-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for 2fa login using --2fa
- Loading branch information
Dom Harrington
committed
Oct 1, 2018
1 parent
65fde12
commit 1baeec9
Showing
2 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,5 +60,40 @@ describe('login command', () => { | |
}); | ||
}); | ||
|
||
it('should error if missing two factor token', done => { | ||
const email = '[email protected]'; | ||
const password = '123456'; | ||
const project = 'subdomain'; | ||
|
||
const mock = nock(config.host) | ||
.post('/api/v1/login', { email, password, project }) | ||
.reply(400, { | ||
description: 'You must provide a Two Factor Code', | ||
error: 'Bad Request', | ||
}); | ||
|
||
return login([], { email, password, project }).catch(err => { | ||
mock.done(); | ||
assert.equal(err.error, 'Bad Request'); | ||
assert.equal(err.description, 'You must provide a Two Factor Code'); | ||
return done(); | ||
}); | ||
}); | ||
|
||
it('should send 2fa token if provided', () => { | ||
const email = '[email protected]'; | ||
const password = '123456'; | ||
const project = 'subdomain'; | ||
const token = '123456'; | ||
|
||
const mock = nock(config.host) | ||
.post('/api/v1/login', { email, password, project, token }) | ||
.reply(200, { apiKey: 123 }); | ||
|
||
return login([], { email, password, project, token }).then(() => { | ||
mock.done(); | ||
}); | ||
}); | ||
|
||
it('should error if trying to access a project that is not yours', () => {}); | ||
}); |