@@ -42,36 +42,12 @@ describe('Ec2ConnectClient', function () {
4242 } )
4343 } )
4444
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-
45+ describe ( 'hasProperPermissions' , async function ( ) {
7046 it ( 'throws error when sdk throws error' , async function ( ) {
7147 sinon . stub ( DefaultIamClient . prototype , 'listAttachedRolePolicies' ) . throws ( new ToolkitError ( 'error' ) )
7248
7349 try {
74- await client . hasProperPolicies ( '' )
50+ await client . hasProperPermissions ( '' )
7551 assert . ok ( false )
7652 } catch {
7753 assert . ok ( true )
@@ -131,7 +107,7 @@ describe('Ec2ConnectClient', function () {
131107 it ( 'throws EC2SSMAgent error if instance is running and has IAM Role, but agent is not running' , async function ( ) {
132108 sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( true )
133109 sinon . stub ( Ec2ConnectionManager . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
134- sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPolicies ' ) . resolves ( true )
110+ sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPermissions ' ) . resolves ( true )
135111 sinon . stub ( SsmClient . prototype , 'getInstanceAgentPingStatus' ) . resolves ( 'offline' )
136112
137113 try {
@@ -145,7 +121,7 @@ describe('Ec2ConnectClient', function () {
145121 it ( 'does not throw an error if all checks pass' , async function ( ) {
146122 sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( true )
147123 sinon . stub ( Ec2ConnectionManager . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
148- sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPolicies ' ) . resolves ( true )
124+ sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPermissions ' ) . resolves ( true )
149125 sinon . stub ( SsmClient . prototype , 'getInstanceAgentPingStatus' ) . resolves ( 'Online' )
150126
151127 assert . doesNotThrow ( async ( ) => await client . checkForStartSessionError ( instanceSelection ) )
0 commit comments