File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,27 @@ describe('Ec2ConnectClient', function () {
22
22
client = new Ec2ConnectionManager ( 'test-region' )
23
23
} )
24
24
25
+ describe ( 'getAttachedIamRole' , async function ( ) {
26
+ it ( 'only returns role if recieves ARN from instance profile' , async function ( ) {
27
+ let role : IAM . Role | undefined
28
+ const getInstanceProfileStub = sinon . stub ( Ec2Client . prototype , 'getAttachedIamInstanceProfile' )
29
+
30
+ getInstanceProfileStub . resolves ( { Arn : 'thisIsAnArn' } )
31
+ sinon
32
+ . stub ( DefaultIamClient . prototype , 'getIAMRoleFromInstanceProfile' )
33
+ . resolves ( { Arn : 'ThisIsARoleArn' } as IAM . Role )
34
+
35
+ role = await client . getAttachedIamRole ( 'test-instance' )
36
+ assert . ok ( role )
37
+ assert . ok ( role . Arn )
38
+
39
+ getInstanceProfileStub . resolves ( { } )
40
+ role = await client . getAttachedIamRole ( 'test-instance' )
41
+ assert . strictEqual ( role , undefined )
42
+ sinon . restore ( )
43
+ } )
44
+ } )
45
+
25
46
describe ( 'isInstanceRunning' , async function ( ) {
26
47
it ( 'only returns true with the instance is running' , async function ( ) {
27
48
sinon . stub ( Ec2Client . prototype , 'getInstanceStatus' ) . callsFake ( async ( input : string ) => input . split ( ':' ) [ 0 ] )
You can’t perform that action at this time.
0 commit comments