mirror of
https://github.com/outline/outline.git
synced 2025-03-28 14:34:35 +00:00
More api/auth tests
This commit is contained in:
@ -1,3 +1,42 @@
|
||||
exports[`#auth.login should login with email 1`] = `
|
||||
Object {
|
||||
"avatarUrl": "http://example.com/avatar.png",
|
||||
"id": "86fde1d4-0050-428f-9f0b-0bf77f8bdf61",
|
||||
"name": "User 1",
|
||||
"username": "user1"
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#auth.login should login with username 1`] = `
|
||||
Object {
|
||||
"avatarUrl": "http://example.com/avatar.png",
|
||||
"id": "86fde1d4-0050-428f-9f0b-0bf77f8bdf61",
|
||||
"name": "User 1",
|
||||
"username": "user1"
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#auth.login should require either username or email 1`] = `
|
||||
Object {
|
||||
"error": "username or email is required",
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#auth.login should require password 1`] = `
|
||||
Object {
|
||||
"error": "password is required",
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#auth.login should validate password 1`] = `
|
||||
Object {
|
||||
"error": "Invalid password",
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#auth.signup should require params 1`] = `
|
||||
Object {
|
||||
"error": "name is required",
|
||||
@ -25,42 +64,3 @@ Object {
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#login should login with email 1`] = `
|
||||
Object {
|
||||
"avatarUrl": "http://example.com/avatar.png",
|
||||
"id": "86fde1d4-0050-428f-9f0b-0bf77f8bdf61",
|
||||
"name": "User 1",
|
||||
"username": "user1"
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#login should login with username 1`] = `
|
||||
Object {
|
||||
"avatarUrl": "http://example.com/avatar.png",
|
||||
"id": "86fde1d4-0050-428f-9f0b-0bf77f8bdf61",
|
||||
"name": "User 1",
|
||||
"username": "user1"
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#login should require either username or email 1`] = `
|
||||
Object {
|
||||
"error": "username or email is required",
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#login should require password 1`] = `
|
||||
Object {
|
||||
"error": "password is required",
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`#login should validate password 1`] = `
|
||||
Object {
|
||||
"error": "Invalid password",
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
@ -1,11 +1,11 @@
|
||||
exports[`test should require authentication 1`] = `
|
||||
exports[`#user.info should require authentication 1`] = `
|
||||
Object {
|
||||
"error": "Authentication required",
|
||||
"ok": false
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`test should return known user 1`] = `
|
||||
exports[`#user.info should return known user 1`] = `
|
||||
Object {
|
||||
"data": Object {
|
||||
"avatarUrl": "http://example.com/avatar.png",
|
||||
|
@ -86,7 +86,7 @@ describe('#auth.signup', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#login', () => {
|
||||
describe('#auth.login', () => {
|
||||
test('should login with email', async () => {
|
||||
await seed();
|
||||
const res = await server.post('/api/auth.login', {
|
||||
|
@ -11,28 +11,30 @@ beforeEach(flushdb);
|
||||
afterAll(() => server.close());
|
||||
afterAll(() => sequelize.close());
|
||||
|
||||
it('should return known user', async () => {
|
||||
await seed();
|
||||
const user = await User.findOne({
|
||||
where: {
|
||||
email: 'user1@example.com',
|
||||
},
|
||||
describe('#user.info', async () => {
|
||||
it('should return known user', async () => {
|
||||
await seed();
|
||||
const user = await User.findOne({
|
||||
where: {
|
||||
email: 'user1@example.com',
|
||||
},
|
||||
});
|
||||
|
||||
const res = await server.post('/api/user.info', {
|
||||
body: { token: user.getJwtToken() },
|
||||
});
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
const res = await server.post('/api/user.info', {
|
||||
body: { token: user.getJwtToken() },
|
||||
it('should require authentication', async () => {
|
||||
await seed();
|
||||
const res = await server.post('/api/user.info');
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(401);
|
||||
expect(body).toMatchSnapshot();
|
||||
});
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should require authentication', async () => {
|
||||
await seed();
|
||||
const res = await server.post('/api/user.info');
|
||||
const body = await res.json();
|
||||
|
||||
expect(res.status).toEqual(401);
|
||||
expect(body).toMatchSnapshot();
|
||||
});
|
||||
|
Reference in New Issue
Block a user