-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from auth0/fix-passwordless-params
Passwordless start: map params to authParams and fix tests
- Loading branch information
Showing
3 changed files
with
125 additions
and
5 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 |
---|---|---|
|
@@ -167,6 +167,98 @@ describe('auth0.authentication', function () { | |
}); | ||
}); | ||
|
||
context('passwordless start', function () { | ||
before(function () { | ||
this.auth0 = new Authentication({ | ||
domain: 'me.auth0.com', | ||
clientID: '...', | ||
redirectUri: 'http://page.com/callback', | ||
responseType: 'code', | ||
_sendTelemetry: false | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
request.post.restore(); | ||
}); | ||
|
||
it('should call passwordless start', function (done) { | ||
stub(request, 'post', function (url) { | ||
expect(url).to.be('https://me.auth0.com/passwordless/start'); | ||
return new RequestMock({ | ||
body: { | ||
client_id: '...', | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
authParams: { | ||
redirect_uri: 'http://page.com/callback', | ||
response_type: 'code' | ||
} | ||
}, | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
cb: function (cb) { | ||
cb(null, { | ||
body: {} | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
this.auth0.passwordless.start({ | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
type: 'email' | ||
}, function (err, data) { | ||
expect(err).to.be(null); | ||
expect(data).to.eql({ | ||
|
||
}); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should call passwordless start with authParams', function (done) { | ||
stub(request, 'post', function (url) { | ||
expect(url).to.be('https://me.auth0.com/passwordless/start'); | ||
return new RequestMock({ | ||
body: { | ||
client_id: '...', | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
authParams: { | ||
scope: 'openid email', | ||
redirect_uri: 'http://page.com/callback', | ||
response_type: 'code' | ||
} | ||
}, | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
cb: function (cb) { | ||
cb(null, { | ||
body: {} | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
this.auth0.passwordless.start({ | ||
connection: 'the_connection', | ||
email: '[email protected]', | ||
type: 'email', | ||
scope: 'openid email' | ||
}, function (err, data) { | ||
expect(err).to.be(null); | ||
expect(data).to.eql({ | ||
|
||
}); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
context('passwordless verify', function () { | ||
before(function () { | ||
this.auth0 = new Authentication({ | ||
|
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 |
---|---|---|
|
@@ -554,7 +554,11 @@ describe('auth0.WebAuth', function () { | |
body: { | ||
client_id: '...', | ||
connection: 'the_connection', | ||
email: '[email protected]' | ||
email: '[email protected]', | ||
authParams: { | ||
redirect_uri: 'http://page.com/callback', | ||
response_type: 'code' | ||
} | ||
}, | ||
headers: { | ||
'Content-Type': 'application/json' | ||
|