Skip to content

Commit

Permalink
Change /auth to /login
Browse files Browse the repository at this point in the history
  • Loading branch information
ssinuco committed Oct 10, 2023
1 parent b87497a commit 9442d16
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions projects/04-burger-queen-api/e2e/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@ const config = require('../config');

const { fetch, fetchWithAuth } = process;

describe('POST /auth', () => {
describe('POST /login', () => {
it('should respond with 400 when email and password missing', () => (
fetch('/auth', { method: 'POST' })
fetch('/login', { method: 'POST' })
.then((resp) => expect(resp.status).toBe(400))
));

it('should respond with 400 when email is missing', () => (
fetch('/auth', {
fetch('/login', {
method: 'POST',
body: { email: '', password: 'xxxx' },
})
.then((resp) => expect(resp.status).toBe(400))
));

it('should respond with 400 when password is missing', () => (
fetch('/auth', {
fetch('/login', {
method: 'POST',
body: { email: 'foo@bar.baz' },
})
.then((resp) => expect(resp.status).toBe(400))
));

it('fail with 404 credentials dont match', () => (
fetch('/auth', {
fetch('/login', {
method: 'POST',
body: { email: `foo-${Date.now()}@bar.baz`, password: 'xxxx' },
})
.then((resp) => expect(resp.status).toBe(404))
));

it('should create new auth token and allow access using it', () => (
fetch('/auth', {
fetch('/login', {
method: 'POST',
body: { email: config.adminEmail, password: config.adminPassword },
})
.then((resp) => {
expect(resp.status).toBe(200);
return resp.json();
})
.then(({ token }) => fetchWithAuth(token)(`/users/${config.adminEmail}`))
.then(({ accessToken }) => fetchWithAuth(accessToken)(`/users/${config.adminEmail}`))
.then((resp) => {
expect(resp.status).toBe(200);
return resp.json();
Expand Down
4 changes: 2 additions & 2 deletions projects/04-burger-queen-api/e2e/globalSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const createTestUser = () => fetchAsAdmin('/users', {
if (resp.status !== 200) {
throw new Error(`Error: Could not create test user - response ${resp.status}`);
}
return fetch('/auth', { method: 'POST', body: __e2e.testUserCredentials });
return fetch('/login', { method: 'POST', body: __e2e.testUserCredentials });
})
.then((resp) => {
if (resp.status !== 200) {
Expand All @@ -73,7 +73,7 @@ const createTestUser = () => fetchAsAdmin('/users', {
})
.then(({ token }) => Object.assign(__e2e, { testUserToken: token }));

const checkAdminCredentials = () => fetch('/auth', {
const checkAdminCredentials = () => fetch('/login', {
method: 'POST',
body: __e2e.adminUserCredentials,
})
Expand Down
6 changes: 3 additions & 3 deletions projects/04-burger-queen-api/e2e/users.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('PUT /users/:uid', () => {
body: { password: 'garmadon' },
})
.then((resp) => expect(resp.status).toBe(200))
.then(() => fetch('/auth', {
.then(() => fetch('/login', {
method: 'POST',
body: { email: 'test@test.test', password: 'garmadon' },
}))
Expand All @@ -254,7 +254,7 @@ describe('PUT /users/:uid', () => {
body: { password: 'ohmygod' },
})
.then((resp) => expect(resp.status).toBe(200))
.then(() => fetch('/auth', {
.then(() => fetch('/login', {
method: 'POST',
body: { email: 'test@test.test', password: 'ohmygod' },
}))
Expand Down Expand Up @@ -286,7 +286,7 @@ describe('DELETE /users/:uid', () => {
const credentials = { email: `foo-${Date.now()}@bar.baz`, password: '1234' };
return fetchAsAdmin('/users', { method: 'POST', body: credentials })
.then((resp) => expect(resp.status).toBe(200))
.then(() => fetch('/auth', { method: 'POST', body: credentials }))
.then(() => fetch('/login', { method: 'POST', body: credentials }))
.then((resp) => {
expect(resp.status).toBe(200);
return resp.json();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Puedes confirmar si tu código funciona revisando la base de datos y con un test

### TODO 3: Implementar autenticación de usuario

En `routes/auth.js` está la ruta '/auth' definida, con un
En `routes/auth.js` está la ruta '/login' definida, con un

```js
// TODO: Authenticate the user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ dados e realizando um teste unitário.

### TODO 3: Implementar autenticación de usuario

En routes/auth.js, a rota '/auth' está definida com um
En routes/auth.js, a rota '/login' está definida com um

```js
// TODO: Authenticate the user
Expand Down
4 changes: 2 additions & 2 deletions projects/04-burger-queen-api/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const { secret } = config;
/** @module auth */
module.exports = (app, nextMain) => {
/**
* @name /auth
* @name /login
* @description Creates an authentication token.
* @path {POST} /auth
* @path {POST} /login
* @body {String} email Email
* @body {String} password Password
* @response {Object} resp
Expand Down

0 comments on commit 9442d16

Please sign in to comment.