github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/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  	server.createList('folder', 2);
    20  	visit('/auth/login');
    21  
    22  	fillIn('#authEmail', 'brizdigital@gmail.com');
    23  	fillIn('#authPassword', 'zinyando123');
    24  	click('button');
    25  
    26  	andThen(function () {
    27  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'Login successful');
    28  	});
    29  });
    30  
    31  test('logging out a user', function (assert) {
    32  	server.create('meta', { allowAnonymousAccess: false });
    33  	server.createList('folder', 2);
    34  	userLogin();
    35  
    36  	visit('/auth/logout');
    37  
    38  	andThen(function () {
    39  		assert.equal(currentURL(), '/auth/login', 'Logging out successful');
    40  	});
    41  });
    42  
    43  test('successful sso login authenticates redirects to dashboard', function (assert) {
    44  	server.create('meta', { allowAnonymousAccess: false });
    45  	server.createList('folder', 2);
    46  
    47  	visit('/auth/sso/OmJyaXpkaWdpdGFsQGdtYWlsLmNvbTp6aW55YW5kbzEyMw==');
    48  
    49  	andThen(function () {
    50  		assert.equal(currentURL(), '/s/VzMuyEw_3WqiafcG/my-project', 'SSO login successful');
    51  	});
    52  });
    53  
    54  test('sso login with bad token should redirect to login', function (assert) {
    55  	server.create('meta', { allowAnonymousAccess: false });
    56  	server.createList('folder', 2);
    57  
    58  	visit('/auth/sso/randomToken1234567890');
    59  
    60  	andThen(function () {
    61  		assert.equal(currentURL(), '/auth/login', 'SSO login unsuccessful');
    62  	});
    63  });