From 76e4092ed72cf0ee514ab7750495dda1dfe37cf1 Mon Sep 17 00:00:00 2001 From: Matthew Irish Date: Wed, 10 Jul 2019 22:07:33 -0500 Subject: [PATCH] acceptance tests for redirect --- ui/app/mixins/cluster-route.js | 10 ---------- ui/tests/acceptance/redirect-to-test.js | 26 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 ui/tests/acceptance/redirect-to-test.js diff --git a/ui/app/mixins/cluster-route.js b/ui/app/mixins/cluster-route.js index 3daa5099ce46..7ed1860728fc 100644 --- a/ui/app/mixins/cluster-route.js +++ b/ui/app/mixins/cluster-route.js @@ -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 && diff --git a/ui/tests/acceptance/redirect-to-test.js b/ui/tests/acceptance/redirect-to-test.js new file mode 100644 index 000000000000..654f2320c000 --- /dev/null +++ b/ui/tests/acceptance/redirect-to-test.js @@ -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'); + }); +});