-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDK-2261] Add forwardFor support to passwordless calls (#576)
- Loading branch information
1 parent
09dec3e
commit 050a4b8
Showing
2 changed files
with
122 additions
and
10 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 |
---|---|---|
|
@@ -54,6 +54,9 @@ describe('PasswordlessAuthenticator', function() { | |
username: 'username', | ||
password: 'pwd' | ||
}; | ||
var options = { | ||
forwardedFor: '0.0.0.0' | ||
}; | ||
|
||
beforeEach(function() { | ||
var oauth = new OAuth(validOptions); | ||
|
@@ -246,6 +249,25 @@ describe('PasswordlessAuthenticator', function() { | |
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should make it possible to pass auth0-forwarded-for header', function(done) { | ||
nock.cleanAll(); | ||
|
||
var request = nock(API_URL) | ||
.post(path, function() { | ||
return this.getHeader('auth0-forwarded-for') === options.forwardedFor; | ||
}) | ||
.reply(200); | ||
|
||
this.authenticator | ||
.signIn(userData, options) | ||
.then(function() { | ||
expect(request.isDone()).to.be.true; | ||
|
||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
}); | ||
|
||
describe('/oauth/token', function() { | ||
|
@@ -254,6 +276,9 @@ describe('PasswordlessAuthenticator', function() { | |
username: 'username', | ||
otp: '000000' | ||
}; | ||
var options = { | ||
forwardedFor: '0.0.0.0' | ||
}; | ||
|
||
beforeEach(function() { | ||
var oauth = new OAuth(validOptions); | ||
|
@@ -446,6 +471,25 @@ describe('PasswordlessAuthenticator', function() { | |
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should make it possible to pass auth0-forwarded-for header', function(done) { | ||
nock.cleanAll(); | ||
|
||
var request = nock(API_URL) | ||
.post(path, function() { | ||
return this.getHeader('auth0-forwarded-for') === options.forwardedFor; | ||
}) | ||
.reply(200); | ||
|
||
this.authenticator | ||
.signIn(userData, options) | ||
.then(function() { | ||
expect(request.isDone()).to.be.true; | ||
|
||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
}); | ||
}); | ||
|
||
|
@@ -455,6 +499,9 @@ describe('PasswordlessAuthenticator', function() { | |
email: '[email protected]', | ||
send: 'link' | ||
}; | ||
var options = { | ||
forwardedFor: '0.0.0.0' | ||
}; | ||
|
||
beforeEach(function() { | ||
var oauth = new OAuth(validOptions); | ||
|
@@ -612,13 +659,35 @@ describe('PasswordlessAuthenticator', function() { | |
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should make it possible to pass auth0-forwarded-for header', function(done) { | ||
nock.cleanAll(); | ||
|
||
var request = nock(API_URL) | ||
.post(path, function() { | ||
return this.getHeader('auth0-forwarded-for') === options.forwardedFor; | ||
}) | ||
.reply(200); | ||
|
||
this.authenticator | ||
.sendEmail(userData, options) | ||
.then(function() { | ||
expect(request.isDone()).to.be.true; | ||
|
||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
}); | ||
|
||
describe('#sendSMS', function() { | ||
var path = '/passwordless/start'; | ||
var userData = { | ||
phone_number: '12345678' | ||
}; | ||
var options = { | ||
forwardedFor: '0.0.0.0' | ||
}; | ||
|
||
beforeEach(function() { | ||
var oauth = new OAuth(validOptions); | ||
|
@@ -746,5 +815,24 @@ describe('PasswordlessAuthenticator', function() { | |
}) | ||
.catch(done); | ||
}); | ||
|
||
it('should make it possible to pass auth0-forwarded-for header', function(done) { | ||
nock.cleanAll(); | ||
|
||
var request = nock(API_URL) | ||
.post(path, function() { | ||
return this.getHeader('auth0-forwarded-for') === options.forwardedFor; | ||
}) | ||
.reply(200); | ||
|
||
this.authenticator | ||
.sendSMS(userData, options) | ||
.then(function() { | ||
expect(request.isDone()).to.be.true; | ||
|
||
done(); | ||
}) | ||
.catch(done); | ||
}); | ||
}); | ||
}); |