Skip to content

Commit 892aabd

Browse files
committed
Adding tests for updating users with the registry flag set to true
1 parent 509f3c3 commit 892aabd

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

test/integration-tests/user/updateUserTest.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ describe('Testing Edit user endpoint', () => {
1919
expect(res).to.have.status(200)
2020
})
2121
})
22+
it('Should return 200 when only name changes are done with registry enabled', async () => {
23+
await chai.request(app)
24+
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&name.first=NewNameAgain')
25+
.set(constants.nonSecretariatUserHeaders)
26+
.then((res, err) => {
27+
expect(err).to.be.undefined
28+
expect(res).to.have.status(200)
29+
})
30+
})
2231
it('Should return an error when admin is required', async () => {
2332
await chai.request(app)
2433
.put('/api/org/win_5/user/jasminesmith@win_5.com?new_username=NewUsername')
@@ -29,6 +38,16 @@ describe('Testing Edit user endpoint', () => {
2938
expect(res.body.error).to.contain('NOT_ORG_ADMIN_OR_SECRETARIAT_UPDATE')
3039
})
3140
})
41+
it('Should return an error when admin is required with registry enabled', async () => {
42+
await chai.request(app)
43+
.put('/api/org/win_5/user/jasminesmith@win_5.com?registry=true&new_username=NewUsername')
44+
.set(constants.nonSecretariatUserHeaders)
45+
.then((res, err) => {
46+
expect(err).to.be.undefined
47+
expect(res).to.have.status(403)
48+
expect(res.body.error).to.contain('NOT_ORG_ADMIN_OR_SECRETARIAT_UPDATE')
49+
})
50+
})
3251
it('Should not allow a first name of more than 100 characters', async () => {
3352
await chai.request(app)
3453
.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')
@@ -38,6 +57,15 @@ describe('Testing Edit user endpoint', () => {
3857
expect(res.body.error).to.contain('BAD_INPUT')
3958
})
4059
})
60+
it('Should not allow a first name of more than 100 characters with registry enabled', async () => {
61+
await chai.request(app)
62+
.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')
63+
.set(constants.nonSecretariatUserHeaders)
64+
.then((res, err) => {
65+
expect(res).to.have.status(400)
66+
expect(res.body.error).to.contain('BAD_INPUT')
67+
})
68+
})
4169
it('Should not allow a middle name of more than 100 characters', async () => {
4270
await chai.request(app)
4371
.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')
@@ -47,6 +75,15 @@ describe('Testing Edit user endpoint', () => {
4775
expect(res.body.error).to.contain('BAD_INPUT')
4876
})
4977
})
78+
it('Should not allow a middle name of more than 100 characters with registry enabled', async () => {
79+
await chai.request(app)
80+
.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')
81+
.set(constants.nonSecretariatUserHeaders)
82+
.then((res, err) => {
83+
expect(res).to.have.status(400)
84+
expect(res.body.error).to.contain('BAD_INPUT')
85+
})
86+
})
5087
it('Should not allow a last name of more than 100 characters', async () => {
5188
await chai.request(app)
5289
.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')
@@ -56,6 +93,15 @@ describe('Testing Edit user endpoint', () => {
5693
expect(res.body.error).to.contain('BAD_INPUT')
5794
})
5895
})
96+
it('Should not allow a last name of more than 100 characters with registry enabled', async () => {
97+
await chai.request(app)
98+
.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')
99+
.set(constants.nonSecretariatUserHeaders)
100+
.then((res, err) => {
101+
expect(res).to.have.status(400)
102+
expect(res.body.error).to.contain('BAD_INPUT')
103+
})
104+
})
59105
it('Should not allow a suffix of more than 100 characters', async () => {
60106
await chai.request(app)
61107
.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')
@@ -65,5 +111,14 @@ describe('Testing Edit user endpoint', () => {
65111
expect(res.body.error).to.contain('BAD_INPUT')
66112
})
67113
})
114+
it('Should not allow a suffix of more than 100 characters with registry enabled', async () => {
115+
await chai.request(app)
116+
.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')
117+
.set(constants.nonSecretariatUserHeaders)
118+
.then((res, err) => {
119+
expect(res).to.have.status(400)
120+
expect(res.body.error).to.contain('BAD_INPUT')
121+
})
122+
})
68123
})
69124
})

0 commit comments

Comments
 (0)