diff --git a/ui/app/adapters/cluster.js b/ui/app/adapters/cluster.js index 9b01f3fb1..1ba1a2f6a 100644 --- a/ui/app/adapters/cluster.js +++ b/ui/app/adapters/cluster.js @@ -119,7 +119,7 @@ export default ApplicationAdapter.extend({ options.headers = { 'X-Vault-Token': token, }; - } else if (backend === 'jwt') { + } else if (backend === 'jwt' || backend === 'oidc') { options.data = { role, jwt }; } else { options.data = token ? { token, password } : { password }; @@ -142,6 +142,7 @@ export default ApplicationAdapter.extend({ const authURLs = { github: 'login', jwt: 'login', + oidc: 'login', userpass: `login/${encodeURIComponent(username)}`, ldap: `login/${encodeURIComponent(username)}`, okta: `login/${encodeURIComponent(username)}`, diff --git a/ui/app/components/auth-jwt.js b/ui/app/components/auth-jwt.js index c1596b2d5..829cb8b1f 100644 --- a/ui/app/components/auth-jwt.js +++ b/ui/app/components/auth-jwt.js @@ -156,7 +156,7 @@ export default Component.extend({ let oidcWindow = win.open( this.role.authUrl, 'vaultOIDCWindow', - `width=${POPUP_WIDTH},height=${POPUP_HEIGHT}resizable,scrollbars=yes,top=${top},left=${left}` + `width=${POPUP_WIDTH},height=${POPUP_HEIGHT},resizable,scrollbars=yes,top=${top},left=${left}` ); this.prepareForOIDC.perform(oidcWindow); diff --git a/ui/tests/acceptance/auth-test.js b/ui/tests/acceptance/auth-test.js index d7dc6380d..9f53937e8 100644 --- a/ui/tests/acceptance/auth-test.js +++ b/ui/tests/acceptance/auth-test.js @@ -64,7 +64,7 @@ module('Acceptance | auth', function(hooks) { if (backend.type === 'github') { await component.token('token'); } - if (backend.type === 'jwt') { + if (backend.type === 'jwt' || backend.type === 'oidc') { await jwtComponent.jwt('1'); await jwtComponent.role('test'); } @@ -78,7 +78,7 @@ module('Acceptance | auth', function(hooks) { ); } else if (backend.type === 'github') { assert.ok(Object.keys(body).includes('token'), 'GitHub includes token'); - } else if (backend.type === 'jwt') { + } else if (backend.type === 'jwt' || backend.type === 'oidc') { assert.ok(Object.keys(body).includes('jwt'), `${backend.type} includes jwt`); assert.ok(Object.keys(body).includes('role'), `${backend.type} includes role`); } else { diff --git a/ui/tests/integration/components/auth-jwt-test.js b/ui/tests/integration/components/auth-jwt-test.js index 3e006e456..2bacd4f27 100644 --- a/ui/tests/integration/components/auth-jwt-test.js +++ b/ui/tests/integration/components/auth-jwt-test.js @@ -1,7 +1,6 @@ -import { next, later, run } from '@ember/runloop'; +import { later, run } from '@ember/runloop'; import EmberObject, { computed } from '@ember/object'; import Evented from '@ember/object/evented'; -import { resolve } from 'rsvp'; import Service from '@ember/service'; import { module, test } from 'qunit'; import { setupRenderingTest } from 'ember-qunit'; @@ -89,7 +88,7 @@ module('Integration | Component | auth jwt', function(hooks) { hooks.beforeEach(function() { this.owner.register('service:router', routerStub); this.server = new Pretender(function() { - this.get('/v1/auth/:path/oidc/callback', request => { + this.get('/v1/auth/:path/oidc/callback', function() { return [200, { 'Content-Type': 'application/json' }, JSON.stringify(OIDC_AUTH_RESPONSE)]; }); this.post('/v1/auth/:path/oidc/auth_url', request => { @@ -169,8 +168,9 @@ module('Integration | Component | auth jwt', function(hooks) { await component.role('test'); component.login(); - next(() => { + later(async () => { run.cancelTimers(); + await settled(); let call = this.window.open.getCall(0); assert.deepEqual( call.args, @@ -181,7 +181,8 @@ module('Integration | Component | auth jwt', function(hooks) { ], 'called with expected args' ); - }); + }, 50); + await settled(); }); test('oidc: it calls error handler when popup is closed', async function(assert) { @@ -190,11 +191,12 @@ module('Integration | Component | auth jwt', function(hooks) { await component.role('test'); component.login(); - next(async () => { + later(async () => { this.window.close(); await settled(); assert.equal(this.error, ERROR_WINDOW_CLOSED, 'calls onError with error string'); - }); + }, 50); + await settled(); }); test('oidc: storage event fires with wrong key', async function(assert) { @@ -202,11 +204,12 @@ module('Integration | Component | auth jwt', function(hooks) { this.set('selectedAuthPath', 'foo'); await component.role('test'); component.login(); - next(async () => { + later(async () => { run.cancelTimers(); this.window.trigger('storage', { key: 'wrongThing' }); - assert.equal(this.window.localStorage.removeItem.callCount, 0, 'never callse removeItem'); - }); + assert.equal(this.window.localStorage.removeItem.callCount, 0, 'never calls removeItem'); + }, 50); + await settled(); }); test('oidc: storage event fires with correct key, wrong params', async function(assert) { @@ -214,13 +217,13 @@ module('Integration | Component | auth jwt', function(hooks) { this.set('selectedAuthPath', 'foo'); await component.role('test'); component.login(); - // need next tick here to let ec tasks set up - next(async () => { + later(async () => { this.window.trigger('storage', { key: 'oidcState', newValue: JSON.stringify({}) }); await settled(); assert.equal(this.window.localStorage.removeItem.callCount, 1, 'calls removeItem'); assert.equal(this.error, ERROR_MISSING_PARAMS, 'calls onError with params missing error'); - }); + }, 50); + await settled(); }); test('oidc: storage event fires with correct key, correct params', async function(assert) { @@ -228,8 +231,7 @@ module('Integration | Component | auth jwt', function(hooks) { this.set('selectedAuthPath', 'foo'); await component.role('test'); component.login(); - // need next tick here to let ec tasks set up - next(async () => { + later(async () => { this.window.trigger('storage', { key: 'oidcState', newValue: JSON.stringify({ @@ -242,6 +244,7 @@ module('Integration | Component | auth jwt', function(hooks) { assert.equal(this.selectedAuth, 'token', 'calls onSelectedAuth with token'); assert.equal(this.token, 'token', 'calls onToken with token'); assert.ok(this.handler.calledOnce, 'calls the onSubmit handler'); - }); + }, 50); + await settled(); }); });