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
This commit is contained in:
Angel Garbarino 2020-01-27 09:41:44 -07:00 committed by GitHub
parent eea26c6af1
commit 41fd74cebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 15 deletions

View file

@ -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) {

View file

@ -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');

View file

@ -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();