vault/ui/tests/helpers/oidc-window-stub.js
claire bontempo 784d8ff581
UI: Glimmerize AuthJwt (#30130)
* glimmerize auth-jwt

* update asserton count

* update jwt acceptance test

* simplify stubbed popup

* remove references to this.window

* remove waitFor, will add back if necessary

* wip tests

* finish auth-jwt integration tests

* finish acceptance tests

* temp skip unit tests

* Revert "temp skip unit tests"

This reverts commit 24ed7c9de8f37a597ef1be28b0f3856278b041bb.

* temp skip unit tests

* remove loading management in parent

* polish integration tests, add final acceptance test, revert while loops

* refactor window helper and address small component cleanup items
2025-04-02 17:10:49 -07:00

33 lines
814 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import sinon from 'sinon';
// suggestions for a custom popup
// passing { close: true } automatically closes popups opened from window.open()
// passing { closed: true } sets value on popup window
export const windowStub = ({ stub, popup } = {}) => {
// if already stubbed, don't re-stub
const openStub = stub ? stub : sinon.stub(window, 'open');
const defaultPopup = { close: () => true };
openStub.returns(popup || defaultPopup);
return openStub;
};
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,
});