Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
acceptance tests for redirect
Browse files Browse the repository at this point in the history
meirish committed Jul 11, 2019
1 parent f70426d commit 76e4092
Showing 2 changed files with 26 additions and 10 deletions.
10 changes: 0 additions & 10 deletions ui/app/mixins/cluster-route.js
Original file line number Diff line number Diff line change
@@ -26,16 +26,6 @@ export default Mixin.create({
targetRoute !== transition.targetName &&
targetRoute !== this.router.currentRouteName
) {
console.log(
'routeName: ',
this.routeName,
' targetName: ',
transition.targetName,
' targetRoute: ',
targetRoute,
' currentRouteName: ',
this.router.currentRouteName
);
if (
// only want to redirect if we're going to authenticate
targetRoute === AUTH &&
26 changes: 26 additions & 0 deletions ui/tests/acceptance/redirect-to-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { currentURL, visit } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import authPage from 'vault/tests/pages/auth';

module('Acceptance | redirect_to functionality', function(hooks) {
setupApplicationTest(hooks);

test('redirect to a route after authentication', async function(assert) {
let url = '/vault/secrets/secret/create';
await visit(url);
assert.equal(
currentURL(),
`/vault/auth?redirect_to=${encodeURIComponent(url)}&with=token`,
'encodes url for the query param'
);
await authPage.tokenInput('root').submit();
assert.equal(currentURL(), url, 'navigates to the redirect_to url after auth');
});

test('redirect from root does not include redirect_to', async function(assert) {
let url = '/';
await visit(url);
assert.equal(currentURL(), `/vault/auth?with=token`, 'there is no redirect_to query param');
});
});

0 comments on commit 76e4092

Please sign in to comment.