-
Notifications
You must be signed in to change notification settings - Fork 736
test(ec2): add security related unit tests #5778
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
24919b7
add test for minimum ssm actions
Hweinstock 61f95f0
refactor pathfinder
Hweinstock 12cf3ec
fix tests
Hweinstock 423ca0c
assert called with resulting ssh path
Hweinstock 9a72b73
add ui tests
Hweinstock b741e83
rename files back
Hweinstock d6c052b
fix imports
Hweinstock b2890bd
add more testing
Hweinstock 697f4bc
avoid unnecessary churn
Hweinstock b47c788
fix imports
Hweinstock 57eb886
avoid circular dependency
Hweinstock 8a1131d
add offset for windows calls
Hweinstock 4071645
move tryRun back
Hweinstock 36c133b
write tests that do not stub fs
Hweinstock 4a55e56
remove duplicate func
Hweinstock a92ba99
add docstring to testUtil
Hweinstock c2e17bd
add tests for path utility;
Hweinstock 4cb7b3c
avoid moving function
Hweinstock 60c2bed
refactor
Hweinstock 5c48e66
avoid with paradigm
Hweinstock eff906a
make param optional
Hweinstock 622c4d2
try case sensitive version
Hweinstock 07026be
add sanity tests for util
Hweinstock f13cf65
avoid .cmd extension
Hweinstock a11c2fc
remove cmd
Hweinstock b910f85
remove linux-command in exec
Hweinstock bb1c3b9
add tests for executable file
Hweinstock 5697da1
add extension to make it executable
Hweinstock b57053d
try .cmd instead of .exe
Hweinstock ba9fa6f
replace manual childprocess with tryRun
Hweinstock ff0cf37
remove cmd extension
Hweinstock bd292c2
re-write unit tests
Hweinstock 6bec701
adjust tests
Hweinstock 3d1740a
adjust windows cases
Hweinstock 6b1bf0f
make a windows specific test
Hweinstock 69f09ab
fix tests to be windows/mac specific
Hweinstock d10f613
Update packages/core/src/test/shared/utilities/testUtils.test.ts
Hweinstock cfcc6bb
Update packages/core/src/test/testUtil.ts
Hweinstock 4b0785f
refactor to shallow copy
Hweinstock deff2a2
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock c6f02ac
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock 5810995
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock 2d0d4fb
remove unneeded utility function
Hweinstock 912d579
fix dupe var in test
Hweinstock f2441ea
Merge branch 'master' into securityTests
Hweinstock 7e7b0cb
write only to PATH
Hweinstock a28c33e
rewrite only the PATH var
Hweinstock 3c80c2f
skip path test on windows, avoid generate assertion on windows
Hweinstock b82672a
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock e103c1e
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock a8880de
Update packages/core/src/test/shared/utilities/testUtils.test.ts
Hweinstock 6cc9743
fix env ref
Hweinstock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { getLogger } from '..' | ||
| import { ChildProcess, ChildProcessOptions } from './processUtils' | ||
|
|
||
| /** | ||
| * Tries to execute a program at path `p` with the given args and | ||
| * optionally checks the output for `expected`. | ||
| * | ||
| * @param p path to a program to execute | ||
| * @param args program args | ||
| * @param doLog log failures | ||
| * @param expected output must contain this string | ||
| */ | ||
| export async function tryRun( | ||
Hweinstock marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| p: string, | ||
| args: string[], | ||
| logging: 'yes' | 'no' | 'noresult' = 'yes', | ||
| expected?: string, | ||
| opt?: ChildProcessOptions | ||
| ): Promise<boolean> { | ||
| const proc = new ChildProcess(p, args, { logging: 'no' }) | ||
| const r = await proc.run(opt) | ||
| const ok = r.exitCode === 0 && (expected === undefined || r.stdout.includes(expected)) | ||
| if (logging === 'noresult') { | ||
| getLogger().info('tryRun: %s: %s', ok ? 'ok' : 'failed', proc) | ||
| } else if (logging !== 'no') { | ||
| getLogger().info('tryRun: %s: %s %O', ok ? 'ok' : 'failed', proc, proc.result()) | ||
| } | ||
| return ok | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| import assert from 'assert' | ||
| import { minimumSsmActions, promptToAddInlinePolicy } from '../../shared/remoteSession' | ||
| import { IamClient } from '../../shared/clients/iamClient' | ||
| import { getTestWindow } from './vscode/window' | ||
| import { cancel } from '../../shared' | ||
|
|
||
| describe('minimumSsmActions', function () { | ||
| it('should contain minimal actions needed for ssm connection', function () { | ||
| assert.deepStrictEqual(minimumSsmActions, [ | ||
| 'ssmmessages:CreateControlChannel', | ||
| 'ssmmessages:CreateDataChannel', | ||
| 'ssmmessages:OpenControlChannel', | ||
| 'ssmmessages:OpenDataChannel', | ||
| 'ssm:DescribeAssociation', | ||
| 'ssm:ListAssociations', | ||
| 'ssm:UpdateInstanceInformation', | ||
| ]) | ||
| }) | ||
|
|
||
| it('prompts the user for confirmation before adding policies and allow cancels', async function () { | ||
| getTestWindow().onDidShowMessage((message) => { | ||
| assert.ok(message.message.includes('add'), 'should prompt to add policies') | ||
| getTestWindow().getFirstMessage().selectItem(cancel) | ||
| }) | ||
| const added = await promptToAddInlinePolicy({} as IamClient, 'roleArnTest') | ||
| assert.ok(!added, 'should not add policies by default') | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.