OIDC Logout Bug (#14545)

* fixes issue with token auth selected after logging out from oidc or jwt methods

* adds changelog entry

* reverts backendType var name change in auth-form authenticate method
This commit is contained in:
Jordan Reimer
2022-03-18 09:40:17 -06:00
committed by GitHub
parent 3fdb221aa6
commit d8128eaa5a
8 changed files with 121 additions and 77 deletions

View File

@@ -1,6 +1,4 @@
import { run } from '@ember/runloop';
import EmberObject, { computed } from '@ember/object';
import Evented from '@ember/object/evented';
import Service from '@ember/service';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
@@ -12,38 +10,19 @@ import { resolve } from 'rsvp';
import { create } from 'ember-cli-page-object';
import form from '../../pages/components/auth-jwt';
import { ERROR_WINDOW_CLOSED, ERROR_MISSING_PARAMS, ERROR_JWT_LOGIN } from 'vault/components/auth-jwt';
import { fakeWindow, buildMessage } from '../../helpers/oidc-window-stub';
const component = create(form);
const windows = [];
const buildMessage = (opts) => ({
isTrusted: true,
origin: 'https://my-vault.com',
data: {},
...opts,
});
const fakeWindow = EmberObject.extend(Evented, {
init() {
this._super(...arguments);
this.on('close', () => {
this.set('closed', true);
});
windows.push(this);
},
screen: computed(function () {
return {
height: 600,
width: 500,
};
}),
origin: 'https://my-vault.com',
closed: false,
});
fakeWindow.reopen({
init() {
this._super(...arguments);
windows.push(this);
},
open() {
return fakeWindow.create();
},
close() {
windows.forEach((w) => w.trigger('close'));
},
@@ -227,17 +206,7 @@ module('Integration | Component | auth jwt', function (hooks) {
await waitUntil(() => {
return this.openSpy.calledOnce;
});
this.window.trigger(
'message',
buildMessage({
data: {
source: 'oidc-callback',
path: 'foo',
state: 'state',
code: 'code',
},
})
);
this.window.trigger('message', buildMessage());
await settled();
assert.equal(this.selectedAuth, 'token', 'calls onSelectedAuth with token');
assert.equal(this.token, 'token', 'calls onToken with token');
@@ -252,18 +221,7 @@ module('Integration | Component | auth jwt', function (hooks) {
await waitUntil(() => {
return this.openSpy.calledOnce;
});
this.window.trigger(
'message',
buildMessage({
origin: 'http://hackerz.com',
data: {
source: 'oidc-callback',
path: 'foo',
state: 'state',
code: 'code',
},
})
);
this.window.trigger('message', buildMessage({ origin: 'http://hackerz.com' }));
run.cancelTimers();
await settled();
assert.notOk(this.handler.called, 'should not call the submit handler');
@@ -277,18 +235,7 @@ module('Integration | Component | auth jwt', function (hooks) {
await waitUntil(() => {
return this.openSpy.calledOnce;
});
this.window.trigger(
'message',
buildMessage({
isTrusted: false,
data: {
source: 'oidc-callback',
path: 'foo',
state: 'state',
code: 'code',
},
})
);
this.window.trigger('message', buildMessage({ isTrusted: false }));
run.cancelTimers();
await settled();
assert.notOk(this.handler.called, 'should not call the submit handler');