Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Remove all tokens associated with a cnsi on unregister, also fix e2e #2821

Merged
merged 23 commits into from
Aug 20, 2018

Conversation

richard-cox
Copy link
Contributor

@richard-cox richard-cox commented Aug 10, 2018

  • Fixes v2-master e2e
  • e2e tests were failing after endpoint guid --> url hash change
    • when an endpoint was disconnected only the tokens associated with itself and the requesting user were deleted
    • previously this wasn't an issue, as registering the same endpoint resulted in a different guid and any tokens left in the db were not used
    • with the guid --> url hash change re-registering the same endpoint results in the old tokens being used
    • this broke e2e tests that expected every user to have to connect after all endpoints were unregistered
    • not sure if there's any clean up of the tokens table over time, so for that reason and security we now remove all tokens associated with an unregistered endpoint
  • other e2e fixes make tests more robust

- e2e tests were failing after endpoint guid --> url hash change
  - when an endpoint was disconnected only the tokens associated with itself and the requesting user were deleted
  - previously this wasn't an issue, as registering the same endpoint resulted in a different guid and any tokens left in the db were not used
  - with the guid --> url hash change re-registering the same endpoint results in the old tokens being used
  - this broke e2e tests that expected every user to have to connect after all endpoints were unregistered
  - not sure if there's any clean up of the tokens table over time, so for that reason and security we now remove all tokens associated with an unregistered endpoint
- other e2e fixes make tests more robust
@cfdreddbot
Copy link

Hey richard-cox!

Thanks for submitting this pull request! I'm here to inform the recipients of the pull request that you and the commit authors have already signed the CLA.

@codecov
Copy link

codecov bot commented Aug 10, 2018

Codecov Report

Merging #2821 into v2-master will decrease coverage by <.01%.
The diff coverage is 62.5%.

@@              Coverage Diff              @@
##           v2-master    #2821      +/-   ##
=============================================
- Coverage       71.3%   71.29%   -0.01%     
=============================================
  Files            604      604              
  Lines          25844    25846       +2     
  Branches        5854     5854              
=============================================
+ Hits           18427    18428       +1     
- Misses          7417     7418       +1

Copy link
Contributor

@nwmac nwmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about browser.sleep

@@ -20,6 +22,8 @@ describe('Endpoints', () => {
describe('Connect/Disconnect endpoints -', () => {

beforeAll(() => {
// Ran independently these tests are fine. However stacked with other spec files they'll fail without a pause
browser.sleep(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of using sleep unless we know why we're doing it... if we're waiting for something to load, complete or appear, I'd prefer to explicitly wait on that

- Needed before, ran several times now without and not needed
- Stale = type=cnsi and no corresponding endpoint
- if user can only see one cf, org and space the create app cf/org/space selections will be autopopulated
- this means the `next` but is enabled on enter
- (test) the incorrect space was fetched if there were multiple with same name
- (test) on delete app it's route would not be deleted due to the app entity having an empty routes array
- Beefed up check for space in application service
- Refactor fetchSpace, fetchApp and deleteApp, ensure all work within a specific space
- Refactor delete app, ensure it works efficiently in all scenarios
- Still an issue - CF is not reporting an app's routes promtly
- TODO: console.logs, remove sleep if possible, fdescribes
@@ -20,6 +22,7 @@ export class ApplicationSummary extends Page {
expect(urlParts[3]).toBe('summary');
const cfGuid = urlParts[1];
const appGuid = urlParts[2];
e2e.log(`Creating App Summary object using cfGuid: '${cfGuid}' and appGuid: '${appGuid}'`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

return json.total_results;
});
}

createApp(cnsiGuid: string, spaceGuid: string, appName: string) {
// For fully fleshed out fetch see application-e2e-helpers
baseFetchApp(cnsiGuid: string, spaceGuid: string, appName: string) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wrong, these are used externally. Have updated name to better reflect type of method


sendCfPost = (cfGuid: string, url: string, body: any): promise.Promise<CFResponse> =>
this.sendCfRequest(cfGuid, url, 'POST', body).then(JSON.parse)

sendCfPut = (cfGuid: string, url: string, body?: any): promise.Promise<CFResponse> =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add typing. group 3 http request methods

Copy link
Contributor

@nwmac nwmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor

This matches jasmine's defaultTimeoutInterval of 30000

Docs for allScriptsTimeout
  * The timeout in milliseconds for each script run on the browser. This
  * should be longer than the maximum time your application needs to
  * stabilize between tasks.
Copy link
Contributor

@nwmac nwmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nwmac nwmac merged commit 771d88f into v2-master Aug 20, 2018
@nwmac nwmac deleted the e2e-fix-and-clear-token-on-unregister branch August 20, 2018 13:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants