profile: email change now requires password
This commit is contained in:
@@ -86,17 +86,35 @@ describe('Profile API', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('update', function () {
|
||||
describe('email', function () {
|
||||
it('change email fails due to missing token', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/email`)
|
||||
.send({ email: 'newemail@example.com' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(401);
|
||||
});
|
||||
|
||||
it('change email fails due to missing password', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/email`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ email: 'newemail@example.com' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('change email fails due to invalid password', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/email`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ email: 'foo@bar.com', password: 'this is wrong' })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(412);
|
||||
});
|
||||
|
||||
it('change email fails due to invalid email', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/email`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ email: 'foo@bar' })
|
||||
.ok(() => true);
|
||||
@@ -104,18 +122,10 @@ describe('Profile API', function () {
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('change user succeeds without email nor displayName', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({});
|
||||
|
||||
expect(response.statusCode).to.equal(204);
|
||||
});
|
||||
|
||||
it('change email succeeds', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/email`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ email: 'newemail@example.Com' });
|
||||
.send({ email: 'newemail@example.Com', password: owner.password });
|
||||
|
||||
expect(response.statusCode).to.equal(204);
|
||||
|
||||
@@ -127,9 +137,11 @@ describe('Profile API', function () {
|
||||
expect(response2.body.email).to.equal('newemail@example.com'); // lower cased
|
||||
expect(response2.body.displayName).to.equal('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('fallbackEmail', function () {
|
||||
it('change fallback email fails due to missing password', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/fallback_email`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ fallbackEmail: 'newemail@example.com' })
|
||||
.ok(() => true);
|
||||
@@ -138,7 +150,7 @@ describe('Profile API', function () {
|
||||
});
|
||||
|
||||
it('change fallback email fails due to invalid password', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/fallback_email`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ fallbackEmail: 'foo@bar.com', password: 'this is wrong' })
|
||||
.ok(() => true);
|
||||
@@ -147,7 +159,7 @@ describe('Profile API', function () {
|
||||
});
|
||||
|
||||
it('change fallback email succeeds', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/fallback_email`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ fallbackEmail: 'NewFallbackemail@example.com', password: owner.password });
|
||||
|
||||
@@ -160,9 +172,11 @@ describe('Profile API', function () {
|
||||
expect(response2.body.username).to.equal(owner.username);
|
||||
expect(response2.body.fallbackEmail).to.equal('newfallbackemail@example.com'); // lowercase
|
||||
});
|
||||
});
|
||||
|
||||
describe('displayName', function () {
|
||||
it('change displayName succeeds', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile`)
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/profile/display_name`)
|
||||
.query({ access_token: owner.token })
|
||||
.send({ displayName: 'Agent Smith' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user