diff --git a/Core/tests/Unit/ClientTraitTest.php b/Core/tests/Unit/ClientTraitTest.php index 5d9a28ef2a55..44dbe398e4cd 100644 --- a/Core/tests/Unit/ClientTraitTest.php +++ b/Core/tests/Unit/ClientTraitTest.php @@ -168,10 +168,7 @@ public function testConfigureAuthenticationWithKeyFilePath() public function testIgnoreKeyFileWhenUsingCredentialsFetcher() { - $keyFilePath = Fixtures::SERVICE_ACCOUNT_FIXTURE(); - $key = json_decode(file_get_contents($keyFilePath), true); - $key['private_key'] = 'xxx'; - + $key = Fixtures::SERVICE_ACCOUNT_FIXTURE(); $credentials = new ServiceAccountCredentials([], $key); $conf = $this->impl->call('configureAuthentication', [[ @@ -183,10 +180,7 @@ public function testIgnoreKeyFileWhenUsingCredentialsFetcher() public function testGetProjectIdFromCredentialsFetcher() { - $keyFilePath = Fixtures::SERVICE_ACCOUNT_FIXTURE(); - $key = json_decode(file_get_contents($keyFilePath), true); - $key['private_key'] = 'xxx'; - + $key = Fixtures::SERVICE_ACCOUNT_FIXTURE(); $credentials = new ServiceAccountCredentials([], $key); $this->impl->call('configureAuthentication', [[ diff --git a/Core/tests/Unit/Fixtures.php b/Core/tests/Unit/Fixtures.php index 663090c8b358..3c45ee6c15c4 100644 --- a/Core/tests/Unit/Fixtures.php +++ b/Core/tests/Unit/Fixtures.php @@ -25,9 +25,20 @@ public static function JSON_KEY_FIXTURE() return __DIR__ . '/fixtures/json-key-fixture.json'; } - public static function SERVICE_ACCOUNT_FIXTURE() + public static function SERVICE_ACCOUNT_FIXTURE(): array { - return __DIR__ . '/fixtures/service-account-fixture.json'; + return [ + 'type' => 'service_account', + 'project_id' => 'example-project-12345', + 'private_key_id' => 'xyz', + 'client_email' => 'test-service-account@example-project-12345.iam.gserviceaccount.com', + 'client_id' => '123456789012345678901', + 'private_key' => 'xyz', + 'auth_uri' => 'https://accounts.google.com/o/oauth2/auth', + 'token_uri' => 'https://oauth2.googleapis.com/token', + 'auth_provider_x509_cert_url' => 'https://www.googleapis.com/oauth2/v1/certs', + 'client_x509_cert_url' => 'https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40example-project-12345.iam.gserviceaccount.com' + ]; } public static function SERVICE_FIXTURE() diff --git a/Core/tests/Unit/fixtures/service-account-fixture.json b/Core/tests/Unit/fixtures/service-account-fixture.json deleted file mode 100644 index 8d124ca8ac6a..000000000000 --- a/Core/tests/Unit/fixtures/service-account-fixture.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "service_account", - "project_id": "example-project-12345", - "private_key_id": "1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b", - "client_email": "test-service-account@example-project-12345.iam.gserviceaccount.com", - "client_id": "123456789012345678901", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/test-service-account%40example-project-12345.iam.gserviceaccount.com" -}