-
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.
[IAMRISK-2603] Add support for Arkose (#2455)
- Loading branch information
1 parent
72007c7
commit d4be17e
Showing
13 changed files
with
223 additions
and
175 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
11 changes: 11 additions & 0 deletions
11
src/__tests__/field/captcha/__snapshots__/arkose.test.jsx.snap
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Arkose should match the snapshot 1`] = ` | ||
<div | ||
className="auth0-lock-arkose-block auth0-lock-arkose-block-error" | ||
> | ||
<div | ||
className="auth0-lock-arkose" | ||
/> | ||
</div> | ||
`; |
10 changes: 9 additions & 1 deletion
10
src/__tests__/field/captcha/__snapshots__/friendlyCaptcha.test.jsx.snap
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,3 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`friendly captcha should match the snapshot 1`] = `ShallowWrapper {}`; | ||
exports[`friendly captcha should match the snapshot 1`] = ` | ||
<div | ||
className="auth0-lock-friendly-captcha-block auth0-lock-friendly-captcha-block-error" | ||
> | ||
<div | ||
className="auth0-lock-friendly-captcha" | ||
/> | ||
</div> | ||
`; |
10 changes: 9 additions & 1 deletion
10
src/__tests__/field/captcha/__snapshots__/hcaptcha.test.jsx.snap
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,3 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`hCaptcha should match the snapshot 1`] = `ShallowWrapper {}`; | ||
exports[`hCaptcha should match the snapshot 1`] = ` | ||
<div | ||
className="auth0-lock-hcaptcha-block auth0-lock-hcaptcha-block-error" | ||
> | ||
<div | ||
className="auth0-lock-hcaptcha" | ||
/> | ||
</div> | ||
`; |
10 changes: 9 additions & 1 deletion
10
src/__tests__/field/captcha/__snapshots__/recaptcha_enterprise.test.jsx.snap
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,3 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Recaptcha Enterprise should match the snapshot 1`] = `ShallowWrapper {}`; | ||
exports[`Recaptcha Enterprise should match the snapshot 1`] = ` | ||
<div | ||
className="auth0-lock-recaptcha-block auth0-lock-recaptcha-block-error" | ||
> | ||
<div | ||
className="auth0-lock-recaptchav2" | ||
/> | ||
</div> | ||
`; |
10 changes: 9 additions & 1 deletion
10
src/__tests__/field/captcha/__snapshots__/recaptchav2.test.jsx.snap
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,3 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Recaptcha v2 should match the snapshot 1`] = `ShallowWrapper {}`; | ||
exports[`Recaptcha v2 should match the snapshot 1`] = ` | ||
<div | ||
className="auth0-lock-recaptcha-block auth0-lock-recaptcha-block-error" | ||
> | ||
<div | ||
className="auth0-lock-recaptchav2" | ||
/> | ||
</div> | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { expectComponent } from 'testUtils'; | ||
import { ThirdPartyCaptcha } from '../../../field/captcha/third_party_captcha'; | ||
|
||
describe('Arkose', () => { | ||
const component = <ThirdPartyCaptcha provider={'arkose'} hl='en' sitekey={'mySiteKey'} clientSubdomain={'client-api'} />; | ||
|
||
it('should match the snapshot', () => { | ||
expectComponent(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('injects the script', () => { | ||
const script = [...window.document.querySelectorAll('script')].find(s => s.src.startsWith("https://client-api.arkoselabs.com/v2/mySiteKey/api.js")); | ||
expect(script).not.toBeUndefined(); | ||
}); | ||
}); |
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,45 +1,16 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import I from 'immutable'; | ||
|
||
import { expectComponent } from 'testUtils'; | ||
import { ThirdPartyCaptcha } from '../../../field/captcha/third_party_captcha'; | ||
|
||
const createLockMock = ({ provider = 'none', sitekey = '' } = {}) => | ||
I.fromJS({ | ||
id: '__lock-id__', | ||
core: { | ||
captcha: { provider, sitekey }, | ||
transient: { | ||
ui: { | ||
language: 'en-US' | ||
} | ||
} | ||
} | ||
}); | ||
|
||
describe('friendly captcha', () => { | ||
const wrapper = <ThirdPartyCaptcha provider={'friendly_captcha'} hl='en' sitekey={'mySiteKey'} />; | ||
|
||
it('should match the snapshot', () => { | ||
const mockLock = createLockMock({ provider: 'friendly_captcha', sitekey: 'mySiteKey' }); | ||
const wrapper = shallow( | ||
<ThirdPartyCaptcha provider={'friendly_captcha'} lock={mockLock} sitekey={'mySiteKey'} /> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
expectComponent(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
describe('render', () => { | ||
beforeAll(() => { | ||
document.body.innerHTML = "<div id='renderTest'></div>"; | ||
}); | ||
afterAll(() => { | ||
document.getElementById('renderTest').remove(); | ||
}); | ||
it('injects the script', () => { | ||
ThirdPartyCaptcha.loadScript({ hl: 'en-US', provider: 'friendly_captcha' }, document.body); | ||
expect(document.body.innerHTML).toContain('<div id="renderTest">'); | ||
expect(document.body.innerHTML).toContain( | ||
'<script src="https://cdn.jsdelivr.net/npm/[email protected]/widget.min.js' | ||
); | ||
}); | ||
it('injects the script', () => { | ||
const script = [...window.document.querySelectorAll('script')].find(s => s.src.startsWith("https://cdn.jsdelivr.net/npm/[email protected]/widget.min.js")); | ||
expect(script).not.toBeUndefined(); | ||
}); | ||
}); |
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,45 +1,16 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import I from 'immutable'; | ||
|
||
import { expectComponent } from 'testUtils'; | ||
import { ThirdPartyCaptcha } from '../../../field/captcha/third_party_captcha'; | ||
|
||
const createLockMock = ({ provider = 'none', sitekey = '' } = {}) => | ||
I.fromJS({ | ||
id: '__lock-id__', | ||
core: { | ||
captcha: { provider, sitekey }, | ||
transient: { | ||
ui: { | ||
language: 'en-US' | ||
} | ||
} | ||
} | ||
}); | ||
|
||
describe('hCaptcha', () => { | ||
const component = <ThirdPartyCaptcha provider={'hcaptcha'} hl='en' sitekey={'mySiteKey'} />; | ||
|
||
it('should match the snapshot', () => { | ||
const mockLock = createLockMock({ provider: 'hcaptcha', sitekey: 'mySiteKey' }); | ||
const wrapper = shallow( | ||
<ThirdPartyCaptcha provider={'hcaptcha'} lock={mockLock} sitekey={'mySiteKey'} /> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
expectComponent(component).toMatchSnapshot(); | ||
}); | ||
|
||
describe('render', () => { | ||
beforeAll(() => { | ||
document.body.innerHTML = "<div id='renderTest'></div>"; | ||
}); | ||
afterAll(() => { | ||
document.getElementById('renderTest').remove(); | ||
}); | ||
it('injects the script', () => { | ||
ThirdPartyCaptcha.loadScript({ hl: 'en-US', provider: 'hcaptcha' }, document.body); | ||
expect(document.body.innerHTML).toContain('<div id="renderTest">'); | ||
expect(document.body.innerHTML).toContain( | ||
'<script src="https://js.hcaptcha.com/1/api.js?hl=en-US' | ||
); | ||
}); | ||
it('injects the script', () => { | ||
const script = [...window.document.querySelectorAll('script')].find(s => s.src.startsWith("https://js.hcaptcha.com/1/api.js")); | ||
expect(script).not.toBeUndefined(); | ||
}); | ||
}); |
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,45 +1,16 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import I from 'immutable'; | ||
|
||
import { expectComponent } from 'testUtils'; | ||
import { ThirdPartyCaptcha } from '../../../field/captcha/third_party_captcha'; | ||
|
||
const createLockMock = ({ provider = 'none', sitekey = '' } = {}) => | ||
I.fromJS({ | ||
id: '__lock-id__', | ||
core: { | ||
captcha: { provider, sitekey }, | ||
transient: { | ||
ui: { | ||
language: 'en-US' | ||
} | ||
} | ||
} | ||
}); | ||
|
||
describe('Recaptcha Enterprise', () => { | ||
const component = <ThirdPartyCaptcha provider={'recaptcha_enterprise'} hl='en' sitekey={'mySiteKey'} />; | ||
|
||
it('should match the snapshot', () => { | ||
const mockLock = createLockMock({ provider: 'recaptcha_enterprise', sitekey: 'mySiteKey' }); | ||
const wrapper = shallow( | ||
<ThirdPartyCaptcha provider={'recaptcha_enterprise'} lock={mockLock} sitekey={'mySiteKey'} /> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
expectComponent(component).toMatchSnapshot(); | ||
}); | ||
|
||
describe('render', () => { | ||
beforeAll(() => { | ||
document.body.innerHTML = "<div id='renderTest'></div>"; | ||
}); | ||
afterAll(() => { | ||
document.getElementById('renderTest').remove(); | ||
}); | ||
it('injects the script', () => { | ||
ThirdPartyCaptcha.loadScript({ hl: 'en-US', provider: 'recaptcha_enterprise' }, document.body); | ||
expect(document.body.innerHTML).toContain('<div id="renderTest">'); | ||
expect(document.body.innerHTML).toContain( | ||
'<script src="https://www.recaptcha.net/recaptcha/enterprise.js?render=explicit' | ||
); | ||
}); | ||
it('injects the script', () => { | ||
const script = [...window.document.querySelectorAll('script')].find(s => s.src.startsWith("https://www.recaptcha.net/recaptcha/enterprise.js")); | ||
expect(script).not.toBeUndefined(); | ||
}); | ||
}); |
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,45 +1,16 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import I from 'immutable'; | ||
|
||
import { expectComponent } from 'testUtils'; | ||
import { ThirdPartyCaptcha } from '../../../field/captcha/third_party_captcha'; | ||
|
||
const createLockMock = ({ provider = 'none', sitekey = '' } = {}) => | ||
I.fromJS({ | ||
id: '__lock-id__', | ||
core: { | ||
captcha: { provider, sitekey }, | ||
transient: { | ||
ui: { | ||
language: 'en-US' | ||
} | ||
} | ||
} | ||
}); | ||
|
||
describe('Recaptcha v2', () => { | ||
const component = <ThirdPartyCaptcha provider={'recaptcha_v2'} hl='en' sitekey={'mySiteKey'} />; | ||
|
||
it('should match the snapshot', () => { | ||
const mockLock = createLockMock({ provider: 'recaptcha_v2', sitekey: 'mySiteKey' }); | ||
const wrapper = shallow( | ||
<ThirdPartyCaptcha provider={'recaptcha_v2'} lock={mockLock} sitekey={'mySiteKey'} /> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
expectComponent(component).toMatchSnapshot(); | ||
}); | ||
|
||
describe('render', () => { | ||
beforeAll(() => { | ||
document.body.innerHTML = "<div id='renderTest'></div>"; | ||
}); | ||
afterAll(() => { | ||
document.getElementById('renderTest').remove(); | ||
}); | ||
it('injects the script', () => { | ||
ThirdPartyCaptcha.loadScript({ hl: 'en-US', provider: 'recaptcha_v2' }, document.body); | ||
expect(document.body.innerHTML).toContain('<div id="renderTest">'); | ||
expect(document.body.innerHTML).toContain( | ||
'<script src="https://www.recaptcha.net/recaptcha/api.js?hl=en-US' | ||
); | ||
}); | ||
it('injects the script', () => { | ||
const script = [...window.document.querySelectorAll('script')].find(s => s.src.startsWith("https://www.recaptcha.net/recaptcha/api.js")); | ||
expect(script).not.toBeUndefined(); | ||
}); | ||
}); |
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
Oops, something went wrong.