Skip to content

Commit f881c9e

Browse files
authored
Merge branch 'main' into trust-boundaries
2 parents 94e0416 + 29abd13 commit f881c9e

39 files changed

Lines changed: 88 additions & 87 deletions

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
# The yoshi-php team is the default owner for anything not
99
# explicitly taken by someone else.
10-
* @googleapis/yoshi-php
10+
* @googleapis/cloud-sdk-php-team

tests/AccessTokenTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function provideCertsFromUrl()
293293

294294
public function testRetrieveCertsFromLocationLocalFile()
295295
{
296-
$certsLocation = __DIR__ . '/fixtures/federated-certs.json';
296+
$certsLocation = __DIR__ . '/fixtures/fixtures1/federated-certs.json';
297297
$certsData = json_decode(file_get_contents($certsLocation), true);
298298

299299
$item = $this->prophesize('Psr\Cache\CacheItemInterface');
@@ -336,7 +336,7 @@ public function testRetrieveCertsFromLocationLocalFileInvalidFilePath()
336336
$this->expectException(InvalidArgumentException::class);
337337
$this->expectExceptionMessage('Failed to retrieve verification certificates from path');
338338

339-
$certsLocation = __DIR__ . '/fixtures/federated-certs-does-not-exist.json';
339+
$certsLocation = __DIR__ . '/fixtures/fixtures1/federated-certs-does-not-exist.json';
340340

341341
$item = $this->prophesize('Psr\Cache\CacheItemInterface');
342342
$item->get()
@@ -409,7 +409,7 @@ public function testRetrieveCertsFromLocationLocalFileInvalidFileData()
409409

410410
public function testRetrieveCertsFromLocationRespectsCacheControl()
411411
{
412-
$certsLocation = __DIR__ . '/fixtures/federated-certs.json';
412+
$certsLocation = __DIR__ . '/fixtures/fixtures1/federated-certs.json';
413413
$certsJson = file_get_contents($certsLocation);
414414
$certsData = json_decode($certsJson, true);
415415

@@ -454,7 +454,7 @@ public function testRetrieveCertsFromLocationRespectsCacheControl()
454454

455455
public function testRetrieveCertsFromLocationRemote()
456456
{
457-
$certsLocation = __DIR__ . '/fixtures/federated-certs.json';
457+
$certsLocation = __DIR__ . '/fixtures/fixtures1/federated-certs.json';
458458
$certsJson = file_get_contents($certsLocation);
459459
$certsData = json_decode($certsJson, true);
460460

tests/ApplicationDefaultCredentialsTest.php

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ public function testGetCredentialsFailsIfEnvSpecifiesNonExistentFile()
5959
{
6060
$this->expectException(DomainException::class);
6161

62-
$keyFile = __DIR__ . '/fixtures' . '/does-not-exist-private.json';
62+
$keyFile = __DIR__ . '/fixtures/fixtures1/does-not-exist-private.json';
6363
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
6464
ApplicationDefaultCredentials::getCredentials('a scope');
6565
}
6666

6767
public function testLoadsOKIfEnvSpecifiedIsValid()
6868
{
69-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
69+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
7070
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
7171
$this->assertNotNull(
7272
ApplicationDefaultCredentials::getCredentials('a scope')
@@ -75,7 +75,7 @@ public function testLoadsOKIfEnvSpecifiedIsValid()
7575

7676
public function testLoadsDefaultFileIfPresentAndEnvVarIsNotSet()
7777
{
78-
setHomeEnv(__DIR__ . '/fixtures');
78+
setHomeEnv(__DIR__ . '/fixtures/fixtures1');
7979
$this->assertNotNull(
8080
ApplicationDefaultCredentials::getCredentials('a scope')
8181
);
@@ -164,7 +164,7 @@ public function testGceCredentials()
164164

165165
public function testImpersonatedServiceAccountCredentials()
166166
{
167-
setHomeEnv(__DIR__ . '/fixtures5');
167+
setHomeEnv(__DIR__ . '/fixtures/fixtures5');
168168
$creds = ApplicationDefaultCredentials::getCredentials(
169169
null,
170170
null,
@@ -186,7 +186,7 @@ public function testImpersonatedServiceAccountCredentials()
186186

187187
public function testUserRefreshCredentials()
188188
{
189-
setHomeEnv(__DIR__ . '/fixtures2');
189+
setHomeEnv(__DIR__ . '/fixtures/fixtures2');
190190

191191
$creds = ApplicationDefaultCredentials::getCredentials(
192192
null, // $scope
@@ -221,7 +221,7 @@ public function testUserRefreshCredentials()
221221

222222
public function testServiceAccountCredentials()
223223
{
224-
setHomeEnv(__DIR__ . '/fixtures');
224+
setHomeEnv(__DIR__ . '/fixtures/fixtures1');
225225

226226
$creds = ApplicationDefaultCredentials::getCredentials(
227227
null, // $scope
@@ -256,7 +256,7 @@ public function testServiceAccountCredentials()
256256

257257
public function testDefaultScopeArray()
258258
{
259-
setHomeEnv(__DIR__ . '/fixtures2');
259+
setHomeEnv(__DIR__ . '/fixtures/fixtures2');
260260

261261
$creds = ApplicationDefaultCredentials::getCredentials(
262262
null, // $scope
@@ -278,21 +278,21 @@ public function testGetMiddlewareFailsIfEnvSpecifiesNonExistentFile()
278278
{
279279
$this->expectException(DomainException::class);
280280

281-
$keyFile = __DIR__ . '/fixtures' . '/does-not-exist-private.json';
281+
$keyFile = __DIR__ . '/fixtures/fixtures1/does-not-exist-private.json';
282282
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
283283
ApplicationDefaultCredentials::getMiddleware('a scope');
284284
}
285285

286286
public function testGetMiddlewareLoadsOKIfEnvSpecifiedIsValid()
287287
{
288-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
288+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
289289
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
290290
$this->assertNotNull(ApplicationDefaultCredentials::getMiddleware('a scope'));
291291
}
292292

293293
public function testLGetMiddlewareoadsDefaultFileIfPresentAndEnvVarIsNotSet()
294294
{
295-
setHomeEnv(__DIR__ . '/fixtures');
295+
setHomeEnv(__DIR__ . '/fixtures/fixtures1');
296296
$this->assertNotNull(ApplicationDefaultCredentials::getMiddleware('a scope'));
297297
}
298298

@@ -314,7 +314,7 @@ public function testGetMiddlewareFailsIfNotOnGceAndNoDefaultFileFound()
314314

315315
public function testGetMiddlewareWithCacheOptions()
316316
{
317-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
317+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
318318
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
319319

320320
$httpHandler = getHandler([
@@ -457,14 +457,14 @@ public function testGetIdTokenCredentialsFailsIfEnvSpecifiesNonExistentFile()
457457
{
458458
$this->expectException(DomainException::class);
459459

460-
$keyFile = __DIR__ . '/fixtures' . '/does-not-exist-private.json';
460+
$keyFile = __DIR__ . '/fixtures/fixtures1/does-not-exist-private.json';
461461
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
462462
ApplicationDefaultCredentials::getIdTokenCredentials($this->targetAudience);
463463
}
464464

465465
public function testGetIdTokenCredentialsLoadsOKIfEnvSpecifiedIsValid()
466466
{
467-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
467+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
468468
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
469469

470470
$creds = ApplicationDefaultCredentials::getIdTokenCredentials($this->targetAudience);
@@ -473,7 +473,7 @@ public function testGetIdTokenCredentialsLoadsOKIfEnvSpecifiedIsValid()
473473

474474
public function testGetIdTokenCredentialsLoadsDefaultFileIfPresentAndEnvVarIsNotSet()
475475
{
476-
setHomeEnv(__DIR__ . '/fixtures');
476+
setHomeEnv(__DIR__ . '/fixtures/fixtures1');
477477
$creds = ApplicationDefaultCredentials::getIdTokenCredentials($this->targetAudience);
478478
$this->assertInstanceOf(ServiceAccountCredentials::class, $creds);
479479
}
@@ -500,14 +500,14 @@ public function testGetIdTokenCredentialsFailsIfNotOnGceAndNoDefaultFileFound()
500500

501501
public function testGetIdTokenCredentialsWithImpersonatedServiceAccountCredentials()
502502
{
503-
setHomeEnv(__DIR__ . '/fixtures5');
503+
setHomeEnv(__DIR__ . '/fixtures/fixtures5');
504504
$creds = ApplicationDefaultCredentials::getIdTokenCredentials('123@456.com');
505505
$this->assertInstanceOf(ImpersonatedServiceAccountCredentials::class, $creds);
506506
}
507507

508508
public function testGetIdTokenCredentialsWithCacheOptions()
509509
{
510-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
510+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
511511
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
512512

513513
$httpHandler = getHandler([
@@ -553,7 +553,7 @@ public function testGetIdTokenCredentialsSuccedsIfNoDefaultFilesButIsOnGCE()
553553

554554
public function testGetIdTokenCredentialsWithUserRefreshCredentials()
555555
{
556-
setHomeEnv(__DIR__ . '/fixtures2');
556+
setHomeEnv(__DIR__ . '/fixtures/fixtures2');
557557

558558
$creds = ApplicationDefaultCredentials::getIdTokenCredentials(
559559
$this->targetAudience,
@@ -572,7 +572,7 @@ public function testGetIdTokenCredentialsWithUserRefreshCredentials()
572572

573573
public function testWithServiceAccountCredentialsAndExplicitQuotaProject()
574574
{
575-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
575+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
576576
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
577577

578578
$credentials = ApplicationDefaultCredentials::getCredentials(
@@ -593,7 +593,7 @@ public function testWithServiceAccountCredentialsAndExplicitQuotaProject()
593593

594594
public function testGetCredentialsUtilizesQuotaProjectInKeyFile()
595595
{
596-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
596+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
597597
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
598598

599599
$credentials = ApplicationDefaultCredentials::getCredentials();
@@ -609,7 +609,7 @@ public function testGetCredentialsUtilizesQuotaProjectEnvVar()
609609
{
610610
$quotaProject = 'quota-project-from-env-var';
611611
putenv(CredentialsLoader::QUOTA_PROJECT_ENV_VAR . '=' . $quotaProject);
612-
setHomeEnv(__DIR__ . '/fixtures');
612+
setHomeEnv(__DIR__ . '/fixtures/fixtures1');
613613

614614
$credentials = ApplicationDefaultCredentials::getCredentials();
615615

@@ -624,7 +624,7 @@ public function testGetCredentialsUtilizesQuotaProjectParameterOverEnvVar()
624624
{
625625
$quotaProject = 'quota-project-from-parameter';
626626
putenv(CredentialsLoader::QUOTA_PROJECT_ENV_VAR . '=quota-project-from-env-var');
627-
setHomeEnv(__DIR__ . '/fixtures');
627+
setHomeEnv(__DIR__ . '/fixtures/fixtures1');
628628

629629
$credentials = ApplicationDefaultCredentials::getCredentials(
630630
null, // $scope
@@ -645,7 +645,7 @@ public function testGetCredentialsUtilizesQuotaProjectParameterOverEnvVar()
645645
public function testGetCredentialsUtilizesQuotaProjectEnvVarOverKeyFile()
646646
{
647647
$quotaProject = 'quota-project-from-env-var';
648-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
648+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
649649
putenv(CredentialsLoader::QUOTA_PROJECT_ENV_VAR . '=' . $quotaProject);
650650
putenv(CredentialsLoader::ENV_VAR . '=' . $keyFile);
651651

@@ -659,7 +659,7 @@ public function testGetCredentialsUtilizesQuotaProjectEnvVarOverKeyFile()
659659

660660
public function testWithFetchAuthTokenCacheAndExplicitQuotaProject()
661661
{
662-
$keyFile = __DIR__ . '/fixtures' . '/private.json';
662+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
663663
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
664664

665665
$httpHandler = getHandler([
@@ -761,7 +761,7 @@ public function testAppEngineFlexibleIdToken()
761761
*/
762762
public function testExternalAccountCredentials(string $jsonFile, string $expectedCredSource)
763763
{
764-
putenv(sprintf('GOOGLE_APPLICATION_CREDENTIALS=%s/fixtures6/%s', __DIR__, $jsonFile));
764+
putenv(sprintf('GOOGLE_APPLICATION_CREDENTIALS=%s/fixtures/fixtures6/%s', __DIR__, $jsonFile));
765765

766766
$creds = ApplicationDefaultCredentials::getCredentials('a_scope');
767767

@@ -832,19 +832,19 @@ public function provideExternalAccountCredentials()
832832
public function testUniverseDomainInKeyFile()
833833
{
834834
// Test no universe domain in keyfile defaults to "googleapis.com"
835-
$keyFile = __DIR__ . '/fixtures3/service_account_credentials.json';
835+
$keyFile = __DIR__ . '/fixtures/fixtures3/service_account_credentials.json';
836836
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
837837
$creds = ApplicationDefaultCredentials::getCredentials();
838838
$this->assertEquals(CredentialsLoader::DEFAULT_UNIVERSE_DOMAIN, $creds->getUniverseDomain());
839839

840840
// Test universe domain in "service_account" keyfile
841-
$keyFile = __DIR__ . '/fixtures/private.json';
841+
$keyFile = __DIR__ . '/fixtures/fixtures1/private.json';
842842
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
843843
$creds = ApplicationDefaultCredentials::getCredentials();
844844
$this->assertEquals('example-universe.com', $creds->getUniverseDomain());
845845

846846
// Test universe domain in "authenticated_user" keyfile is not read.
847-
$keyFile = __DIR__ . '/fixtures2/private.json';
847+
$keyFile = __DIR__ . '/fixtures/fixtures2/private.json';
848848
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
849849
$creds2 = ApplicationDefaultCredentials::getCredentials();
850850
$this->assertEquals(CredentialsLoader::DEFAULT_UNIVERSE_DOMAIN, $creds2->getUniverseDomain());

tests/Credentials/GCECredentialsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ public function testOnWindowsGceWithResidencyWithNoCom()
139139
$method = (new ReflectionClass(GCECredentials::class))
140140
->getMethod('detectResidencyWindows');
141141

142-
143142
$this->assertFalse($method->invoke(null, 'thisShouldBeFalse'));
144143
}
145144

tests/Credentials/ServiceAccountCredentialsTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private function createTestJson()
4141
'client_id' => 'client123',
4242
'type' => 'service_account',
4343
'project_id' => 'example_project',
44-
'private_key' => file_get_contents(__DIR__ . '/../fixtures/private.pem'),
44+
'private_key' => file_get_contents(__DIR__ . '/../fixtures/fixtures1/private.pem'),
4545
];
4646
}
4747

@@ -138,13 +138,13 @@ public function testFailsToInitalizeFromANonExistentFile()
138138
{
139139
$this->expectException(InvalidArgumentException::class);
140140

141-
$keyFile = __DIR__ . '/../fixtures' . '/does-not-exist-private.json';
141+
$keyFile = __DIR__ . '/../fixtures/fixtures1/does-not-exist-private.json';
142142
new ServiceAccountCredentials('scope/1', $keyFile);
143143
}
144144

145145
public function testInitalizeFromAFile()
146146
{
147-
$keyFile = __DIR__ . '/../fixtures' . '/private.json';
147+
$keyFile = __DIR__ . '/../fixtures/fixtures1/private.json';
148148
$this->assertNotNull(
149149
new ServiceAccountCredentials('scope/1', $keyFile)
150150
);
@@ -176,15 +176,15 @@ public function testIsNullIfEnvVarIsNotSet()
176176
public function testFailsIfEnvSpecifiesNonExistentFile()
177177
{
178178
$this->expectException(DomainException::class);
179-
$keyFile = __DIR__ . '/../fixtures' . '/does-not-exist-private.json';
179+
$keyFile = __DIR__ . '/../fixtures/fixtures1/does-not-exist-private.json';
180180
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
181181
ApplicationDefaultCredentials::getCredentials('a scope');
182182
}
183183

184184
/** @runInSeparateProcess */
185185
public function testSucceedIfFileExists()
186186
{
187-
$keyFile = __DIR__ . '/../fixtures' . '/private.json';
187+
$keyFile = __DIR__ . '/../fixtures/fixtures1/private.json';
188188
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
189189
$this->assertNotNull(ApplicationDefaultCredentials::getCredentials('a scope'));
190190
}
@@ -201,7 +201,7 @@ public function testIsNullIfFileDoesNotExist()
201201
/** @runInSeparateProcess */
202202
public function testSucceedIfFileIsPresent()
203203
{
204-
setHomeEnv(__DIR__ . '/../fixtures');
204+
setHomeEnv(__DIR__ . '/../fixtures/fixtures1');
205205
$this->assertNotNull(
206206
ApplicationDefaultCredentials::getCredentials('a scope')
207207
);
@@ -420,7 +420,7 @@ public function testGetProjectId()
420420

421421
public function testGetQuotaProject()
422422
{
423-
$keyFile = __DIR__ . '/../fixtures' . '/private.json';
423+
$keyFile = __DIR__ . '/../fixtures/fixtures1/private.json';
424424
$sa = new ServiceAccountCredentials('scope/1', $keyFile);
425425
$this->assertEquals('test_quota_project', $sa->getQuotaProject());
426426
}

tests/Credentials/ServiceAccountJwtAccessCredentialsTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ private function createTestJson()
4040
'client_id' => 'client123',
4141
'type' => 'service_account',
4242
'project_id' => 'example_project',
43-
'private_key' => file_get_contents(__DIR__ . '/../fixtures' . '/private.pem'),
43+
'private_key' => file_get_contents(__DIR__ . '/../fixtures/fixtures1/private.pem'),
4444
];
4545
}
4646

4747
public function testFailsToInitalizeFromANonExistentFile()
4848
{
4949
$this->expectException(InvalidArgumentException::class);
5050

51-
$keyFile = __DIR__ . '/../fixtures' . '/does-not-exist-private.json';
51+
$keyFile = __DIR__ . '/../fixtures/fixtures1/does-not-exist-private.json';
5252
new ServiceAccountJwtAccessCredentials($keyFile);
5353
}
5454

5555
public function testInitalizeFromAFile()
5656
{
57-
$keyFile = __DIR__ . '/../fixtures' . '/private.json';
57+
$keyFile = __DIR__ . '/../fixtures/fixtures1/private.json';
5858
$this->assertNotNull(
5959
new ServiceAccountJwtAccessCredentials($keyFile)
6060
);
@@ -392,7 +392,7 @@ public function testFetchAuthTokenWithScopeAndUseJwtAccessWithScopeParameterAndA
392392
/** @runInSeparateProcess */
393393
public function testAccessFromApplicationDefault()
394394
{
395-
$keyFile = __DIR__ . '/../fixtures3/service_account_credentials.json';
395+
$keyFile = __DIR__ . '/../fixtures/fixtures3/service_account_credentials.json';
396396
putenv(ServiceAccountCredentials::ENV_VAR . '=' . $keyFile);
397397
$creds = ApplicationDefaultCredentials::getCredentials(
398398
null, // $scope
@@ -408,7 +408,7 @@ public function testAccessFromApplicationDefault()
408408

409409
$this->assertArrayHasKey('authorization', $metadata);
410410
$token = str_replace('Bearer ', '', $metadata['authorization'][0]);
411-
$key = file_get_contents(__DIR__ . '/../fixtures3/key.pub');
411+
$key = file_get_contents(__DIR__ . '/../fixtures/fixtures3/key.pub');
412412
$result = JWT::decode($token, new Key($key, 'RS256'));
413413

414414
$this->assertEquals($authUri, $result->aud);
@@ -509,7 +509,7 @@ public function testGetProjectId()
509509

510510
public function testGetQuotaProject()
511511
{
512-
$keyFile = __DIR__ . '/../fixtures' . '/private.json';
512+
$keyFile = __DIR__ . '/../fixtures/fixtures1/private.json';
513513
$sa = new ServiceAccountJwtAccessCredentials($keyFile);
514514
$this->assertEquals('test_quota_project', $sa->getQuotaProject());
515515
}

0 commit comments

Comments
 (0)