Skip to content

Commit 4d6780e

Browse files
committed
Update auth to use GOOGLE_APPLICATION_CREDENTIALS environment
1 parent b8fbac2 commit 4d6780e

File tree

7 files changed

+3
-38
lines changed

7 files changed

+3
-38
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ composer require stackkit/laravel-google-cloud-tasks-queue
5252
```
5353
'cloudtasks' => [
5454
'driver' => 'cloudtasks',
55-
'credentials' => base_path('gcloud-key.json'),
5655
'project' => env('STACKKIT_CLOUD_TASKS_PROJECT', ''),
5756
'location' => env('STACKKIT_CLOUD_TASKS_LOCATION', ''),
5857
'handler' => env('STACKKIT_CLOUD_TASKS_HANDLER', ''),

phpunit.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<env name="SESSION_DRIVER" value="array"/>
2323
<env name="MAIL_DRIVER" value="log"/>
2424
<env name="QUEUE_DRIVER" value="cloudtasks"/>
25+
<env name="GOOGLE_APPLICATION_CREDENTIALS" value="./tests/Support/gcloud-key-valid.json" />
2526
</php>
2627

2728
<filter>

src/CloudTasksServiceProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ public function boot(QueueManager $queue, Router $router)
1919
private function registerClient()
2020
{
2121
$this->app->singleton(CloudTasksClient::class, function () {
22-
return new CloudTasksClient([
23-
'credentials' => Config::credentials(),
24-
]);
22+
return new CloudTasksClient();
2523
});
2624
}
2725

src/Config.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ public static function serviceAccountEmail()
3333

3434
public static function validate(array $config)
3535
{
36-
if (empty($config['credentials'])) {
37-
throw new Error(Errors::invalidCredentials());
38-
}
39-
40-
if (!file_exists($config['credentials'])) {
41-
throw new Error(Errors::credentialsFileDoesNotExist());
42-
}
43-
4436
if (empty($config['project'])) {
4537
throw new Error(Errors::invalidProject());
4638
}

tests/ConfigTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,6 @@
88

99
class ConfigTest extends TestCase
1010
{
11-
/** @test */
12-
public function credentials_are_required()
13-
{
14-
$this->setConfigValue('credentials', '');
15-
16-
$this->expectException(Error::class);
17-
$this->expectExceptionMessage(Errors::invalidCredentials());
18-
19-
SimpleJob::dispatch();
20-
}
21-
22-
/** @test */
23-
public function credentials_file_must_exist()
24-
{
25-
$this->setConfigValue('credentials', 'doesnotexist.json');
26-
27-
$this->expectException(Error::class);
28-
$this->expectExceptionMessage(Errors::credentialsFileDoesNotExist());
29-
30-
SimpleJob::dispatch();
31-
}
32-
3311
/** @test */
3412
public function project_is_required()
3513
{

tests/TaskHandlerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ protected function setUp(): void
4545
$googlePublicKey->shouldReceive('getKidFromOpenIdToken')->andReturnNull();
4646

4747
$this->handler = new TaskHandler(
48-
new CloudTasksClient([
49-
'credentials' => __DIR__ . '/Support/gcloud-key-valid.json'
50-
]),
48+
new CloudTasksClient(),
5149
request(),
5250
$this->jwt,
5351
$googlePublicKey

tests/TestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ protected function getEnvironmentSetUp($app)
3232
$app['config']->set('queue.default', 'cloudtasks');
3333
$app['config']->set('queue.connections.cloudtasks', [
3434
'driver' => 'cloudtasks',
35-
'credentials' => __DIR__ . '/Support/gcloud-key-valid.json',
3635
'queue' => 'test-queue',
3736
'project' => 'test-project',
3837
'location' => 'europe-west6',

0 commit comments

Comments
 (0)