Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow default auth method to be either "other" or auth of the enabled listing-visibility unauth #8218

Merged
merged 13 commits into from
Jan 27, 2020
Merged
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
14 changes: 3 additions & 11 deletions ui/tests/acceptance/auth-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,16 @@ 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 $`);
Monkeychip marked this conversation as resolved.
Show resolved Hide resolved
}
});

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