Skip to content

Commit e6e1283

Browse files
authored
Unit test clients (#203)
* Adding unit tests for clients. This will make sure the input and the output is correct. * Make sure the response is not resolved * Updated to core2
1 parent 405b5fb commit e6e1283

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Tests/Unit/StsClientTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace AsyncAws\Core\Tests\Unit;
4+
5+
use AsyncAws\Core\Credentials\NullProvider;
6+
use AsyncAws\Core\Sts\Input\AssumeRoleRequest;
7+
use AsyncAws\Core\Sts\Input\GetCallerIdentityRequest;
8+
use AsyncAws\Core\Sts\Result\AssumeRoleResponse;
9+
use AsyncAws\Core\Sts\Result\GetCallerIdentityResponse;
10+
use AsyncAws\Core\Sts\StsClient;
11+
use PHPUnit\Framework\TestCase;
12+
use Symfony\Component\HttpClient\MockHttpClient;
13+
14+
class StsClientTest extends TestCase
15+
{
16+
public function testAssumeRole(): void
17+
{
18+
$client = new StsClient([], new NullProvider(), new MockHttpClient());
19+
20+
$input = new AssumeRoleRequest([
21+
'RoleArn' => 'change me',
22+
'RoleSessionName' => 'change me',
23+
24+
]);
25+
$result = $client->AssumeRole($input);
26+
27+
self::assertInstanceOf(AssumeRoleResponse::class, $result);
28+
self::assertFalse($result->info()['resolved']);
29+
}
30+
31+
public function testGetCallerIdentity(): void
32+
{
33+
$client = new StsClient([], new NullProvider(), new MockHttpClient());
34+
35+
$input = new GetCallerIdentityRequest([
36+
37+
]);
38+
$result = $client->GetCallerIdentity($input);
39+
40+
self::assertInstanceOf(GetCallerIdentityResponse::class, $result);
41+
self::assertFalse($result->info()['resolved']);
42+
}
43+
}

0 commit comments

Comments
 (0)