-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
8 changed files
with
119 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Fixes issue with correct auth method not selected when logging out from OIDC or JWT methods | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { click, visit, fillIn, settled } from '@ember/test-helpers'; | ||
import { setupMirage } from 'ember-cli-mirage/test-support'; | ||
import { fakeWindow, buildMessage } from '../helpers/oidc-window-stub'; | ||
import sinon from 'sinon'; | ||
import { later, run } from '@ember/runloop'; | ||
|
||
module('Acceptance | logout auth method', function (hooks) { | ||
setupApplicationTest(hooks); | ||
setupMirage(hooks); | ||
|
||
hooks.beforeEach(function () { | ||
this.openStub = sinon.stub(window, 'open').callsFake(() => fakeWindow.create()); | ||
}); | ||
hooks.afterEach(function () { | ||
this.openStub.restore(); | ||
}); | ||
|
||
// coverage for bug where token was selected as auth method for oidc and jwt | ||
test('it should populate oidc auth method on logout', async function (assert) { | ||
this.server.post('/auth/oidc/oidc/auth_url', () => ({ | ||
data: { auth_url: 'http://example.com' }, | ||
})); | ||
this.server.get('/auth/foo/oidc/callback', () => ({ | ||
auth: { client_token: 'root' }, | ||
})); | ||
// ensure clean state | ||
sessionStorage.removeItem('selectedAuth'); | ||
await visit('/vault/auth'); | ||
await fillIn('[data-test-select="auth-method"]', 'oidc'); | ||
later(() => run.cancelTimers(), 50); | ||
await click('[data-test-auth-submit]'); | ||
window.postMessage(buildMessage().data, window.origin); | ||
await settled(); | ||
await click('.nav-user-button button'); | ||
await click('#logout'); | ||
assert | ||
.dom('[data-test-select="auth-method"]') | ||
.hasValue('oidc', 'Previous auth method selected on logout'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import EmberObject, { computed } from '@ember/object'; | ||
import Evented from '@ember/object/evented'; | ||
|
||
export const fakeWindow = EmberObject.extend(Evented, { | ||
init() { | ||
this._super(...arguments); | ||
this.on('close', () => { | ||
this.set('closed', true); | ||
}); | ||
}, | ||
screen: computed(function () { | ||
return { | ||
height: 600, | ||
width: 500, | ||
}; | ||
}), | ||
origin: 'https://my-vault.com', | ||
closed: false, | ||
open() {}, | ||
close() {}, | ||
}); | ||
|
||
export const buildMessage = (opts) => ({ | ||
isTrusted: true, | ||
origin: 'https://my-vault.com', | ||
data: { | ||
source: 'oidc-callback', | ||
path: 'foo', | ||
state: 'state', | ||
code: 'code', | ||
}, | ||
...opts, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters