2019-05-03 03:20:28 +00:00
|
|
|
import { run } from '@ember/runloop';
|
2019-02-14 15:39:19 +00:00
|
|
|
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';
|
2019-05-03 03:20:28 +00:00
|
|
|
import { render, settled, waitUntil } from '@ember/test-helpers';
|
2019-02-14 15:39:19 +00:00
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import Pretender from 'pretender';
|
2019-05-03 03:20:28 +00:00
|
|
|
import { resolve } from 'rsvp';
|
2019-02-14 15:39:19 +00:00
|
|
|
import { create } from 'ember-cli-page-object';
|
|
|
|
import form from '../../pages/components/auth-jwt';
|
2020-05-08 23:00:28 +00:00
|
|
|
import { ERROR_WINDOW_CLOSED, ERROR_MISSING_PARAMS, ERROR_JWT_LOGIN } from 'vault/components/auth-jwt';
|
2019-02-14 15:39:19 +00:00
|
|
|
|
|
|
|
const component = create(form);
|
Update ui dependencies (#7244)
* be more specific about node version, and specify a yarn version
* update ember, ember-cli, ember-data, ember-data-model-fragments
* use router handlers to access transition information
* fix shadowing of component helper
* update ivy-codemirror, ember-cli-inject-live-reload
* remove custom router service
* don't use transition.queryParams
* update ember-cli-deprecation-workflow
* refactor kv v1 to use 'path' instead of 'id' on creation
* fix auth-jwt-test and toolbar-link-test
* update ember composable helpers
* remove Ember.copy from test file
* no more deprecations in the workflow
* fix more secret tests
* fix remaining failed tests
* move select component to core because it's used by ttl-picker
* generate new model class for each test instead of reusing an existing one
* fix selectors on kmip tests
* refactor how control groups construct urls from the new transition objects
* add router service override back in, and have it be evented so that we can trigger router events on it
* move stories and markdown files to core if the component lives in core
* update ember-cli, ember-cli-babel, ember-auto-import
* update base64js, date-fns, deepmerge, codemirror, broccoli-asset-rev
* update linting rules
* fix test selectors
* update ember-api-actions, ember-concurrency, ember-load-initializers, escape-string-regexp, normalize.css, prettier-eslint-cli, jsdoc-to-markdown
* remove test-results dir
* update base64js, ember-cli-clipboard, ember-cli-sass, ember-cli-string-helpers, ember-cli-template-lint, ember-cli-uglify, ember-link-action
* fix linting
* run yarn install without restoring from cache
* refactor how tests are run and handle the vault server subprocess
* update makefile for new test task names
* update circle config to use the new yarn task
* fix writing the seal keys when starting the dev server
* remove optional deps from the lockfile
* don't ignore-optional on yarn install
* remove errant console.log
* update ember-basic-dropdown-hover, jsonlint, yargs-parser
* update ember-cli-flash
* add back optionalDeps
* update @babel/core@7.5.5, ember-basic-dropdown@1.1.3, eslint-plugin-ember@6.8.2
* update storybook to the latest release
* add a babel config with targets so that the ember babel plugin works properly
* update ember-resolver, move ember-cli-storybook to devDependencies
* revert normalize.css upgrade
* silence fetchadapter warning for now
* exclude 3rd party array helper now that ember includes one
* fix switch and entity lookup styling
* only add -root suffix if it's not in versions mode
* make sure drop always has an array on the aws role form
* fix labels like we did with the backport
* update eslintignore
* update the yarn version in the docker build file
* update eslint ignore
2019-08-19 20:45:39 +00:00
|
|
|
const windows = [];
|
2021-06-17 20:56:04 +00:00
|
|
|
const buildMessage = opts => ({
|
|
|
|
isTrusted: true,
|
|
|
|
origin: 'https://my-vault.com',
|
|
|
|
data: {},
|
|
|
|
...opts,
|
|
|
|
});
|
2019-02-14 15:39:19 +00:00
|
|
|
const fakeWindow = EmberObject.extend(Evented, {
|
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
Update ui dependencies (#7244)
* be more specific about node version, and specify a yarn version
* update ember, ember-cli, ember-data, ember-data-model-fragments
* use router handlers to access transition information
* fix shadowing of component helper
* update ivy-codemirror, ember-cli-inject-live-reload
* remove custom router service
* don't use transition.queryParams
* update ember-cli-deprecation-workflow
* refactor kv v1 to use 'path' instead of 'id' on creation
* fix auth-jwt-test and toolbar-link-test
* update ember composable helpers
* remove Ember.copy from test file
* no more deprecations in the workflow
* fix more secret tests
* fix remaining failed tests
* move select component to core because it's used by ttl-picker
* generate new model class for each test instead of reusing an existing one
* fix selectors on kmip tests
* refactor how control groups construct urls from the new transition objects
* add router service override back in, and have it be evented so that we can trigger router events on it
* move stories and markdown files to core if the component lives in core
* update ember-cli, ember-cli-babel, ember-auto-import
* update base64js, date-fns, deepmerge, codemirror, broccoli-asset-rev
* update linting rules
* fix test selectors
* update ember-api-actions, ember-concurrency, ember-load-initializers, escape-string-regexp, normalize.css, prettier-eslint-cli, jsdoc-to-markdown
* remove test-results dir
* update base64js, ember-cli-clipboard, ember-cli-sass, ember-cli-string-helpers, ember-cli-template-lint, ember-cli-uglify, ember-link-action
* fix linting
* run yarn install without restoring from cache
* refactor how tests are run and handle the vault server subprocess
* update makefile for new test task names
* update circle config to use the new yarn task
* fix writing the seal keys when starting the dev server
* remove optional deps from the lockfile
* don't ignore-optional on yarn install
* remove errant console.log
* update ember-basic-dropdown-hover, jsonlint, yargs-parser
* update ember-cli-flash
* add back optionalDeps
* update @babel/core@7.5.5, ember-basic-dropdown@1.1.3, eslint-plugin-ember@6.8.2
* update storybook to the latest release
* add a babel config with targets so that the ember babel plugin works properly
* update ember-resolver, move ember-cli-storybook to devDependencies
* revert normalize.css upgrade
* silence fetchadapter warning for now
* exclude 3rd party array helper now that ember includes one
* fix switch and entity lookup styling
* only add -root suffix if it's not in versions mode
* make sure drop always has an array on the aws role form
* fix labels like we did with the backport
* update eslintignore
* update the yarn version in the docker build file
* update eslint ignore
2019-08-19 20:45:39 +00:00
|
|
|
this.on('close', () => {
|
2019-02-14 15:39:19 +00:00
|
|
|
this.set('closed', true);
|
|
|
|
});
|
Update ui dependencies (#7244)
* be more specific about node version, and specify a yarn version
* update ember, ember-cli, ember-data, ember-data-model-fragments
* use router handlers to access transition information
* fix shadowing of component helper
* update ivy-codemirror, ember-cli-inject-live-reload
* remove custom router service
* don't use transition.queryParams
* update ember-cli-deprecation-workflow
* refactor kv v1 to use 'path' instead of 'id' on creation
* fix auth-jwt-test and toolbar-link-test
* update ember composable helpers
* remove Ember.copy from test file
* no more deprecations in the workflow
* fix more secret tests
* fix remaining failed tests
* move select component to core because it's used by ttl-picker
* generate new model class for each test instead of reusing an existing one
* fix selectors on kmip tests
* refactor how control groups construct urls from the new transition objects
* add router service override back in, and have it be evented so that we can trigger router events on it
* move stories and markdown files to core if the component lives in core
* update ember-cli, ember-cli-babel, ember-auto-import
* update base64js, date-fns, deepmerge, codemirror, broccoli-asset-rev
* update linting rules
* fix test selectors
* update ember-api-actions, ember-concurrency, ember-load-initializers, escape-string-regexp, normalize.css, prettier-eslint-cli, jsdoc-to-markdown
* remove test-results dir
* update base64js, ember-cli-clipboard, ember-cli-sass, ember-cli-string-helpers, ember-cli-template-lint, ember-cli-uglify, ember-link-action
* fix linting
* run yarn install without restoring from cache
* refactor how tests are run and handle the vault server subprocess
* update makefile for new test task names
* update circle config to use the new yarn task
* fix writing the seal keys when starting the dev server
* remove optional deps from the lockfile
* don't ignore-optional on yarn install
* remove errant console.log
* update ember-basic-dropdown-hover, jsonlint, yargs-parser
* update ember-cli-flash
* add back optionalDeps
* update @babel/core@7.5.5, ember-basic-dropdown@1.1.3, eslint-plugin-ember@6.8.2
* update storybook to the latest release
* add a babel config with targets so that the ember babel plugin works properly
* update ember-resolver, move ember-cli-storybook to devDependencies
* revert normalize.css upgrade
* silence fetchadapter warning for now
* exclude 3rd party array helper now that ember includes one
* fix switch and entity lookup styling
* only add -root suffix if it's not in versions mode
* make sure drop always has an array on the aws role form
* fix labels like we did with the backport
* update eslintignore
* update the yarn version in the docker build file
* update eslint ignore
2019-08-19 20:45:39 +00:00
|
|
|
windows.push(this);
|
2019-02-14 15:39:19 +00:00
|
|
|
},
|
|
|
|
screen: computed(function() {
|
|
|
|
return {
|
|
|
|
height: 600,
|
|
|
|
width: 500,
|
|
|
|
};
|
|
|
|
}),
|
2021-06-17 20:56:04 +00:00
|
|
|
origin: 'https://my-vault.com',
|
2019-02-14 15:39:19 +00:00
|
|
|
closed: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
fakeWindow.reopen({
|
|
|
|
open() {
|
|
|
|
return fakeWindow.create();
|
|
|
|
},
|
|
|
|
|
|
|
|
close() {
|
Update ui dependencies (#7244)
* be more specific about node version, and specify a yarn version
* update ember, ember-cli, ember-data, ember-data-model-fragments
* use router handlers to access transition information
* fix shadowing of component helper
* update ivy-codemirror, ember-cli-inject-live-reload
* remove custom router service
* don't use transition.queryParams
* update ember-cli-deprecation-workflow
* refactor kv v1 to use 'path' instead of 'id' on creation
* fix auth-jwt-test and toolbar-link-test
* update ember composable helpers
* remove Ember.copy from test file
* no more deprecations in the workflow
* fix more secret tests
* fix remaining failed tests
* move select component to core because it's used by ttl-picker
* generate new model class for each test instead of reusing an existing one
* fix selectors on kmip tests
* refactor how control groups construct urls from the new transition objects
* add router service override back in, and have it be evented so that we can trigger router events on it
* move stories and markdown files to core if the component lives in core
* update ember-cli, ember-cli-babel, ember-auto-import
* update base64js, date-fns, deepmerge, codemirror, broccoli-asset-rev
* update linting rules
* fix test selectors
* update ember-api-actions, ember-concurrency, ember-load-initializers, escape-string-regexp, normalize.css, prettier-eslint-cli, jsdoc-to-markdown
* remove test-results dir
* update base64js, ember-cli-clipboard, ember-cli-sass, ember-cli-string-helpers, ember-cli-template-lint, ember-cli-uglify, ember-link-action
* fix linting
* run yarn install without restoring from cache
* refactor how tests are run and handle the vault server subprocess
* update makefile for new test task names
* update circle config to use the new yarn task
* fix writing the seal keys when starting the dev server
* remove optional deps from the lockfile
* don't ignore-optional on yarn install
* remove errant console.log
* update ember-basic-dropdown-hover, jsonlint, yargs-parser
* update ember-cli-flash
* add back optionalDeps
* update @babel/core@7.5.5, ember-basic-dropdown@1.1.3, eslint-plugin-ember@6.8.2
* update storybook to the latest release
* add a babel config with targets so that the ember babel plugin works properly
* update ember-resolver, move ember-cli-storybook to devDependencies
* revert normalize.css upgrade
* silence fetchadapter warning for now
* exclude 3rd party array helper now that ember includes one
* fix switch and entity lookup styling
* only add -root suffix if it's not in versions mode
* make sure drop always has an array on the aws role form
* fix labels like we did with the backport
* update eslintignore
* update the yarn version in the docker build file
* update eslint ignore
2019-08-19 20:45:39 +00:00
|
|
|
windows.forEach(w => w.trigger('close'));
|
2019-02-14 15:39:19 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const OIDC_AUTH_RESPONSE = {
|
|
|
|
auth: {
|
|
|
|
client_token: 'token',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const routerStub = Service.extend({
|
|
|
|
urlFor() {
|
|
|
|
return 'http://example.com';
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-03-14 19:26:09 +00:00
|
|
|
const renderIt = async (context, path = 'jwt') => {
|
2019-02-14 15:39:19 +00:00
|
|
|
let handler = (data, e) => {
|
|
|
|
if (e && e.preventDefault) e.preventDefault();
|
2019-05-03 03:20:28 +00:00
|
|
|
return resolve();
|
2019-02-14 15:39:19 +00:00
|
|
|
};
|
|
|
|
let fake = fakeWindow.create();
|
|
|
|
context.set('window', fake);
|
|
|
|
context.set('handler', sinon.spy(handler));
|
|
|
|
context.set('roleName', '');
|
|
|
|
context.set('selectedAuthPath', path);
|
|
|
|
await render(hbs`
|
|
|
|
<AuthJwt
|
|
|
|
@window={{window}}
|
|
|
|
@roleName={{roleName}}
|
|
|
|
@selectedAuthPath={{selectedAuthPath}}
|
|
|
|
@onError={{action (mut error)}}
|
|
|
|
@onLoading={{action (mut isLoading)}}
|
|
|
|
@onToken={{action (mut token)}}
|
|
|
|
@onNamespace={{action (mut namespace)}}
|
|
|
|
@onSelectedAuth={{action (mut selectedAuth)}}
|
|
|
|
@onSubmit={{action handler}}
|
|
|
|
@onRoleName={{action (mut roleName)}}
|
|
|
|
/>
|
|
|
|
`);
|
|
|
|
};
|
|
|
|
module('Integration | Component | auth jwt', function(hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
|
|
|
hooks.beforeEach(function() {
|
2019-05-03 03:20:28 +00:00
|
|
|
this.openSpy = sinon.spy(fakeWindow.proto(), 'open');
|
2019-02-14 15:39:19 +00:00
|
|
|
this.owner.register('service:router', routerStub);
|
|
|
|
this.server = new Pretender(function() {
|
2019-02-21 22:21:23 +00:00
|
|
|
this.get('/v1/auth/:path/oidc/callback', function() {
|
2019-02-14 15:39:19 +00:00
|
|
|
return [200, { 'Content-Type': 'application/json' }, JSON.stringify(OIDC_AUTH_RESPONSE)];
|
|
|
|
});
|
|
|
|
this.post('/v1/auth/:path/oidc/auth_url', request => {
|
|
|
|
let body = JSON.parse(request.requestBody);
|
|
|
|
if (body.role === 'test') {
|
|
|
|
return [
|
|
|
|
200,
|
|
|
|
{ 'Content-Type': 'application/json' },
|
|
|
|
JSON.stringify({
|
|
|
|
data: {
|
|
|
|
auth_url: 'http://example.com',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
if (body.role === 'okta') {
|
|
|
|
return [
|
|
|
|
200,
|
|
|
|
{ 'Content-Type': 'application/json' },
|
|
|
|
JSON.stringify({
|
|
|
|
data: {
|
|
|
|
auth_url: 'http://okta.com',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
];
|
|
|
|
}
|
2020-05-08 23:00:28 +00:00
|
|
|
return [400, { 'Content-Type': 'application/json' }, JSON.stringify({ errors: [ERROR_JWT_LOGIN] })];
|
2019-02-14 15:39:19 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
hooks.afterEach(function() {
|
2019-05-03 03:20:28 +00:00
|
|
|
this.openSpy.restore();
|
2019-02-14 15:39:19 +00:00
|
|
|
this.server.shutdown();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('it renders the yield', async function(assert) {
|
|
|
|
await render(hbs`<AuthJwt @onSubmit={{action (mut submit)}}>Hello!</AuthJwt>`);
|
|
|
|
assert.equal(component.yieldContent, 'Hello!', 'yields properly');
|
|
|
|
});
|
|
|
|
|
2021-06-17 20:56:04 +00:00
|
|
|
test('jwt: it renders and makes auth_url requests', async function(assert) {
|
2019-02-14 15:39:19 +00:00
|
|
|
await renderIt(this);
|
2019-03-14 19:26:09 +00:00
|
|
|
await settled();
|
2019-02-14 15:39:19 +00:00
|
|
|
assert.ok(component.jwtPresent, 'renders jwt field');
|
|
|
|
assert.ok(component.rolePresent, 'renders jwt field');
|
2019-03-14 19:26:09 +00:00
|
|
|
assert.equal(this.server.handledRequests.length, 1, 'request to the default path is made');
|
|
|
|
assert.equal(this.server.handledRequests[0].url, '/v1/auth/jwt/oidc/auth_url');
|
2019-02-14 15:39:19 +00:00
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await settled();
|
2019-03-14 19:26:09 +00:00
|
|
|
assert.equal(this.server.handledRequests.length, 2, 'a second request was made');
|
2019-02-14 15:39:19 +00:00
|
|
|
assert.equal(
|
2019-03-14 19:26:09 +00:00
|
|
|
this.server.handledRequests[1].url,
|
2019-02-14 15:39:19 +00:00
|
|
|
'/v1/auth/foo/oidc/auth_url',
|
|
|
|
'requests when path is set'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('jwt: it calls passed action on login', async function(assert) {
|
|
|
|
await renderIt(this);
|
|
|
|
await component.login();
|
|
|
|
assert.ok(this.handler.calledOnce);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('oidc: test role: it renders', async function(assert) {
|
|
|
|
await renderIt(this);
|
2019-03-14 19:26:09 +00:00
|
|
|
await settled();
|
2019-02-14 15:39:19 +00:00
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await component.role('test');
|
2019-03-14 19:26:09 +00:00
|
|
|
await settled();
|
2019-02-14 15:39:19 +00:00
|
|
|
assert.notOk(component.jwtPresent, 'does not show jwt input for OIDC type login');
|
|
|
|
assert.equal(component.loginButtonText, 'Sign in with OIDC Provider');
|
|
|
|
|
|
|
|
await component.role('okta');
|
|
|
|
// 1 for initial render, 1 for each time role changed = 3
|
2019-03-14 19:26:09 +00:00
|
|
|
assert.equal(this.server.handledRequests.length, 4, 'fetches the auth_url when the path changes');
|
2019-02-14 15:39:19 +00:00
|
|
|
assert.equal(component.loginButtonText, 'Sign in with Okta', 'recognizes auth methods with certain urls');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('oidc: it calls window.open popup window on login', async function(assert) {
|
|
|
|
await renderIt(this);
|
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await component.role('test');
|
|
|
|
component.login();
|
2019-05-03 03:20:28 +00:00
|
|
|
await waitUntil(() => {
|
|
|
|
return this.openSpy.calledOnce;
|
|
|
|
});
|
|
|
|
run.cancelTimers();
|
|
|
|
let call = this.openSpy.getCall(0);
|
|
|
|
assert.deepEqual(
|
|
|
|
call.args,
|
|
|
|
['http://example.com', 'vaultOIDCWindow', 'width=500,height=600,resizable,scrollbars=yes,top=0,left=0'],
|
|
|
|
'called with expected args'
|
|
|
|
);
|
2019-02-14 15:39:19 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('oidc: it calls error handler when popup is closed', async function(assert) {
|
|
|
|
await renderIt(this);
|
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await component.role('test');
|
|
|
|
component.login();
|
2019-05-03 03:20:28 +00:00
|
|
|
await waitUntil(() => {
|
|
|
|
return this.openSpy.calledOnce;
|
|
|
|
});
|
|
|
|
this.window.close();
|
2019-02-21 22:21:23 +00:00
|
|
|
await settled();
|
2019-05-03 03:20:28 +00:00
|
|
|
assert.equal(this.error, ERROR_WINDOW_CLOSED, 'calls onError with error string');
|
2019-02-14 15:39:19 +00:00
|
|
|
});
|
|
|
|
|
2021-06-17 20:56:04 +00:00
|
|
|
test('oidc: shows error when message posted with state key, wrong params', async function(assert) {
|
2019-02-14 15:39:19 +00:00
|
|
|
await renderIt(this);
|
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await component.role('test');
|
|
|
|
component.login();
|
2019-05-03 03:20:28 +00:00
|
|
|
await waitUntil(() => {
|
|
|
|
return this.openSpy.calledOnce;
|
|
|
|
});
|
2021-06-17 20:56:04 +00:00
|
|
|
this.window.trigger('message', buildMessage({ data: { state: 'state', foo: 'bar' } }));
|
2019-05-03 03:20:28 +00:00
|
|
|
run.cancelTimers();
|
2021-06-17 20:56:04 +00:00
|
|
|
assert.equal(this.error, ERROR_MISSING_PARAMS, 'calls onError with params missing error');
|
2019-02-14 15:39:19 +00:00
|
|
|
});
|
|
|
|
|
2021-06-17 20:56:04 +00:00
|
|
|
test('oidc: storage event fires with state key, correct params', async function(assert) {
|
2019-02-14 15:39:19 +00:00
|
|
|
await renderIt(this);
|
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await component.role('test');
|
|
|
|
component.login();
|
2019-05-03 03:20:28 +00:00
|
|
|
await waitUntil(() => {
|
|
|
|
return this.openSpy.calledOnce;
|
|
|
|
});
|
2021-06-17 20:56:04 +00:00
|
|
|
this.window.trigger(
|
|
|
|
'message',
|
|
|
|
buildMessage({
|
|
|
|
data: {
|
|
|
|
path: 'foo',
|
|
|
|
state: 'state',
|
|
|
|
code: 'code',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
|
|
|
await settled();
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('oidc: fails silently when event origin does not match window origin', async function(assert) {
|
|
|
|
await renderIt(this);
|
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await component.role('test');
|
|
|
|
component.login();
|
|
|
|
await waitUntil(() => {
|
|
|
|
return this.openSpy.calledOnce;
|
|
|
|
});
|
|
|
|
this.window.trigger(
|
|
|
|
'message',
|
|
|
|
buildMessage({
|
|
|
|
origin: 'http://hackerz.com',
|
|
|
|
data: {
|
|
|
|
path: 'foo',
|
|
|
|
state: 'state',
|
|
|
|
code: 'code',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
);
|
2019-05-03 03:20:28 +00:00
|
|
|
run.cancelTimers();
|
2021-06-17 20:56:04 +00:00
|
|
|
await settled();
|
|
|
|
assert.notOk(this.handler.called, 'should not call the submit handler');
|
2019-02-14 15:39:19 +00:00
|
|
|
});
|
|
|
|
|
2021-06-17 20:56:04 +00:00
|
|
|
test('oidc: fails silently when event is not trusted', async function(assert) {
|
2019-02-14 15:39:19 +00:00
|
|
|
await renderIt(this);
|
|
|
|
this.set('selectedAuthPath', 'foo');
|
|
|
|
await component.role('test');
|
|
|
|
component.login();
|
2019-05-03 03:20:28 +00:00
|
|
|
await waitUntil(() => {
|
|
|
|
return this.openSpy.calledOnce;
|
|
|
|
});
|
2021-06-17 20:56:04 +00:00
|
|
|
this.window.trigger(
|
|
|
|
'message',
|
|
|
|
buildMessage({
|
|
|
|
isTrusted: false,
|
|
|
|
data: {
|
|
|
|
path: 'foo',
|
|
|
|
state: 'state',
|
|
|
|
code: 'code',
|
|
|
|
},
|
2020-01-15 21:27:12 +00:00
|
|
|
})
|
|
|
|
);
|
2021-06-17 20:56:04 +00:00
|
|
|
run.cancelTimers();
|
2019-02-21 22:21:23 +00:00
|
|
|
await settled();
|
2021-06-17 20:56:04 +00:00
|
|
|
assert.notOk(this.handler.called, 'should not call the submit handler');
|
2019-02-14 15:39:19 +00:00
|
|
|
});
|
|
|
|
});
|