mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
fix: api login use case when user already exist
It adds a new use case based on the plugin update. 409 in case user exists already and 201 when new user has been created.
This commit is contained in:
parent
3a9c994bbc
commit
6491db4191
1 changed files with 21 additions and 3 deletions
|
@ -146,12 +146,14 @@ describe('endpoint unit test', () => {
|
|||
});
|
||||
|
||||
test('should test add a new user with login', (done) => {
|
||||
const newCredentials = _.clone(credentials);
|
||||
newCredentials.name = 'jotaNew';
|
||||
|
||||
request(app)
|
||||
.put('/-/user/org.couchdb.user:jota')
|
||||
.send(credentials)
|
||||
.put('/-/user/org.couchdb.user:jotaNew')
|
||||
.send(newCredentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.expect(201)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
|
@ -161,6 +163,22 @@ describe('endpoint unit test', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('should test fails on add a existing user with login', (done) => {
|
||||
request(app)
|
||||
.put('/-/user/org.couchdb.user:jotaNew')
|
||||
.send(credentials)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(409)
|
||||
.end(function(err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
expect(res.body.error).toBeDefined();
|
||||
expect(res.body.error).toMatch(/username is already registered/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should test fails add a new user with wrong password', (done) => {
|
||||
|
||||
const credentialsShort = _.clone(credentials);
|
||||
|
|
Loading…
Reference in a new issue