-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDK-2970] Remove captcha for enterprise SSO connections (#2071)
* Hide captcha for SSO connections in login pane * Add tests for sign-up pane + captcha * Add tests for login pane + captcha * Modify browserstack settings (rolls in #2065) Co-authored-by: Adam Mcgrath <[email protected]>
- Loading branch information
1 parent
f13a5ab
commit 6e5b27d
Showing
16 changed files
with
824 additions
and
467 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
129 changes: 129 additions & 0 deletions
129
src/__tests__/connection/database/__snapshots__/login_pane.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,129 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`LoginPane hides the captcha for SSO connections 1`] = ` | ||
<div> | ||
<UsernamePane | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
strictValidation={false} | ||
usernameStyle="username" | ||
validateFormat={false} | ||
/> | ||
<PasswordPane | ||
hidden={false} | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`LoginPane renders a captcha 1`] = ` | ||
<div> | ||
<UsernamePane | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
strictValidation={false} | ||
usernameStyle="username" | ||
validateFormat={false} | ||
/> | ||
<PasswordPane | ||
hidden={false} | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
/> | ||
<CaptchaPane | ||
error={false} | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
onReload={[Function]} | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`LoginPane renders correctly 1`] = ` | ||
<div> | ||
<UsernamePane | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
strictValidation={false} | ||
usernameStyle="username" | ||
validateFormat={false} | ||
/> | ||
<PasswordPane | ||
hidden={false} | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`LoginPane shows the captcha for SSO (ADFS) connections 1`] = ` | ||
<div> | ||
<UsernamePane | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
strictValidation={false} | ||
usernameStyle="username" | ||
validateFormat={false} | ||
/> | ||
<PasswordPane | ||
hidden={false} | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
placeholder="" | ||
/> | ||
<CaptchaPane | ||
error={false} | ||
i18n={Object {}} | ||
lock={ | ||
Immutable.Map { | ||
"id": "__lock-id__", | ||
} | ||
} | ||
onReload={[Function]} | ||
/> | ||
</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,67 @@ | ||
import React from 'react'; | ||
import I from 'immutable'; | ||
import { expectShallowComponent } from 'testUtils'; | ||
import LoginPane from '../../../connection/database/login_pane'; | ||
|
||
const lock = I.fromJS({ id: '__lock-id__' }); | ||
|
||
jest.mock('core/index'); | ||
|
||
jest.mock('engine/classic'); | ||
jest.mock('connection/enterprise'); | ||
|
||
describe('LoginPane', () => { | ||
const defaultProps = { | ||
emailInputPlaceholder: '', | ||
forgotPasswordAction: '', | ||
i18n: {}, | ||
passwordInputPlaceholder: '', | ||
showForgotPasswordLink: true, | ||
showPassword: true, | ||
usernameInputPlaceholder: '', | ||
lock | ||
}; | ||
|
||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
it('renders correctly', async () => { | ||
expectShallowComponent(<LoginPane {...defaultProps} />).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders a captcha', () => { | ||
require('core/index').captcha.mockReturnValue({ | ||
get() { | ||
return true; | ||
} | ||
}); | ||
|
||
expectShallowComponent(<LoginPane {...defaultProps} />).toMatchSnapshot(); | ||
}); | ||
|
||
it('hides the captcha for SSO connections', () => { | ||
require('core/index').captcha.mockReturnValue({ | ||
get() { | ||
return true; | ||
} | ||
}); | ||
|
||
require('engine/classic').isSSOEnabled.mockReturnValue(true); | ||
|
||
expectShallowComponent(<LoginPane {...defaultProps} />).toMatchSnapshot(); | ||
}); | ||
|
||
it('shows the captcha for SSO (ADFS) connections', () => { | ||
require('core/index').captcha.mockReturnValue({ | ||
get() { | ||
return true; | ||
} | ||
}); | ||
|
||
require('engine/classic').isSSOEnabled.mockReturnValue(true); | ||
require('connection/enterprise').isHRDDomain.mockReturnValue(true); | ||
|
||
expectShallowComponent(<LoginPane {...defaultProps} />).toMatchSnapshot(); | ||
}); | ||
}); |
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,7 +4,8 @@ import * as l from '../../../core/index'; | |
import { setField } from '../../../field/index'; | ||
|
||
jest.mock('connection/database/index', () => ({ | ||
databaseLogInWithEmail: jest.fn(() => true) | ||
databaseLogInWithEmail: jest.fn(() => true), | ||
databaseUsernameValue: jest.fn() | ||
})); | ||
|
||
jest.mock('store/index', () => ({ | ||
|
@@ -17,7 +18,8 @@ jest.mock('store/index', () => ({ | |
jest.mock('connection/enterprise', () => ({ | ||
matchConnection: jest.fn(), | ||
enterpriseActiveFlowConnection: jest.fn(), | ||
isHRDActive: jest.fn() | ||
isHRDActive: jest.fn(), | ||
isEnterpriseDomain: jest.fn() | ||
})); | ||
|
||
jest.mock('core/actions', () => ({ | ||
|
@@ -65,10 +67,12 @@ describe('Login with connection scopes', () => { | |
}); | ||
}); | ||
|
||
it('should throw an error if the captcha was not completed', () => { | ||
it('should not throw an error if the captcha was not completed', () => { | ||
lock = l.setup('__lock__', 'client', 'domain', {}); | ||
lock = setField(lock, 'email', '[email protected]'); | ||
|
||
// This will be specified in the response from the /challenge endpoint if the | ||
// dashboard settings have Captcha as 'required', regardless of connection being used. | ||
lock = l.setCaptcha(lock, { | ||
required: true, | ||
provider: 'recaptcha_v2' | ||
|
@@ -83,7 +87,7 @@ describe('Login with connection scopes', () => { | |
const coreActions = require('core/actions'); | ||
|
||
logIn('__lock__'); | ||
expect(coreActions.logIn).not.toHaveBeenCalled(); | ||
expect(coreActions.logIn).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
|
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
Oops, something went wrong.