github.com/jancarloviray/community@v0.41.1-0.20170124221257-33a66c87cf2f/app/tests/acceptance/authentication-test.js (about)

     1  // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
     2  //
     3  // This software (Documize Community Edition) is licensed under
     4  // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
     5  //
     6  // You can operate outside the AGPL restrictions by purchasing
     7  // Documize Enterprise Edition and obtaining a commercial license
     8  // by contacting <sales@documize.com>.
     9  //
    10  // https://documize.com
    11  
    12  import { test } from 'qunit';
    13  import moduleForAcceptance from 'documize/tests/helpers/module-for-acceptance';
    14  
    15  moduleForAcceptance('Acceptance | Authentication');
    16  
    17  test('visiting /auth/login and logging in', function (assert) {
    18  	server.create('meta', { allowAnonymousAccess: false });
    19  	visit('/auth/login');
    20  
    21  	fillIn('#authEmail', 'brizdigital@gmail.com');
    22  	fillIn('#authPassword', 'zinyando123');
    23  	click('button');
    24  
    25  	andThen(function () {
    26  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful');
    27  	});
    28  });
    29  
    30  test('logging out a user', function (assert) {
    31  	server.create('meta', { allowAnonymousAccess: false });
    32  	userLogin();
    33  	click('.dropdown-menu a:contains(Logout)');
    34  
    35  	andThen(function () {
    36  		assert.equal(currentURL(), '/auth/login', 'Logging out successful');
    37  	});
    38  });
    39  
    40  test('successful sso login authenticates redirects to dashboard', function (assert) {
    41  	server.create('meta', { allowAnonymousAccess: false });
    42  
    43  	visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
    44  
    45  	andThen(function () {
    46  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful');
    47  	});
    48  });
    49  
    50  test('sso login with bad token should redirect to login', function (assert) {
    51  	server.create('meta', { allowAnonymousAccess: false });
    52  
    53  	visit('/auth/sso/randomToken1234567890');
    54  
    55  	andThen(function () {
    56  		assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful');
    57  	});
    58  });