Skip to content

Commit

Permalink
Add testing for windows residency
Browse files Browse the repository at this point in the history
  • Loading branch information
Hectorhammett committed May 29, 2024
1 parent c0ca065 commit c10d23e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
runs-on: [ubuntu-latest, windows-latest]
strategy:
matrix:
php: [ "8.0", "8.1", "8.2", "8.3" ]
Expand Down
21 changes: 21 additions & 0 deletions tests/Credentials/GCECredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,27 @@ public function testOnWindowsGceWithResidencyWithNoCom()
$this->assertFalse($method->invoke(null, 'thisShouldBeFalse'));
}

public function testOnWindowsGceWithResidency()
{
if (!class_exists(\COM::class)) {
throw $this->markTestSkipped('This test only works while running on windiwos with GCE and the COM class enabled');
}

$method = (new \ReflectionClass(GCECredentials::class))
->getMethod('detectResidencyWindows');
$method->setAccessible(true);

$keyPathProperty = (new \ReflectionClass(GCECredentials::class))
->getProperty('REGISTRY_KEY_PATH');
$keyPathProperty->setAccessible(true);

$keyName = (new \ReflectionClass(GCECredentials::class))
->getProperty('REGISTRY_KEY_NAME');
$keyName->setAccessible(true);

$this->assertTrue($method->invoke(null, $keyPathProperty->getValue() . $keyName->getValue()));
}

public function testOnGCEIsFalseOnOkStatusWithoutExpectedHeader()
{
$httpHandler = getHandler([
Expand Down

0 comments on commit c10d23e

Please sign in to comment.