-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IAMRISK-3553] Swapped CAPTCHA on each reload (#2560)
### Changes Exactly the same as #2558 , but without package.json version bump. --------- Co-authored-by: Tre Moore <[email protected]> Co-authored-by: Josh Cain <[email protected]>
- Loading branch information
1 parent
c342929
commit 5883544
Showing
2 changed files
with
140 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
import Immutable, { List, Map } from 'immutable'; | ||
import { signUp } from '../../../connection/database/actions'; | ||
import { | ||
signUp, | ||
resetPasswordSuccess, | ||
showResetPasswordActivity, | ||
showLoginActivity, showSignUpActivity | ||
} from '../../../connection/database/actions'; | ||
import { swap, setEntity } from '../../../store'; | ||
import { swapCaptcha } from "../../../connection/captcha"; | ||
|
||
const webApiMock = () => require('core/web_api'); | ||
const coreActionsMock = () => require('core/actions'); | ||
|
||
jest.mock('core/actions', () => ({ | ||
validateAndSubmit: jest.fn() | ||
})); | ||
|
||
jest.mock('../../../connection/captcha', () => { | ||
const originalCaptcha = jest.requireActual('../../../connection/captcha'); | ||
return { | ||
__esModule: true, | ||
...originalCaptcha, | ||
swapCaptcha: jest.fn((id, flow, wasInvalid, next) => { | ||
next(); | ||
}), | ||
} | ||
}); | ||
|
||
jest.mock('core/web_api', () => ({ | ||
signUp: jest.fn() | ||
})); | ||
|
@@ -208,4 +226,85 @@ describe('database/actions.js', () => { | |
} | ||
}); | ||
}); | ||
}); | ||
|
||
describe('exported functions', () => { | ||
const id = 2; | ||
const mCaptcha = Immutable.fromJS({ | ||
field: { | ||
email: { | ||
value: '[email protected]' | ||
}, | ||
password: { | ||
value: 'testpass' | ||
}, | ||
family_name: { | ||
value: 'test-family-name' | ||
}, | ||
given_name: { | ||
value: 'test-given-name' | ||
}, | ||
name: { | ||
value: 'test-name' | ||
}, | ||
nickname: { | ||
value: 'test-nickname' | ||
}, | ||
picture: { | ||
value: 'test-pic' | ||
}, | ||
other_prop: { | ||
value: 'test-other' | ||
} | ||
}, | ||
database: { | ||
additionalSignUpFields: [ | ||
{ name: 'family_name', storage: 'root' }, | ||
{ name: 'given_name', storage: 'root' }, | ||
{ name: 'name', storage: 'root' }, | ||
{ name: 'nickname', storage: 'root' }, | ||
{ name: 'picture', storage: 'root' }, | ||
{ name: 'other_prop' } | ||
] | ||
}, | ||
captcha: { | ||
provider: 'auth0' | ||
}, | ||
passwordResetCaptcha: { | ||
provider: 'auth0' | ||
}, | ||
}); | ||
|
||
describe('resetPasswordSuccess', () => { | ||
it('runs swap CAPTCHA', () => { | ||
swap(setEntity, 'lock', id, mCaptcha); | ||
resetPasswordSuccess(id); | ||
expect(swapCaptcha.mock.calls.length).toEqual(1); | ||
}); | ||
}); | ||
|
||
describe('showResetPasswordActivity', () => { | ||
it('runs swap CAPTCHA', () => { | ||
swap(setEntity, 'lock', id, mCaptcha); | ||
showResetPasswordActivity(id); | ||
expect(swapCaptcha.mock.calls.length).toEqual(1); | ||
}); | ||
}); | ||
|
||
describe('showLoginActivity', () => { | ||
it('runs swap CAPTCHA', () => { | ||
swap(setEntity, 'lock', id, mCaptcha); | ||
showLoginActivity(id); | ||
expect(swapCaptcha.mock.calls.length).toEqual(1); | ||
}); | ||
}); | ||
|
||
describe('showSignupActivity', () => { | ||
it('runs swap CAPTCHA', () => { | ||
swap(setEntity, 'lock', id, mCaptcha); | ||
showSignUpActivity(id); | ||
expect(swapCaptcha.mock.calls.length).toEqual(1); | ||
}); | ||
}); | ||
}); | ||
}) | ||
|
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