From 93d0eba072ccda5ae93893a24eb8c3331ad937c6 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Mon, 27 Jan 2020 09:41:44 -0700 Subject: [PATCH] Allow default auth method to be either "other" or auth of the enabled listing-visibility unauth (#8218) * remove default for authMethod as it's preventing the other auth methods from being selected as default when they are marked as List method when unauthenticated. * fix test * fix test * fix typo * fix missed query params * fix missing backend.type, and adjust formatting per prettier requirements --- ui/app/controllers/vault/cluster/auth.js | 2 +- ui/tests/acceptance/auth-test.js | 18 +++++++----------- ui/tests/acceptance/redirect-to-test.js | 6 +++--- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/ui/app/controllers/vault/cluster/auth.js b/ui/app/controllers/vault/cluster/auth.js index e4f1f7b115e4..8733761393e5 100644 --- a/ui/app/controllers/vault/cluster/auth.js +++ b/ui/app/controllers/vault/cluster/auth.js @@ -10,7 +10,7 @@ export default Controller.extend({ namespaceQueryParam: alias('clusterController.namespaceQueryParam'), queryParams: [{ authMethod: 'with' }], wrappedToken: alias('vaultController.wrappedToken'), - authMethod: 'token', + authMethod: '', redirectTo: alias('vaultController.redirectTo'), updateNamespace: task(function*(value) { diff --git a/ui/tests/acceptance/auth-test.js b/ui/tests/acceptance/auth-test.js index 81ef6a171d02..e6d0a0b88e4b 100644 --- a/ui/tests/acceptance/auth-test.js +++ b/ui/tests/acceptance/auth-test.js @@ -37,24 +37,20 @@ module('Acceptance | auth', function(hooks) { let backends = supportedAuthBackends(); assert.expect(backends.length + 1); await visit('/vault/auth'); - assert.equal(currentURL(), '/vault/auth'); + assert.equal(currentURL(), '/vault/auth?with=token'); for (let backend of backends.reverse()) { await component.selectMethod(backend.type); - if (backend.type === 'token') { - assert.equal(currentURL(), `/vault/auth`, `has the correct URL for ${backend.type}`); - } else { - assert.equal( - currentURL(), - `/vault/auth?with=${backend.type}`, - `has the correct URL for ${backend.type}` - ); - } + assert.equal( + currentURL(), + `/vault/auth?with=${backend.type}`, + `has the correct URL for ${backend.type}` + ); } }); test('it clears token when changing selected auth method', async function(assert) { await visit('/vault/auth'); - assert.equal(currentURL(), '/vault/auth'); + assert.equal(currentURL(), '/vault/auth?with=token'); await component.token('token').selectMethod('github'); await component.selectMethod('token'); assert.equal(component.tokenValue, '', 'it clears the token value when toggling methods'); diff --git a/ui/tests/acceptance/redirect-to-test.js b/ui/tests/acceptance/redirect-to-test.js index b25e4b65c1b4..70bdf049903e 100644 --- a/ui/tests/acceptance/redirect-to-test.js +++ b/ui/tests/acceptance/redirect-to-test.js @@ -45,7 +45,7 @@ module('Acceptance | redirect_to query param functionality', function(hooks) { await visit(url); assert.equal( currentURL(), - `/vault/auth?redirect_to=${encodeURIComponent(url)}`, + `/vault/auth?redirect_to=${encodeURIComponent(url)}&with=token`, 'encodes url for the query param' ); // the login method on this page does another visit call that we don't want here @@ -56,7 +56,7 @@ module('Acceptance | redirect_to query param functionality', function(hooks) { test('redirect from root does not include redirect_to', async function(assert) { let url = '/'; await visit(url); - assert.equal(currentURL(), `/vault/auth`, 'there is no redirect_to query param'); + assert.equal(currentURL(), `/vault/auth?with=token`, 'there is no redirect_to query param'); }); test('redirect to a route after authentication with a query param', async function(assert) { @@ -64,7 +64,7 @@ module('Acceptance | redirect_to query param functionality', function(hooks) { await visit(url); assert.equal( currentURL(), - `/vault/auth?redirect_to=${encodeURIComponent(url)}`, + `/vault/auth?redirect_to=${encodeURIComponent(url)}&with=token`, 'encodes url for the query param' ); await auth.tokenInput('root').submit();