@@ -43,45 +43,6 @@ describe('Ec2ConnectClient', function () {
43
43
} )
44
44
} )
45
45
46
- describe ( 'hasProperPolicies' , async function ( ) {
47
- it ( 'correctly determines if proper policies are included' , async function ( ) {
48
- async function assertAcceptsPolicies ( policies : IAM . Policy [ ] , expectedResult : boolean ) {
49
- sinon . stub ( DefaultIamClient . prototype , 'listAttachedRolePolicies' ) . resolves ( policies )
50
-
51
- const result = await client . hasProperPolicies ( '' )
52
- assert . strictEqual ( result , expectedResult )
53
-
54
- sinon . restore ( )
55
- }
56
- await assertAcceptsPolicies (
57
- [ { PolicyName : 'name' } , { PolicyName : 'name2' } , { PolicyName : 'name3' } ] ,
58
- false
59
- )
60
- await assertAcceptsPolicies (
61
- [
62
- { PolicyName : 'AmazonSSMManagedInstanceCore' } ,
63
- { PolicyName : 'AmazonSSMManagedEC2InstanceDefaultPolicy' } ,
64
- ] ,
65
- true
66
- )
67
- await assertAcceptsPolicies ( [ { PolicyName : 'AmazonSSMManagedEC2InstanceDefaultPolicy' } ] , false )
68
- await assertAcceptsPolicies ( [ { PolicyName : 'AmazonSSMManagedEC2InstanceDefaultPolicy' } ] , false )
69
- } )
70
-
71
- it ( 'throws error when sdk throws error' , async function ( ) {
72
- sinon . stub ( DefaultIamClient . prototype , 'listAttachedRolePolicies' ) . throws ( new ToolkitError ( 'error' ) )
73
-
74
- try {
75
- await client . hasProperPolicies ( '' )
76
- assert . ok ( false )
77
- } catch {
78
- assert . ok ( true )
79
- }
80
-
81
- sinon . restore ( )
82
- } )
83
- } )
84
-
85
46
describe ( 'isInstanceRunning' , async function ( ) {
86
47
it ( 'only returns true with the instance is running' , async function ( ) {
87
48
sinon . stub ( Ec2Client . prototype , 'getInstanceStatus' ) . callsFake ( async ( input : string ) => input . split ( ':' ) [ 0 ] )
@@ -132,7 +93,7 @@ describe('Ec2ConnectClient', function () {
132
93
it ( 'throws EC2SSMAgent error if instance is running and has IAM Role, but agent is not running' , async function ( ) {
133
94
sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( true )
134
95
sinon . stub ( Ec2ConnectionManager . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
135
- sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPolicies ' ) . resolves ( true )
96
+ sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPermissions ' ) . resolves ( true )
136
97
sinon . stub ( SsmClient . prototype , 'getInstanceAgentPingStatus' ) . resolves ( 'offline' )
137
98
138
99
try {
@@ -148,7 +109,7 @@ describe('Ec2ConnectClient', function () {
148
109
it ( 'does not throw an error if all checks pass' , async function ( ) {
149
110
sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( true )
150
111
sinon . stub ( Ec2ConnectionManager . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
151
- sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPolicies ' ) . resolves ( true )
112
+ sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPermissions ' ) . resolves ( true )
152
113
sinon . stub ( SsmClient . prototype , 'getInstanceAgentPingStatus' ) . resolves ( 'Online' )
153
114
154
115
assert . doesNotThrow ( async ( ) => await client . checkForStartSessionError ( instanceSelection ) )
0 commit comments