Skip to content

Commit

Permalink
chore: make test accounts to be dummy
Browse files Browse the repository at this point in the history
  • Loading branch information
yenfryherrerafeliz committed Aug 5, 2024
1 parent 32aead4 commit be88327
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class AssumeRoleWithWebIdentityCredentialProviderTest extends TestCase
{
const SAMPLE_ROLE_ARN = 'arn:aws:iam::012345678910:role/role_name';
const SAMPLE_ROLE_ARN = 'arn:aws:iam::123456789012:role/role_name';

use UsesServiceTrait;

Expand Down
8 changes: 4 additions & 4 deletions tests/Credentials/CredentialProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function testCreatesFromEnvironmentVariables()
putenv(CredentialProvider::ENV_KEY . '=abc');
putenv(CredentialProvider::ENV_SECRET . '=123');
putenv(CredentialProvider::ENV_SESSION . '=456');
$testAccountId = '123456789000';
$testAccountId = 'foo';
putenv(CredentialProvider::ENV_ACCOUNT_ID ."=$testAccountId");
$creds = call_user_func(CredentialProvider::env())->wait();
$this->assertSame('abc', $creds->getAccessKeyId());
Expand Down Expand Up @@ -211,7 +211,7 @@ public function testCreatesFromIniFile($iniFile, Credentials $expectedCreds)
public function iniFileProvider()
{
$credentials = new Credentials('foo', 'bar', 'baz');
$testAccountId = '123456789000';
$testAccountId = 'foo';
$credentialsWithAccountId = new Credentials('foo', 'bar', 'baz', null, $testAccountId);
$credentialsWithEquals = new Credentials('foo', 'bar', 'baz=');
$standardIni = <<<EOT
Expand Down Expand Up @@ -378,7 +378,7 @@ public function testCreatesFromProcessCredentialProvider()

public function testCreatesFromProcessCredentialProviderWithAccountId()
{
$testAccountId = '123456789000';
$testAccountId = 'foo';
$dir = $this->clearEnv();
$ini = <<<EOT
[foo]
Expand Down Expand Up @@ -471,7 +471,7 @@ public function testCreatesFromIniCredentialWithSharedFilename()

public function testCreatesFromIniCredentialWithDefaultProvider()
{
$testAccountId = '123456789000';
$testAccountId = 'foo';
$dir = $this->clearEnv();
$ini = <<<EOT
[baz]
Expand Down
4 changes: 2 additions & 2 deletions tests/Credentials/CredentialsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CredentialsTest extends TestCase
public function testHasGetters()
{
$exp = time() + 500;
$accountId = '123456789000';
$accountId = 'foo';
$creds = new Credentials('foo', 'baz', 'tok', $exp, $accountId);
$this->assertSame('foo', $creds->getAccessKeyId());
$this->assertSame('baz', $creds->getSecretKey());
Expand Down Expand Up @@ -53,7 +53,7 @@ public function testSerialization()
'expires' => null,
'accountId' => null
], $actual);
$accountId = '123456789000';
$accountId = 'foo';
$credentials = new Credentials('key-value', 'secret-value', 'token-value', 10, $accountId);
$actual = unserialize(serialize($credentials))->toArray();

Expand Down
7 changes: 4 additions & 3 deletions tests/Credentials/EcsCredentialProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,16 @@ private function getClientWithHeaderMiddleware($expectedValue)

public function testResolveCredentialsWithAccountId()
{
$testAccountId = 'foo';
$expiration = time() + 1000;
$testHandler = function (RequestInterface $_) use ($expiration) {
$testHandler = function (RequestInterface $_) use ($expiration, $testAccountId) {
$jsonResponse = <<<EOF
{
"AccessKeyId": "foo",
"SecretAccessKey": "foo",
"Token": "bazz",
"Expiration": "@$expiration",
"AccountId": "123456789012"
"AccountId": "$testAccountId"
}
EOF;
return Promise\Create::promiseFor(new Response(200, [], $jsonResponse));
Expand All @@ -345,7 +346,7 @@ public function testResolveCredentialsWithAccountId()
$this->assertSame('foo', $credentials->getSecretKey());
$this->assertSame('bazz', $credentials->getSecurityToken());
$this->assertSame($expiration, $credentials->getExpiration());
$this->assertSame('123456789012', $credentials->getAccountId());
$this->assertSame($testAccountId, $credentials->getAccountId());
} catch (GuzzleException $e) {
self::fail($e->getMessage());
}
Expand Down
7 changes: 4 additions & 3 deletions tests/Credentials/InstanceProfileProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1629,8 +1629,9 @@ private function getClientForEndpointTesting(\Closure $assertingFunction): \Clos

public function testResolveCredentialsWithAccountId()
{
$testAccountId = 'foo';
$expiration = time() + 1000;
$testHandler = function (RequestInterface $request) use ($expiration) {
$testHandler = function (RequestInterface $request) use ($expiration, $testAccountId) {
if ($request->getMethod() === 'PUT' && $request->getUri()->getPath() === '/latest/api/token') {
return Promise\Create::promiseFor(new Response(200, [], Psr7\Utils::streamFor('')));
} elseif ($request->getMethod() === 'GET') {
Expand All @@ -1645,7 +1646,7 @@ public function testResolveCredentialsWithAccountId()
"SecretAccessKey": "foo",
"Token": "bazz",
"Expiration": "@$expiration",
"AccountId": "123456789012"
"AccountId": "$testAccountId"
}
EOF;
return Promise\Create::promiseFor(
Expand All @@ -1671,6 +1672,6 @@ public function testResolveCredentialsWithAccountId()
$this->assertSame('foo', $credentials->getSecretKey());
$this->assertSame('bazz', $credentials->getSecurityToken());
$this->assertSame($expiration, $credentials->getExpiration());
$this->assertSame('123456789012', $credentials->getAccountId());
$this->assertSame($testAccountId, $credentials->getAccountId());
}
}
2 changes: 1 addition & 1 deletion tests/Sts/StsClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testCanCreateCredentialsObjectFromStsResultWithAssumedRoleUser()
{
$result = new Result([
'AssumedRoleUser' => [
'Arn' => 'arn:aws:iam::123456789000:user/test-user-1'
'Arn' => 'arn:aws:iam::123456789012:user/test-user-1'
],
'Credentials' => [
'AccessKeyId' => 'foo',
Expand Down

0 comments on commit be88327

Please sign in to comment.