1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-20 13:49:42 +02:00
documize/gui/tests/acceptance/authentication-test.js

54 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-12-08 15:39:31 +00:00
import { click, fillIn, currentURL, visit } from '@ember/test-helpers';
2016-07-07 18:54:16 -07:00
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
2016-07-19 15:51:35 +02:00
// This software (Documize Community Edition) is licensed under
2016-07-07 18:54:16 -07:00
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
2016-07-19 15:51:35 +02:00
// by contacting <sales@documize.com>.
2016-07-07 18:54:16 -07:00
//
// https://documize.com
2018-12-08 15:39:31 +00:00
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
module('Acceptance | Authentication', function(hooks) {
setupApplicationTest(hooks);
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
test('visiting /auth/login and logging in', async function(assert) {
server.create('meta', { allowAnonymousAccess: false });
await visit('/auth/login');
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
await fillIn('#authEmail', 'brizdigital@gmail.com');
await fillIn('#authPassword', 'zinyando123');
await click('button');
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful');
});
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
test('logging out a user', async function(assert) {
server.create('meta', { allowAnonymousAccess: false });
userLogin();
await click('.dropdown-menu a:contains(Logout)');
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
assert.equal(currentURL(), '/auth/login', 'Logging out successful');
});
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
test('successful sso login authenticates redirects to dashboard', async function(assert) {
server.create('meta', { allowAnonymousAccess: false });
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
await visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful');
});
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
test('sso login with bad token should redirect to login', async function(assert) {
server.create('meta', { allowAnonymousAccess: false });
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
await visit('/auth/sso/randomToken1234567890');
2016-07-07 18:54:16 -07:00
2018-12-08 15:39:31 +00:00
assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful');
});
2016-07-19 15:51:35 +02:00
});