Skip to content

Commit

Permalink
Allow default auth method to be either "other" or auth of the enabled…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Monkeychip authored Jan 27, 2020
1 parent 9de6ed6 commit 2a4125f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion ui/app/controllers/vault/cluster/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 7 additions & 11 deletions ui/tests/acceptance/auth-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions ui/tests/acceptance/redirect-to-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,15 +56,15 @@ 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) {
let url = '/vault/secrets/secret/create?initialKey=hello';
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();
Expand Down

0 comments on commit 2a4125f

Please sign in to comment.