-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Signup challenge enforcement endpoint
- Loading branch information
Showing
10 changed files
with
118 additions
and
48 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
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
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 |
---|---|---|
|
@@ -4,8 +4,7 @@ import en from '../src/i18n/en'; | |
|
||
const lockOpts = { | ||
allowedConnections: ['db'], | ||
rememberLastLogin: false, | ||
initialScreen: 'signUp' | ||
rememberLastLogin: false | ||
}; | ||
|
||
const svgCaptchaRequiredResponse1 = { | ||
|
@@ -33,39 +32,40 @@ describe('captcha on signup', function () { | |
describe('svg-captcha', () => { | ||
describe('when the api returns a new challenge', function () { | ||
beforeEach(function (done) { | ||
this.stub = h.stubGetChallenge([svgCaptchaRequiredResponse1, svgCaptchaRequiredResponse2]); | ||
this.lock = h.displayLock('', lockOpts, done); | ||
this.stub = h.stubGetChallenge({ required: false }); | ||
this.stub = h.stubGetSignupChallenge([svgCaptchaRequiredResponse1, svgCaptchaRequiredResponse2]); | ||
this.lock = h.displayLock('', lockOpts, () => { | ||
h.clickSignUpTab(); | ||
h.waitUntilExists(this.lock, '.auth0-lock-with-terms', () => { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
this.lock.hide(); | ||
}); | ||
|
||
it('sign-up tab should be active', function (done) { | ||
h.waitUntilExists(this.lock, '.auth0-lock-tabs-current', () => { | ||
expect(h.isSignUpTabCurrent(this.lock)).to.be.ok(); | ||
done(); | ||
}); | ||
it('sign-up tab should be active', function () { | ||
expect(h.isSignUpTabCurrent(this.lock)).to.be.ok(); | ||
}); | ||
|
||
it('should show the captcha input', function (done) { | ||
expect(h.isSignUpTabCurrent(this.lock)).to.be.ok(); | ||
setTimeout(() => { | ||
expect(h.qInput(this.lock, 'captcha', false)).to.be.ok(); | ||
done(); | ||
}, 500); | ||
}); | ||
|
||
it('should require another challenge when clicking the refresh button', function (done) { | ||
h.waitUntilExists(this.lock, '.auth0-lock-captcha-refresh', () => { | ||
h.clickRefreshCaptchaButton(this.lock); | ||
|
||
setTimeout(() => { | ||
expect(h.q(this.lock, '.auth0-lock-captcha-image').style.backgroundImage).to.equal( | ||
`url("${svgCaptchaRequiredResponse2.image}")` | ||
); | ||
done(); | ||
}, 200); | ||
}); | ||
h.clickRefreshCaptchaButton(this.lock); | ||
setTimeout(() => { | ||
expect(h.q(this.lock, '.auth0-lock-captcha-image').style.backgroundImage).to.equal( | ||
`url("${svgCaptchaRequiredResponse2.image}")` | ||
); | ||
done(); | ||
}, 200); | ||
}); | ||
|
||
it('should submit the captcha provided by the user', function (done) { | ||
|
@@ -86,12 +86,16 @@ describe('captcha on signup', function () { | |
}); | ||
}); | ||
|
||
describe('when the challenge api returns required: false', function () { | ||
describe('when the challenge api returns required: false for signup', function () { | ||
beforeEach(function (done) { | ||
h.stubGetChallenge({ | ||
required: false | ||
h.stubGetChallenge([svgCaptchaRequiredResponse1, svgCaptchaRequiredResponse2]); | ||
h.stubGetSignupChallenge({ required: false }); | ||
this.lock = h.displayLock('', lockOpts, () => { | ||
h.clickSignUpTab(); | ||
h.waitUntilExists(this.lock, '.auth0-lock-with-terms', () => { | ||
done(); | ||
}); | ||
}); | ||
this.lock = h.displayLock('', lockOpts, done); | ||
}); | ||
|
||
afterEach(function () { | ||
|
@@ -110,7 +114,7 @@ describe('captcha on signup', function () { | |
}); | ||
|
||
h.waitForEmailAndPasswordInput(this.lock, () => { | ||
h.stubGetChallenge(svgCaptchaRequiredResponse1); | ||
h.stubGetSignupChallenge(svgCaptchaRequiredResponse1); | ||
h.fillEmailInput(this.lock, '[email protected]'); | ||
h.fillComplexPassword(this.lock); | ||
h.submitForm(this.lock); | ||
|
@@ -127,8 +131,14 @@ describe('captcha on signup', function () { | |
describe('recaptcha', () => { | ||
describe('when the api returns a new challenge', function () { | ||
beforeEach(function (done) { | ||
this.stub = h.stubGetChallenge([recaptchav2Response]); | ||
this.lock = h.displayLock('', lockOpts, done); | ||
this.stub = h.stubGetChallenge({ required: false }); | ||
this.stub = h.stubGetSignupChallenge([recaptchav2Response]); | ||
this.lock = h.displayLock('', lockOpts, () => { | ||
h.clickSignUpTab(); | ||
h.waitUntilExists(this.lock, '.auth0-lock-with-terms', () => { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
|
@@ -156,12 +166,17 @@ describe('captcha on signup', function () { | |
}); | ||
|
||
describe('when the challenge api returns required: false', function () { | ||
let notRequiredStub; | ||
let notRequiredStub | ||
let loginGetChallengeStub; | ||
beforeEach(function (done) { | ||
notRequiredStub = h.stubGetChallenge({ | ||
required: false | ||
loginGetChallengeStub = h.stubGetChallenge([recaptchav2Response]); | ||
notRequiredStub = h.stubGetSignupChallenge({ required: false }); | ||
this.lock = h.displayLock('', lockOpts, () => { | ||
h.clickSignUpTab(); | ||
h.waitUntilExists(this.lock, '.auth0-lock-with-terms', () => { | ||
done(); | ||
}); | ||
}); | ||
this.lock = h.displayLock('', lockOpts, done); | ||
}); | ||
|
||
afterEach(function () { | ||
|
@@ -181,7 +196,7 @@ describe('captcha on signup', function () { | |
setTimeout(done, 260); | ||
}); | ||
|
||
challengeStub = h.stubGetChallenge(recaptchav2Response); | ||
challengeStub = h.stubGetSignupChallenge([recaptchav2Response]); | ||
h.fillEmailInput(this.lock, '[email protected]'); | ||
h.fillComplexPassword(this.lock); | ||
h.submitForm(this.lock); | ||
|
@@ -190,6 +205,7 @@ describe('captcha on signup', function () { | |
it('should call the challenge api again and show the input', function () { | ||
expect(notRequiredStub.calledOnce).to.be.true; | ||
expect(challengeStub.calledOnce).to.be.true; | ||
expect(loginGetChallengeStub.calledOnce).to.be.false; | ||
expect(h.q(this.lock, '.auth0-lock-recaptchav2')).to.be.ok(); | ||
}); | ||
}); | ||
|
Oops, something went wrong.