Skip to content

Commit a6e0e84

Browse files
committed
Provide version information to SDK user agent
1 parent 7fb2fed commit a6e0e84

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

config/aws.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22

3+
use Aws\Laravel\AwsServiceProvider;
4+
use Illuminate\Foundation\Application;
5+
36
return [
47

58
/*
@@ -20,5 +23,8 @@
2023
],
2124
'region' => env('AWS_REGION', 'us-east-1'),
2225
'version' => 'latest',
23-
26+
'ua_append' => [
27+
'Laravel/' . Application::VERSION,
28+
'L5MOD/' . AwsServiceProvider::VERSION,
29+
],
2430
];

src/AwsServiceProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
class AwsServiceProvider extends ServiceProvider
1010
{
11+
const VERSION = '3.0.1';
1112

1213
/**
1314
* Indicates if loading of the provider is deferred.

tests/AwsServiceProviderTest.php

+17
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ public function testServiceNameIsProvided()
4646
$this->assertContains('aws', $provider->provides());
4747
}
4848

49+
public function testVersionInformationIsProvidedToSdkUserAgent()
50+
{
51+
$app = $this->setupApplication();
52+
$this->setupServiceProvider($app);
53+
$config = $app['config']->get('aws');
54+
55+
$this->assertArrayHasKey('ua_append', $config);
56+
$this->assertInternalType('array', $config['ua_append']);
57+
$this->assertNotEmpty($config['ua_append']);
58+
$this->assertNotEmpty(array_filter($config['ua_append'], function ($ua) {
59+
return false !== strpos($ua, Application::VERSION);
60+
}));
61+
$this->assertNotEmpty(array_filter($config['ua_append'], function ($ua) {
62+
return false !== strpos($ua, AwsServiceProvider::VERSION);
63+
}));
64+
}
65+
4966
/**
5067
* @return Application
5168
*/

0 commit comments

Comments
 (0)