55
66import assert from 'assert'
77import * as sinon from 'sinon'
8- import { Ec2ConnectionManager } from '../../../awsService/ec2/model'
8+ import { Ec2Connecter } from '../../../awsService/ec2/model'
99import { SsmClient } from '../../../shared/clients/ssmClient'
1010import { Ec2Client } from '../../../shared/clients/ec2Client'
1111import { Ec2Selection } from '../../../awsService/ec2/prompter'
@@ -15,10 +15,10 @@ import { SshKeyPair } from '../../../awsService/ec2/sshKeyPair'
1515import { DefaultIamClient } from '../../../shared/clients/iamClient'
1616
1717describe ( 'Ec2ConnectClient' , function ( ) {
18- let client : Ec2ConnectionManager
18+ let client : Ec2Connecter
1919
2020 before ( function ( ) {
21- client = new Ec2ConnectionManager ( 'test-region' )
21+ client = new Ec2Connecter ( 'test-region' )
2222 } )
2323
2424 describe ( 'getAttachedIamRole' , async function ( ) {
@@ -82,7 +82,7 @@ describe('Ec2ConnectClient', function () {
8282 } )
8383
8484 it ( 'throws EC2SSMStatus error if instance is not running' , async function ( ) {
85- sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( false )
85+ sinon . stub ( Ec2Connecter . prototype , 'isInstanceRunning' ) . resolves ( false )
8686
8787 try {
8888 await client . checkForStartSessionError ( instanceSelection )
@@ -93,8 +93,8 @@ describe('Ec2ConnectClient', function () {
9393 } )
9494
9595 it ( 'throws EC2SSMPermission error if instance is running but has no role' , async function ( ) {
96- sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( true )
97- sinon . stub ( Ec2ConnectionManager . prototype , 'getAttachedIamRole' ) . resolves ( undefined )
96+ sinon . stub ( Ec2Connecter . prototype , 'isInstanceRunning' ) . resolves ( true )
97+ sinon . stub ( Ec2Connecter . prototype , 'getAttachedIamRole' ) . resolves ( undefined )
9898
9999 try {
100100 await client . checkForStartSessionError ( instanceSelection )
@@ -105,9 +105,9 @@ describe('Ec2ConnectClient', function () {
105105 } )
106106
107107 it ( 'throws EC2SSMAgent error if instance is running and has IAM Role, but agent is not running' , async function ( ) {
108- sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( true )
109- sinon . stub ( Ec2ConnectionManager . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
110- sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPermissions' ) . resolves ( true )
108+ sinon . stub ( Ec2Connecter . prototype , 'isInstanceRunning' ) . resolves ( true )
109+ sinon . stub ( Ec2Connecter . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
110+ sinon . stub ( Ec2Connecter . prototype , 'hasProperPermissions' ) . resolves ( true )
111111 sinon . stub ( SsmClient . prototype , 'getInstanceAgentPingStatus' ) . resolves ( 'offline' )
112112
113113 try {
@@ -119,9 +119,9 @@ describe('Ec2ConnectClient', function () {
119119 } )
120120
121121 it ( 'does not throw an error if all checks pass' , async function ( ) {
122- sinon . stub ( Ec2ConnectionManager . prototype , 'isInstanceRunning' ) . resolves ( true )
123- sinon . stub ( Ec2ConnectionManager . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
124- sinon . stub ( Ec2ConnectionManager . prototype , 'hasProperPermissions' ) . resolves ( true )
122+ sinon . stub ( Ec2Connecter . prototype , 'isInstanceRunning' ) . resolves ( true )
123+ sinon . stub ( Ec2Connecter . prototype , 'getAttachedIamRole' ) . resolves ( { Arn : 'testRole' } as IAM . Role )
124+ sinon . stub ( Ec2Connecter . prototype , 'hasProperPermissions' ) . resolves ( true )
125125 sinon . stub ( SsmClient . prototype , 'getInstanceAgentPingStatus' ) . resolves ( 'Online' )
126126
127127 assert . doesNotThrow ( async ( ) => await client . checkForStartSessionError ( instanceSelection ) )
0 commit comments