Remove primaryEmail parameter from REST api.
This commit is contained in:
parent
4c28da4eab
commit
5fa36e6d52
@ -37,12 +37,12 @@ class REST {
|
||||
* @param {Object} ctx The koa request/response context
|
||||
*/
|
||||
async create(ctx) {
|
||||
const {publicKeyArmored, primaryEmail} = ctx.request.body;
|
||||
if (!publicKeyArmored || (primaryEmail && !util.isEmail(primaryEmail))) {
|
||||
const {publicKeyArmored} = ctx.request.body;
|
||||
if (!publicKeyArmored) {
|
||||
ctx.throw(400, 'Invalid request!');
|
||||
}
|
||||
const origin = util.origin(ctx);
|
||||
await this._publicKey.put({publicKeyArmored, primaryEmail, origin});
|
||||
await this._publicKey.put({publicKeyArmored, origin});
|
||||
ctx.body = 'Upload successful. Check your inbox to verify your email address.';
|
||||
ctx.status = 201;
|
||||
}
|
||||
|
@ -68,26 +68,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
||||
.end(done);
|
||||
});
|
||||
|
||||
it('should return 400 for an invalid primaryEmail', done => {
|
||||
request(app.listen())
|
||||
.post('/api/v1/key')
|
||||
.send({publicKeyArmored, primaryEmail: 'foo'})
|
||||
.expect(400)
|
||||
.end(done);
|
||||
});
|
||||
|
||||
it('should return 201 with primaryEmail', done => {
|
||||
request(app.listen())
|
||||
.post('/api/v1/key')
|
||||
.send({publicKeyArmored, primaryEmail})
|
||||
.expect(201)
|
||||
.end(() => {
|
||||
expect(emailParams).to.exist;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return 201 without primaryEmail', done => {
|
||||
it('should return 201', done => {
|
||||
request(app.listen())
|
||||
.post('/api/v1/key')
|
||||
.send({publicKeyArmored})
|
||||
@ -103,7 +84,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
||||
beforeEach(done => {
|
||||
request(app.listen())
|
||||
.post('/api/v1/key')
|
||||
.send({publicKeyArmored, primaryEmail})
|
||||
.send({publicKeyArmored})
|
||||
.expect(201)
|
||||
.end(done);
|
||||
});
|
||||
@ -134,7 +115,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
||||
beforeEach(done => {
|
||||
request(app.listen())
|
||||
.post('/api/v1/key')
|
||||
.send({publicKeyArmored, primaryEmail})
|
||||
.send({publicKeyArmored})
|
||||
.expect(201)
|
||||
.end(done);
|
||||
});
|
||||
@ -196,7 +177,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
||||
beforeEach(done => {
|
||||
request(app.listen())
|
||||
.post('/api/v1/key')
|
||||
.send({publicKeyArmored, primaryEmail})
|
||||
.send({publicKeyArmored})
|
||||
.expect(201)
|
||||
.end(done);
|
||||
});
|
||||
@ -234,7 +215,7 @@ describe('Koa App (HTTP Server) Integration Tests', function() {
|
||||
beforeEach(done => {
|
||||
request(app.listen())
|
||||
.post('/api/v1/key')
|
||||
.send({publicKeyArmored, primaryEmail})
|
||||
.send({publicKeyArmored})
|
||||
.expect(201)
|
||||
.end(() => {
|
||||
request(app.listen())
|
||||
|
Loading…
Reference in New Issue
Block a user