mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-24 16:11:08 +02:00
* rename page test to login form * add username/password tests to auth page test * add github and generalize tests * finish standard auth types for page test * add tests for onNamespaceInput * fix accessibility violation * add oidc provider qp test * move helper into test * move destructured arg * address oidc auth method flakiness...maybe? * cleanup unused fake window methods * add comment why... * fix diff * fix header * finish mfa acceptance tests move mfa selectors to folder
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
import EmberObject from '@ember/object';
|
|
import Evented from '@ember/object/evented';
|
|
|
|
export class WindowStub extends EventTarget {
|
|
close() {
|
|
this.dispatchEvent(new CustomEvent('close')); // Trigger 'close' event using CustomEvent
|
|
}
|
|
}
|
|
|
|
// using Evented is deprecated, but it's the only way we can trigger a message that is trusted
|
|
// by calling window.trigger. Using dispatchEvent will always result in an untrusted event.
|
|
export const fakeWindow = EmberObject.extend(Evented, {
|
|
init() {
|
|
this._super(...arguments);
|
|
this.on('close', () => {
|
|
this.set('closed', true);
|
|
});
|
|
},
|
|
get screen() {
|
|
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: callbackData(),
|
|
...opts,
|
|
});
|
|
|
|
export const callbackData = (data = {}) => ({
|
|
source: 'oidc-callback',
|
|
path: 'foo',
|
|
state: 'state',
|
|
code: 'code',
|
|
...data,
|
|
});
|