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