-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): use base64 encoding for basic authentication
- Loading branch information
Marc Ryan
committed
Mar 24, 2017
1 parent
3e26c1c
commit 15e4407
Showing
3 changed files
with
7 additions
and
4 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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import sinon from 'sinon'; | ||
import btoa from 'btoa'; | ||
import GigwalkAPI from '../../src/index'; | ||
import GigwalkAxios from '../../src/client'; | ||
import Authorization from '../../src/api/authorization'; | ||
|
@@ -42,8 +43,8 @@ describe('GigwalkAPI', () => { | |
it('should allow users to authenticate', () => { | ||
const gigwalk = new GigwalkAPI(); | ||
|
||
gigwalk.authenticate({ email: '[email protected]', password: 'password' }); | ||
expect(gigwalk.client).to.have.deep.property('defaults.headers.common.Authorization', 'Basic [email protected]:password'); | ||
gigwalk.authenticate({ username: '[email protected]', password: 'password' }); | ||
expect(gigwalk.client).to.have.deep.property('defaults.headers.common.Authorization', `Basic ${btoa('[email protected]:password')}`); | ||
|
||
gigwalk.authenticate({ token: 'qwerty' }); | ||
expect(gigwalk.client).to.have.deep.property('defaults.headers.common.Authorization', 'Token qwerty'); | ||
|