-
Notifications
You must be signed in to change notification settings - Fork 119
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
test: connection url appstream #673
Merged
SanketD92
merged 5 commits into
feat-secure-workspace-egress
from
test-connection-url-appstream
Aug 25, 2021
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
38ef1cc
feat: adding appstream integ tests for connect URL
SanketD92 5935c23
Merge branch 'feat-secure-workspace-egress' of https://github.com/aws…
SanketD92 7c84e8d
code cleanup
SanketD92 410360a
fix: changes per review
SanketD92 431940f
code cleanup
SanketD92 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 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 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 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
103 changes: 103 additions & 0 deletions
103
...stream-egress-enabled/workspace-service-catalog/connections/create-url-connection.test.js
This file contains 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,103 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
const fetch = require('node-fetch'); | ||
SanketD92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { runSetup } = require('../../../../../support/setup'); | ||
|
||
describe('Create URL scenarios', () => { | ||
let setup; | ||
let adminSession; | ||
|
||
beforeAll(async () => { | ||
setup = await runSetup(); | ||
adminSession = await setup.defaultAdminSession(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await setup.cleanup(); | ||
}); | ||
|
||
// These tests assume workspaces have already been created in the SWB environment | ||
// TODO: Create a new workspace during these tests, and terminate once done (dependent on GALI-1093) | ||
describe('Create AppStream URL', () => { | ||
it('should return AppStream URL SageMaker', async () => { | ||
const envId = '36f22de5-fefb-4f62-8ab4-e99ac4387ad4'; | ||
const connectionId = 'id-0'; | ||
const applicationName = 'Firefox'; | ||
const sagemakerUrlPrefix = 'https://basicnotebookinstance'; | ||
const preAuthStreamingUrl = 'https://appstream2.us-east-1.aws.amazon.com/authenticate?parameters='; | ||
const redirectStreamingUrl = `appstream2.us-east-1.aws.amazon.com/#/streaming/?reference=fleet%2Finitial-stack-1629237287942-ServiceWorkbenchFleet&app=${applicationName}`; | ||
|
||
const retVal = await adminSession.resources.workspaceServiceCatalogs | ||
SanketD92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.workspaceServiceCatalog(envId) | ||
.connections() | ||
.connection(connectionId) | ||
.createUrl(); | ||
|
||
const response = await fetch(retVal.url); | ||
const redirectResponse = response[Object.getOwnPropertySymbols(response)[1]]; | ||
SanketD92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
expect(retVal.appstreamDestinationUrl).toContain(sagemakerUrlPrefix); | ||
expect(retVal.id).toEqual(connectionId); | ||
expect(retVal.url).toContain(preAuthStreamingUrl); | ||
expect(redirectResponse.url).toContain(redirectStreamingUrl); | ||
}); | ||
|
||
// Simplify repetitive Jest test cases with it.each here | ||
const testContexts = [ | ||
[ | ||
'Windows', | ||
{ | ||
envId: '5360d995-fa4b-44eb-b67d-a0586886e1a3', | ||
connectionId: 'id-1', | ||
applicationName: 'MicrosoftRemoteDesktop', | ||
preAuthStreamingUrl: 'https://appstream2.us-east-1.aws.amazon.com/authenticate?parameters=', | ||
redirectStreamingUrl: | ||
'appstream2.us-east-1.aws.amazon.com/#/streaming/?reference=fleet%2Finitial-stack-1629237287942-ServiceWorkbenchFleet&app=', | ||
expected: { scheme: 'rdp', name: 'RDP to EC2 Windows Instance' }, | ||
}, | ||
], | ||
[ | ||
'EC2 Linux', | ||
{ | ||
envId: '4ceb23c8-c80c-4ded-b948-c63b21ba5c72', | ||
connectionId: 'id-1', | ||
applicationName: 'EC2Linux', | ||
preAuthStreamingUrl: 'https://appstream2.us-east-1.aws.amazon.com/authenticate?parameters=', | ||
redirectStreamingUrl: | ||
'appstream2.us-east-1.aws.amazon.com/#/streaming/?reference=fleet%2Finitial-stack-1629237287942-ServiceWorkbenchFleet&app=', | ||
expected: { scheme: 'ssh', name: 'SSH to Main EC2 instance' }, | ||
}, | ||
], | ||
]; | ||
|
||
it.each(testContexts)('should return AppStream URL %s', async (_, testContext) => { | ||
SanketD92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const retVal = await adminSession.resources.workspaceServiceCatalogs | ||
.workspaceServiceCatalog(testContext.envId) | ||
.connections() | ||
.connection(testContext.connectionId) | ||
.createUrl(); | ||
|
||
const response = await fetch(retVal.url); | ||
const redirectResponse = response[Object.getOwnPropertySymbols(response)[1]]; | ||
|
||
expect(retVal.scheme).toContain(testContext.expected.scheme); | ||
SanketD92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect(retVal.name).toContain(testContext.expected.name); | ||
expect(retVal.id).toEqual(testContext.connectionId); | ||
expect(retVal.url).toContain(testContext.preAuthStreamingUrl); | ||
expect(redirectResponse.url).toContain(`${testContext.redirectStreamingUrl}${testContext.applicationName}`); | ||
}); | ||
}); | ||
}); |
This file contains 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.
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.
Not a big deal, but for arrays, JS comes with the
filter
method already. Therefore we don't have to use lodash for this. We don't have to change it for this PR, but for future reference.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
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.
True, but there's a minor performance difference.