Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions test/integration-tests/user/updateUserTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ describe('Testing Edit user endpoint', () => {
expect(res).to.have.status(200)
})
})
it('Should return 200 when only name changes are done with registry enabled', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&name.first=NewNameAgain')
.set(constants.nonSecretariatUserHeaders)
.then((res, err) => {
expect(err).to.be.undefined
expect(res).to.have.status(200)
})
})
it('Should return an error when admin is required', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?new_username=NewUsername')
Expand All @@ -29,6 +38,16 @@ describe('Testing Edit user endpoint', () => {
expect(res.body.error).to.contain('NOT_ORG_ADMIN_OR_SECRETARIAT_UPDATE')
})
})
it('Should return an error when admin is required with registry enabled', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&new_username=NewUsername')
.set(constants.nonSecretariatUserHeaders)
.then((res, err) => {
expect(err).to.be.undefined
expect(res).to.have.status(403)
expect(res.body.error).to.contain('NOT_ORG_ADMIN_OR_SECRETARIAT_UPDATE')
})
})
it('Should not allow a first name of more than 100 characters', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?name.first=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
Expand All @@ -38,6 +57,15 @@ describe('Testing Edit user endpoint', () => {
expect(res.body.error).to.contain('BAD_INPUT')
})
})
it('Should not allow a first name of more than 100 characters with registry enabled', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&name.first=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
.set(constants.nonSecretariatUserHeaders)
.then((res, err) => {
expect(res).to.have.status(400)
expect(res.body.error).to.contain('BAD_INPUT')
})
})
it('Should not allow a middle name of more than 100 characters', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?name.middle=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
Expand All @@ -47,6 +75,15 @@ describe('Testing Edit user endpoint', () => {
expect(res.body.error).to.contain('BAD_INPUT')
})
})
it('Should not allow a middle name of more than 100 characters with registry enabled', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&name.middle=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
.set(constants.nonSecretariatUserHeaders)
.then((res, err) => {
expect(res).to.have.status(400)
expect(res.body.error).to.contain('BAD_INPUT')
})
})
it('Should not allow a last name of more than 100 characters', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?name.last=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
Expand All @@ -56,6 +93,15 @@ describe('Testing Edit user endpoint', () => {
expect(res.body.error).to.contain('BAD_INPUT')
})
})
it('Should not allow a last name of more than 100 characters with registry enabled', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&name.last=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
.set(constants.nonSecretariatUserHeaders)
.then((res, err) => {
expect(res).to.have.status(400)
expect(res.body.error).to.contain('BAD_INPUT')
})
})
it('Should not allow a suffix of more than 100 characters', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?name.suffix=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
Expand All @@ -65,5 +111,14 @@ describe('Testing Edit user endpoint', () => {
expect(res.body.error).to.contain('BAD_INPUT')
})
})
it('Should not allow a suffix of more than 100 characters with registry enabled', async () => {
await chai.request(app)
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&name.suffix=1:1234567,2:1234567,3:1234567,4:1234567,5:1234567,6:1234567,7:1234567,8:1234567,9:1234567,10:1234567,11:1234567')
.set(constants.nonSecretariatUserHeaders)
.then((res, err) => {
expect(res).to.have.status(400)
expect(res.body.error).to.contain('BAD_INPUT')
})
})
})
})
Loading