Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsmith committed Oct 2, 2016
1 parent fa9d5c6 commit 2001d1e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 23 deletions.
14 changes: 2 additions & 12 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ module.exports = function(environment) {
// ENV.APP.LOG_VIEW_LOOKUPS = true;

ENV.API_BASE_URL = 'http://api.lvh.me:49235';
ENV.SERVER_TOKEN_ENDPOINT = 'http://api.lvh.me:49235/token';
ENV.SERVER_TOKEN_REFRESH_ENDPOINT = 'http://api.lvh.me:49235/token/refresh';
ENV.WEB_BASE_URL = 'http://localhost:4200';

ENV.sentry.development = true;
Expand Down Expand Up @@ -128,17 +126,13 @@ module.exports = function(environment) {

if (environment === 'remote-development') {
ENV.API_BASE_URL = 'http://api.pbqrpbecf-qri.org';
ENV.SERVER_TOKEN_ENDPOINT = 'http://api.pbqrpbecf-qri.org/token';
ENV.SERVER_TOKEN_REFRESH_ENDPOINT = 'http://api.pbqrpbecf-qri.org/token/refresh';
ENV.WEB_BASE_URL = 'http://www.pbqrpbecf-qri.org';

ENV.sentry.development = true;
}

if (environment === 'staging') {
ENV.API_BASE_URL = 'http://api.pbqrpbecf.org';
ENV.SERVER_TOKEN_ENDPOINT = 'http://api.pbqrpbecf.org/token';
ENV.SERVER_TOKEN_REFRESH_ENDPOINT = 'http://api.pbqrpbecf.org/token/refresh';
ENV.WEB_BASE_URL = 'http://www.pbqrpbecf.org';

ENV.sentry.dsn = 'https://c494e4250972401e84b74526fdf1182b@app.getsentry.com/82742';
Expand All @@ -156,8 +150,6 @@ module.exports = function(environment) {
ENV.APP.rootElement = '#ember-testing';

ENV.API_BASE_URL = '';
ENV.SERVER_TOKEN_ENDPOINT = '/token';
ENV.SERVER_TOKEN_REFRESH_ENDPOINT = '/token/refresh';
ENV.WEB_BASE_URL = '';

ENV.sentry.development = true;
Expand All @@ -173,14 +165,12 @@ module.exports = function(environment) {

if (environment === 'production') {
ENV.API_BASE_URL = 'https://api.codecorps.org';
ENV.SERVER_TOKEN_ENDPOINT = 'https://api.codecorps.org/token';
ENV.SERVER_TOKEN_REFRESH_ENDPOINT = 'https://api.codecorps.org/token/refresh';
ENV.WEB_BASE_URL = 'http://www.codecorps.org';
}

ENV['ember-simple-auth-token'] = {
serverTokenEndpoint: ENV.SERVER_TOKEN_ENDPOINT,
serverTokenRefreshEndpoint: ENV.SERVER_TOKEN_REFRESH_ENDPOINT,
serverTokenEndpoint: ENV.API_BASE_URL + '/token',
serverTokenRefreshEndpoint: ENV.API_BASE_URL + '/token/refresh',
refreshLeeway: 3000, // 5 minutes before expiry
timeFactor: 1000,
};
Expand Down
13 changes: 7 additions & 6 deletions mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,22 @@ export default function() {

// POST /token
this.post('/token', (db, request) => {
console.log(request);
let json = JSON.parse(request.requestBody);

if(json.username === "josh@coderly.com" && json.password === "password") {
if(json.username === "volunteers@codecorps.org" && json.password === "password") {
return {
// token encoded at https://jwt.io/
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXNzd29yZCI6InBhc3N3b3JkIiwidXNlcm5hbWUiOiJqb3NoQGNvZGVybHkuY29tIiwidXNlcl9pZCI6MSwiZXhwIjo3MjAwfQ.QVDyAznECIWL6DjDs9iPezvMmoPuzDqAl4bQ6CY-fCQ"
};
} else {
return new Mirage.Response(400, {}, {
let errorDetail = "Your password doesn't match the email " + json.username + ".";
return new Mirage.Response(401, {}, {
errors: [
{
id: "INVALID_GRANT",
title: "Invalid grant",
detail: "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
id: "UNAUTHORIZED",
title: "401 Unauthorized",
detail: errorDetail,
status: 401
}
]
Expand Down Expand Up @@ -457,7 +459,6 @@ export default function() {
return { available: true, valid: true };
});


// GET /users/username_available
this.get('/users/username_available', () => {
return { available: true, valid: true };
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/login-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ test('Logging in', function(assert) {
});

test('Login failure', function(assert) {
const ERROR_TEXT = 'The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.';
// Mirage expects volunteers@codecorps.org as default email
const ERROR_TEXT = "Your password doesn't match the email volunteers@codecorps.org.";

assert.expect(2);

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/signup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('Successful signup', (assert) => {

let signInDone = assert.async();

server.post('/login', function(db, request) {
server.post('/token', function(db, request) {
let json = request.requestBody;

assert.ok(json.indexOf('"username":"email@example.com"') > -1);
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/task-creation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test('Creating a task requires logging in', (assert) => {
andThen(() => {
assert.equal(currentRouteName(), 'login', 'Got redirected to login');

server.schema.users.create({ id: 1, email: 'josh@coderly.com' });
server.schema.users.create({ id: 1, email: 'volunteers@codecorps.org' });
loginPage.form.loginSuccessfully();
});

Expand Down
4 changes: 2 additions & 2 deletions tests/pages/components/login-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export default {

loginSuccessfully() {
this
.username('josh@coderly.com')
.username('volunteers@codecorps.org')
.password('password')
.submit();
},
loginUnsuccessfully() {
this
.username('josh@coderly.com')
.username('volunteers@codecorps.org')
.password('wrongpassword')
.submit();
}
Expand Down

0 comments on commit 2001d1e

Please sign in to comment.