Fixes login tests related to token removal

This commit is contained in:
Seyi Adebajo 2019-09-18 17:19:59 -07:00
parent 6080ddfae9
commit 59ed313bcd
3 changed files with 3 additions and 94 deletions

View File

@ -19,7 +19,7 @@ const getAuth = (_schema: {}, { requestBody }: { requestBody: string }) => {
return new Response(400, textContentHeader, 'Missing or invalid [credentials]');
}
if (password === 'invalidPassword' || password === 'invalidPassword123456' || password === 'validPasswordWithNoVip') {
if (password === 'invalidPassword' || password === 'invalidPassword123456') {
return new Response(401, textContentHeader, 'Invalid Password');
}

View File

@ -1,89 +0,0 @@
import { visit, click, find, fillIn, currentURL, settled } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import {
loginContainer,
authenticationUrl,
invalidCredentials,
testUser,
testPasswordInvalid,
testVipToken,
testPassword
} from 'wherehows-web/tests/helpers/login/constants';
import {
loginUserInput,
loginPasswordInput,
loginSubmitButton,
loginVipTokenInput
} from 'wherehows-web/tests/helpers/login/page-element-constants';
module('Acceptance | login', function(hooks) {
setupApplicationTest(hooks);
hooks.beforeEach(async function() {
await visit(authenticationUrl);
});
test('visiting /login', function(assert) {
assert.equal(currentURL(), authenticationUrl, `the current url is ${authenticationUrl}`);
});
test('should render login form', function(assert) {
assert.expect(5);
assert.ok(find(loginContainer), 'should have a login form container');
assert.ok(find('input[type=text]'), 'should have a username text input field');
assert.ok(find('input[type=password]'), 'should have a password text input field');
assert.ok(find('input[type=number]'), 'should have a VIP Token input field');
assert.ok(find('button[type=submit]'), 'should have a submit button');
});
test('should display error message with empty credentials', async function(assert) {
assert.expect(2);
await fillIn(loginUserInput, testUser);
await click(loginSubmitButton);
await settled();
assert.ok(find('#login-error').textContent.length, 'error message element is rendered');
assert.equal(
find('#login-error').textContent.trim(),
invalidCredentials,
'displays missing or invalid credentials message'
);
});
test('should display invalid password message with invalid password entered', async function(assert) {
assert.expect(2);
await fillIn(loginUserInput, testUser);
await fillIn(loginPasswordInput, testPasswordInvalid);
await fillIn(loginVipTokenInput, testVipToken);
await click(loginSubmitButton);
await settled();
assert.ok(find('#login-error').textContent.length, 'error message element is rendered');
assert.equal(
find('#login-error').textContent.trim(),
'Invalid Password',
'displays invalid password message in error message container'
);
});
/**
* Treating empty VIP as invalid password,
* since they are part of the same authentication request to the LDAP server.
*/
test('should display error message with empty VIP Token', async function(assert) {
assert.expect(2);
await fillIn(loginUserInput, testUser);
await fillIn(loginPasswordInput, testPassword);
await click(loginSubmitButton);
await settled();
assert.ok(find('#login-error').textContent.length, 'error message element is rendered');
assert.equal(
find('#login-error').textContent.trim(),
'Invalid Password',
'displays invalid password message in error message container'
);
});
});

View File

@ -1,17 +1,15 @@
import { visit, click, fillIn } from '@ember/test-helpers';
import { authenticationUrl, testUser, testPassword, testVipToken } from 'wherehows-web/tests/helpers/login/constants';
import { authenticationUrl, testUser, testPassword } from 'wherehows-web/tests/helpers/login/constants';
import {
loginUserInput,
loginPasswordInput,
loginSubmitButton,
loginVipTokenInput
loginSubmitButton
} from 'wherehows-web/tests/helpers/login/page-element-constants';
const appLogin = async (): Promise<void> => {
await visit(authenticationUrl);
await fillIn(loginUserInput, testUser);
await fillIn(loginPasswordInput, testPassword);
await fillIn(loginVipTokenInput, testVipToken.toString());
await click(loginSubmitButton);
};