-
Notifications
You must be signed in to change notification settings - Fork 738
refactor(ec2): enforce ssh key inside global storage. #5814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
d670ef2
05e6d52
12fc398
e9d011a
0e966cb
dc2b756
b1cda5f
02eed17
593538a
44aa977
8f23d8a
9762798
539f0e7
fdaa72c
11ce1ca
304991a
075b050
15b7b79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,8 @@ import { ToolkitError } from '../../../shared/errors' | |||||
| import { IAM } from 'aws-sdk' | ||||||
| import { SshKeyPair } from '../../../awsService/ec2/sshKeyPair' | ||||||
| import { DefaultIamClient } from '../../../shared/clients/iamClient' | ||||||
| import path from 'path' | ||||||
| import { fs, globals } from '../../../shared' | ||||||
|
|
||||||
| describe('Ec2ConnectClient', function () { | ||||||
| let client: Ec2ConnectionManager | ||||||
|
|
@@ -132,17 +134,19 @@ describe('Ec2ConnectClient', function () { | |||||
| it('calls the sdk with the proper parameters', async function () { | ||||||
| const sendCommandStub = sinon.stub(SsmClient.prototype, 'sendCommandAndWait') | ||||||
|
|
||||||
| sinon.stub(SshKeyPair, 'generateSshKeyPair') | ||||||
| sinon.stub(SshKeyPair.prototype, 'getPublicKey').resolves('test-key') | ||||||
|
|
||||||
| const testSelection = { | ||||||
| instanceId: 'test-id', | ||||||
| region: 'test-region', | ||||||
| } | ||||||
| const mockKeys = await SshKeyPair.getSshKeyPair('fakeDir', 30000) | ||||||
| await client.sendSshKeyToInstance(testSelection, mockKeys, 'test-user') | ||||||
| const temporaryDirectory = path.join(globals.context.globalStorageUri.fsPath, 'ModelTests') | ||||||
|
||||||
| await testUtil.deleteTestTempDirs() |
So maybe you could add:
await fs.delete(globals.context.globalStorageUri.fsPath, { recursive: true, force: true })around here:
| await globals.globalState.clear() |
which I think we should have been doing in the first place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I move the temp keys into the globalStorage itself, then is there any reason I need this to clear on afterEach? I would think deleting the temp dir on after should be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not clear globalStorageUri after each test we'll probably have a collision somewhere later.
Lets say you had a test that created an ssh key, then the following test assumed that since it is a new test the globalStorage will not have a key by default. The initial test state bled over in to the next and left some unexpected artifacts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Was there any reason we didn't want to do this before? Is it expensive/slow to delete all its contents for every test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't used it much in tests before, so it was just an oversight.
Uh oh!
There was an error while loading. Please reload this page.