auth0-lock 11.34.2 → 12.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +1 -0
- package/.circleci/config.yml +4 -2
- package/.eslintrc.json +5 -5
- package/.github/workflows/codeql.yml +41 -0
- package/.shiprc +4 -5
- package/CHANGELOG.md +26 -0
- package/EXAMPLES.md +626 -0
- package/README.md +77 -649
- package/karma.conf.js +1 -1
- package/lib/CSSCore.js +1 -4
- package/lib/__tests__/auth_button.js +12 -22
- package/lib/__tests__/connection/database/actions.js +48 -49
- package/lib/__tests__/connection/database/index.js +22 -28
- package/lib/__tests__/connection/database/login_pane.js +20 -41
- package/lib/__tests__/connection/database/password_reset_confirmation.js +19 -26
- package/lib/__tests__/connection/database/reset_password.js +17 -39
- package/lib/__tests__/connection/database/signed_up_confirmation.js +19 -26
- package/lib/__tests__/connection/enterprise/actions.js +22 -47
- package/lib/__tests__/connection/enterprise/hrd_pane.js +16 -33
- package/lib/__tests__/connection/enterprise/hrd_screen.js +26 -40
- package/lib/__tests__/connection/enterprise/quick_auth_screen.js +27 -68
- package/lib/__tests__/connection/passwordless/ask_vcode.js +29 -51
- package/lib/__tests__/connection/passwordless/email_sent_confirmation.js +19 -26
- package/lib/__tests__/connection/passwordless/passwordless.js +35 -97
- package/lib/__tests__/core/actions.js +23 -46
- package/lib/__tests__/core/client/index.js +10 -13
- package/lib/__tests__/core/index.js +46 -94
- package/lib/__tests__/core/remote_data.js +14 -20
- package/lib/__tests__/core/signed_in_confirmation.js +19 -26
- package/lib/__tests__/core/sso/last_login_screen.js +27 -50
- package/lib/__tests__/core/tenant.js +10 -12
- package/lib/__tests__/core/web_api/helper.js +6 -14
- package/lib/__tests__/core/web_api/p2_api.js +38 -33
- package/lib/__tests__/core/web_api.js +37 -33
- package/lib/__tests__/engine/classic/login.js +20 -41
- package/lib/__tests__/engine/classic/mfa_login_screen.js +6 -19
- package/lib/__tests__/engine/classic/sign_up_pane.js +33 -55
- package/lib/__tests__/engine/classic/sign_up_screen.js +18 -45
- package/lib/__tests__/engine/classic.js +13 -6
- package/lib/__tests__/engine/passwordless.js +2 -5
- package/lib/__tests__/field/captcha/recaptcha_enterprise.js +27 -27
- package/lib/__tests__/field/captcha/recaptchav2.js +27 -27
- package/lib/__tests__/field/captcha.js +39 -51
- package/lib/__tests__/field/custom_input.js +23 -47
- package/lib/__tests__/field/email.js +2 -3
- package/lib/__tests__/field/email_pane.js +25 -48
- package/lib/__tests__/field/field.js +9 -13
- package/lib/__tests__/field/login_pane.js +30 -34
- package/lib/__tests__/field/mfa_code_pane.js +13 -28
- package/lib/__tests__/field/option_selection_pane.js +7 -25
- package/lib/__tests__/field/password.js +6 -12
- package/lib/__tests__/field/password_pane.js +29 -46
- package/lib/__tests__/field/phone_number_pane.js +18 -41
- package/lib/__tests__/field/social_buttons_pane.js +30 -47
- package/lib/__tests__/field/username.js +27 -48
- package/lib/__tests__/field/username_pane.js +30 -47
- package/lib/__tests__/field/vcode.js +5 -13
- package/lib/__tests__/field/vcode_pane.js +20 -44
- package/lib/__tests__/i18n.js +28 -53
- package/lib/__tests__/quick-auth/actions.js +4 -27
- package/lib/__tests__/setup-tests.js +7 -9
- package/lib/__tests__/testUtils.js +41 -58
- package/lib/__tests__/ui/box/chrome.js +24 -49
- package/lib/__tests__/ui/box/confirmation_pane.js +19 -36
- package/lib/__tests__/ui/box/container.js +21 -46
- package/lib/__tests__/ui/box/global_message.js +60 -37
- package/lib/__tests__/ui/input/email_input.js +6 -17
- package/lib/__tests__/ui/input/input_wrap.js +6 -19
- package/lib/__tests__/ui/input/password/password_strength.js +13 -15
- package/lib/__tests__/ui/input/password_input.js +22 -27
- package/lib/__tests__/utils/format.js +10 -17
- package/lib/__tests__/utils/url_utils.js +2 -5
- package/lib/avatar/gravatar_provider.js +13 -28
- package/lib/avatar.js +22 -41
- package/lib/browser.js +372 -23
- package/lib/connection/captcha.js +14 -32
- package/lib/connection/database/actions.js +39 -108
- package/lib/connection/database/index.js +90 -191
- package/lib/connection/database/login_pane.js +107 -147
- package/lib/connection/database/login_sign_up_tabs.js +106 -125
- package/lib/connection/database/mfa_pane.js +50 -69
- package/lib/connection/database/password_reset_confirmation.js +51 -73
- package/lib/connection/database/reset_password.js +116 -132
- package/lib/connection/database/reset_password_pane.js +45 -56
- package/lib/connection/database/sign_up_terms.js +17 -23
- package/lib/connection/database/signed_up_confirmation.js +52 -75
- package/lib/connection/enterprise/actions.js +23 -52
- package/lib/connection/enterprise/hrd_pane.js +60 -76
- package/lib/connection/enterprise/hrd_screen.js +60 -75
- package/lib/connection/enterprise/kerberos_screen.js +46 -60
- package/lib/connection/enterprise/quick_auth_screen.js +46 -64
- package/lib/connection/enterprise/single_sign_on_notice.js +14 -26
- package/lib/connection/enterprise.js +51 -84
- package/lib/connection/passwordless/actions.js +29 -62
- package/lib/connection/passwordless/ask_vcode.js +53 -60
- package/lib/connection/passwordless/email_sent_confirmation.js +129 -179
- package/lib/connection/passwordless/index.js +36 -68
- package/lib/connection/social/index.js +12 -15
- package/lib/core/actions.js +33 -85
- package/lib/core/client/index.js +38 -58
- package/lib/core/client/settings.js +12 -20
- package/lib/core/error_screen.js +38 -52
- package/lib/core/index.js +152 -301
- package/lib/core/loading_screen.js +61 -71
- package/lib/core/pane_separator.js +10 -10
- package/lib/core/remote_data.js +28 -48
- package/lib/core/screen.js +85 -79
- package/lib/core/signed_in_confirmation.js +51 -73
- package/lib/core/sso/data.js +9 -17
- package/lib/core/sso/index.js +5 -6
- package/lib/core/sso/last_login_screen.js +46 -63
- package/lib/core/tenant/index.js +37 -59
- package/lib/core/tenant/settings.js +11 -15
- package/lib/core/web_api/helper.js +24 -30
- package/lib/core/web_api/p2_api.js +156 -165
- package/lib/core/web_api.js +101 -90
- package/lib/core.js +126 -160
- package/lib/engine/classic/login.js +92 -144
- package/lib/engine/classic/mfa_login_screen.js +61 -67
- package/lib/engine/classic/sign_up_pane.js +89 -123
- package/lib/engine/classic/sign_up_screen.js +112 -158
- package/lib/engine/classic.js +122 -183
- package/lib/engine/passwordless/social_or_email_login_screen.js +71 -106
- package/lib/engine/passwordless/social_or_phone_number_login_screen.js +70 -100
- package/lib/engine/passwordless.js +75 -104
- package/lib/field/actions.js +11 -17
- package/lib/field/captcha/captcha_pane.js +82 -102
- package/lib/field/captcha/recaptcha.js +140 -145
- package/lib/field/captcha.js +7 -10
- package/lib/field/custom_input.js +37 -50
- package/lib/field/email/email_pane.js +90 -109
- package/lib/field/email.js +17 -35
- package/lib/field/index.js +51 -88
- package/lib/field/mfa-code/mfa_code_pane.js +57 -71
- package/lib/field/mfa_code.js +15 -21
- package/lib/field/option_selection_pane.js +16 -22
- package/lib/field/password/password_pane.js +79 -91
- package/lib/field/password.js +8 -14
- package/lib/field/phone-number/locations.js +7 -3
- package/lib/field/phone-number/phone_number_pane.js +87 -124
- package/lib/field/phone_number.js +16 -30
- package/lib/field/social/event.js +9 -12
- package/lib/field/social/social_buttons_pane.js +93 -121
- package/lib/field/username/username_pane.js +105 -123
- package/lib/field/username.js +16 -26
- package/lib/field/vcode/vcode_pane.js +67 -93
- package/lib/field/vcode.js +5 -5
- package/lib/i18n/af.js +7 -4
- package/lib/i18n/ar.js +7 -4
- package/lib/i18n/az.js +7 -4
- package/lib/i18n/bg.js +7 -4
- package/lib/i18n/ca.js +7 -4
- package/lib/i18n/cs.js +7 -4
- package/lib/i18n/da.js +7 -4
- package/lib/i18n/de.js +7 -3
- package/lib/i18n/el.js +7 -4
- package/lib/i18n/en.js +9 -4
- package/lib/i18n/es.js +7 -3
- package/lib/i18n/et.js +7 -4
- package/lib/i18n/fa.js +7 -4
- package/lib/i18n/fi.js +7 -4
- package/lib/i18n/fr.js +7 -4
- package/lib/i18n/he.js +7 -4
- package/lib/i18n/hr.js +7 -4
- package/lib/i18n/hu.js +7 -4
- package/lib/i18n/id.js +7 -4
- package/lib/i18n/it.js +7 -3
- package/lib/i18n/ja.js +7 -4
- package/lib/i18n/ko.js +7 -4
- package/lib/i18n/lt.js +7 -4
- package/lib/i18n/lv.js +7 -4
- package/lib/i18n/ms.js +7 -4
- package/lib/i18n/nb.js +7 -4
- package/lib/i18n/nl.js +7 -4
- package/lib/i18n/nn.js +7 -4
- package/lib/i18n/no.js +7 -4
- package/lib/i18n/pl.js +7 -4
- package/lib/i18n/pt-br.js +7 -3
- package/lib/i18n/pt.js +7 -4
- package/lib/i18n/ro.js +7 -4
- package/lib/i18n/ru.js +7 -4
- package/lib/i18n/sk.js +7 -4
- package/lib/i18n/sl.js +7 -4
- package/lib/i18n/sr.js +7 -4
- package/lib/i18n/sv.js +7 -4
- package/lib/i18n/tr.js +7 -4
- package/lib/i18n/ua.js +7 -4
- package/lib/i18n/uk.js +7 -4
- package/lib/i18n/vi.js +7 -4
- package/lib/i18n/zh-tw.js +7 -4
- package/lib/i18n/zh.js +7 -4
- package/lib/i18n.js +38 -75
- package/lib/index.js +14 -17
- package/lib/lock.js +29 -32
- package/lib/passwordless.js +29 -31
- package/lib/quick-auth/actions.js +19 -26
- package/lib/quick_auth.js +8 -10
- package/lib/sanitizer.js +5 -5
- package/lib/store/index.js +22 -42
- package/lib/sync.js +21 -42
- package/lib/ui/box/button.js +85 -105
- package/lib/ui/box/chrome.js +463 -548
- package/lib/ui/box/confirmation_pane.js +34 -48
- package/lib/ui/box/container.js +305 -339
- package/lib/ui/box/global_message.js +51 -60
- package/lib/ui/box/header.js +155 -177
- package/lib/ui/box/multisize_slide.js +233 -229
- package/lib/ui/box/success_pane.js +34 -37
- package/lib/ui/box.js +88 -93
- package/lib/ui/button/auth_button.js +44 -51
- package/lib/ui/input/captcha_input.js +162 -181
- package/lib/ui/input/checkbox_input.js +57 -59
- package/lib/ui/input/email_input.js +117 -124
- package/lib/ui/input/input_wrap.js +65 -80
- package/lib/ui/input/location_input.js +130 -150
- package/lib/ui/input/mfa_code_input.js +98 -98
- package/lib/ui/input/password/password_strength.js +103 -127
- package/lib/ui/input/password_input.js +141 -147
- package/lib/ui/input/phone_number_input.js +101 -109
- package/lib/ui/input/select_input.js +120 -132
- package/lib/ui/input/text_input.js +89 -84
- package/lib/ui/input/username_input.js +109 -115
- package/lib/ui/input/vcode_input.js +110 -118
- package/lib/ui/list.js +224 -247
- package/lib/ui/pane/quick_auth_pane.js +55 -80
- package/lib/utils/atom.js +55 -48
- package/lib/utils/cache.js +54 -43
- package/lib/utils/cdn_utils.js +17 -31
- package/lib/utils/createRef.js +3 -1
- package/lib/utils/data_utils.js +10 -16
- package/lib/utils/fn_utils.js +5 -4
- package/lib/utils/format.js +6 -8
- package/lib/utils/id_utils.js +4 -3
- package/lib/utils/jsonp_utils.js +20 -17
- package/lib/utils/media_utils.js +4 -2
- package/lib/utils/preload_utils.js +4 -3
- package/lib/utils/string_utils.js +4 -4
- package/lib/utils/url_utils.js +4 -3
- package/opslevel.yml +6 -0
- package/package.json +53 -38
- package/webpack.config.js +36 -3
package/karma.conf.js
CHANGED
package/lib/CSSCore.js
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
* display and not reading it as no logical state should be encoded in the
|
|
17
17
|
* display of elements.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
var CSSCore = {
|
|
21
20
|
/**
|
|
22
21
|
* Adds the class passed in to the element if it doesn't already have it.
|
|
@@ -35,7 +34,6 @@ var CSSCore = {
|
|
|
35
34
|
}
|
|
36
35
|
return element;
|
|
37
36
|
},
|
|
38
|
-
|
|
39
37
|
/**
|
|
40
38
|
* Removes the class passed in from the element
|
|
41
39
|
*
|
|
@@ -52,9 +50,9 @@ var CSSCore = {
|
|
|
52
50
|
.replace(/^\s*|\s*$/g, ''); // trim the ends
|
|
53
51
|
}
|
|
54
52
|
}
|
|
53
|
+
|
|
55
54
|
return element;
|
|
56
55
|
},
|
|
57
|
-
|
|
58
56
|
/**
|
|
59
57
|
* Tests whether the element has the class specified.
|
|
60
58
|
*
|
|
@@ -69,5 +67,4 @@ var CSSCore = {
|
|
|
69
67
|
return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1;
|
|
70
68
|
}
|
|
71
69
|
};
|
|
72
|
-
|
|
73
70
|
module.exports = CSSCore;
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
4
|
-
|
|
5
|
-
var _react = require('react');
|
|
6
|
-
|
|
7
|
-
var _react2 = _interopRequireDefault(_react);
|
|
8
|
-
|
|
9
|
-
var _enzyme = require('enzyme');
|
|
10
|
-
|
|
11
|
-
var _testUtils = require('testUtils');
|
|
12
|
-
|
|
13
|
-
var _auth_button = require('ui/button/auth_button');
|
|
14
|
-
|
|
15
|
-
var _auth_button2 = _interopRequireDefault(_auth_button);
|
|
1
|
+
"use strict";
|
|
16
2
|
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _enzyme = require("enzyme");
|
|
5
|
+
var _testUtils = require("testUtils");
|
|
6
|
+
var _auth_button = _interopRequireDefault(require("ui/button/auth_button"));
|
|
17
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
8
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
9
|
describe('AuthButton', function () {
|
|
20
10
|
var defaultProps = {
|
|
21
11
|
label: 'label',
|
|
@@ -23,17 +13,17 @@ describe('AuthButton', function () {
|
|
|
23
13
|
strategy: 'strategy'
|
|
24
14
|
};
|
|
25
15
|
it('renders correctly', function () {
|
|
26
|
-
(0, _testUtils.expectComponent)(
|
|
16
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(_auth_button.default, defaultProps)).toMatchSnapshot();
|
|
27
17
|
});
|
|
28
18
|
it('renders with style customizations', function () {
|
|
29
|
-
(0, _testUtils.expectComponent)(
|
|
30
|
-
icon:
|
|
31
|
-
primaryColor:
|
|
32
|
-
foregroundColor:
|
|
19
|
+
(0, _testUtils.expectComponent)( /*#__PURE__*/_react.default.createElement(_auth_button.default, _extends({}, defaultProps, {
|
|
20
|
+
icon: "test",
|
|
21
|
+
primaryColor: "primaryColor",
|
|
22
|
+
foregroundColor: "foregroundColor"
|
|
33
23
|
}))).toMatchSnapshot();
|
|
34
24
|
});
|
|
35
25
|
it('should trigger onClick when clicked', function () {
|
|
36
|
-
var wrapper = (0, _enzyme.mount)(
|
|
26
|
+
var wrapper = (0, _enzyme.mount)( /*#__PURE__*/_react.default.createElement(_auth_button.default, defaultProps));
|
|
37
27
|
wrapper.find('a').simulate('click');
|
|
38
28
|
expect(defaultProps.onClick.mock.calls.length).toBe(1);
|
|
39
29
|
});
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
var _store = require('../../../store');
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
var _immutable = _interopRequireWildcard(require("immutable"));
|
|
5
|
+
var _actions = require("../../../connection/database/actions");
|
|
6
|
+
var _store = require("../../../store");
|
|
7
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
9
|
var webApiMock = function webApiMock() {
|
|
14
10
|
return require('core/web_api');
|
|
15
11
|
};
|
|
@@ -21,32 +17,27 @@ jest.mock('core/actions', function () {
|
|
|
21
17
|
validateAndSubmit: jest.fn()
|
|
22
18
|
};
|
|
23
19
|
});
|
|
24
|
-
|
|
25
20
|
jest.mock('core/web_api', function () {
|
|
26
21
|
return {
|
|
27
22
|
signUp: jest.fn()
|
|
28
23
|
};
|
|
29
24
|
});
|
|
30
|
-
|
|
31
25
|
describe('database/actions.js', function () {
|
|
32
26
|
beforeEach(function () {
|
|
33
27
|
jest.resetAllMocks();
|
|
34
28
|
});
|
|
35
|
-
|
|
36
29
|
it('signUp splits root attributes correctly', function () {
|
|
37
30
|
var id = 1;
|
|
38
31
|
var hookRunner = jest.fn(function (str, m, context, fn) {
|
|
39
32
|
return fn();
|
|
40
33
|
});
|
|
41
|
-
|
|
42
34
|
require('connection/database/index').databaseConnectionName = function () {
|
|
43
35
|
return 'test-connection';
|
|
44
36
|
};
|
|
45
37
|
require('connection/database/index').shouldAutoLogin = function () {
|
|
46
38
|
return true;
|
|
47
39
|
};
|
|
48
|
-
|
|
49
|
-
var m = _immutable2.default.fromJS({
|
|
40
|
+
var m = _immutable.default.fromJS({
|
|
50
41
|
field: {
|
|
51
42
|
email: {
|
|
52
43
|
value: 'test@email.com'
|
|
@@ -74,7 +65,24 @@ describe('database/actions.js', function () {
|
|
|
74
65
|
}
|
|
75
66
|
},
|
|
76
67
|
database: {
|
|
77
|
-
additionalSignUpFields: [{
|
|
68
|
+
additionalSignUpFields: [{
|
|
69
|
+
name: 'family_name',
|
|
70
|
+
storage: 'root'
|
|
71
|
+
}, {
|
|
72
|
+
name: 'given_name',
|
|
73
|
+
storage: 'root'
|
|
74
|
+
}, {
|
|
75
|
+
name: 'name',
|
|
76
|
+
storage: 'root'
|
|
77
|
+
}, {
|
|
78
|
+
name: 'nickname',
|
|
79
|
+
storage: 'root'
|
|
80
|
+
}, {
|
|
81
|
+
name: 'picture',
|
|
82
|
+
storage: 'root'
|
|
83
|
+
}, {
|
|
84
|
+
name: 'other_prop'
|
|
85
|
+
}]
|
|
78
86
|
},
|
|
79
87
|
core: {
|
|
80
88
|
hookRunner: hookRunner
|
|
@@ -82,19 +90,15 @@ describe('database/actions.js', function () {
|
|
|
82
90
|
});
|
|
83
91
|
(0, _store.swap)(_store.setEntity, 'lock', id, m);
|
|
84
92
|
(0, _actions.signUp)(id);
|
|
85
|
-
|
|
86
93
|
var _coreActionsMock = coreActionsMock(),
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
validateAndSubmitMock = _coreActionsMock.validateAndSubmit.mock;
|
|
89
95
|
expect(validateAndSubmitMock.calls.length).toBe(1);
|
|
90
96
|
expect(validateAndSubmitMock.calls[0][0]).toBe(id);
|
|
91
97
|
expect(validateAndSubmitMock.calls[0][1]).toContain('email');
|
|
92
98
|
expect(validateAndSubmitMock.calls[0][1]).toContain('password');
|
|
93
99
|
validateAndSubmitMock.calls[0][2](m);
|
|
94
|
-
|
|
95
100
|
var _webApiMock = webApiMock(),
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
signUpMock = _webApiMock.signUp.mock;
|
|
98
102
|
expect(signUpMock.calls.length).toBe(1);
|
|
99
103
|
expect(signUpMock.calls[0][0]).toBe(id);
|
|
100
104
|
expect(signUpMock.calls[0][1]).toMatchObject({
|
|
@@ -112,22 +116,18 @@ describe('database/actions.js', function () {
|
|
|
112
116
|
}
|
|
113
117
|
});
|
|
114
118
|
});
|
|
115
|
-
|
|
116
119
|
it('runs the signingUp hook on signUp', function () {
|
|
117
120
|
var id = 1;
|
|
118
|
-
|
|
119
121
|
require('connection/database/index').databaseConnectionName = function () {
|
|
120
122
|
return 'test-connection';
|
|
121
123
|
};
|
|
122
124
|
require('connection/database/index').shouldAutoLogin = function () {
|
|
123
125
|
return true;
|
|
124
126
|
};
|
|
125
|
-
|
|
126
127
|
var hookRunner = jest.fn(function (str, m, context, fn) {
|
|
127
128
|
return fn();
|
|
128
129
|
});
|
|
129
|
-
|
|
130
|
-
var m = _immutable2.default.fromJS({
|
|
130
|
+
var m = _immutable.default.fromJS({
|
|
131
131
|
field: {
|
|
132
132
|
email: {
|
|
133
133
|
value: 'test@email.com'
|
|
@@ -140,31 +140,23 @@ describe('database/actions.js', function () {
|
|
|
140
140
|
hookRunner: hookRunner
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
|
-
|
|
144
143
|
(0, _store.swap)(_store.setEntity, 'lock', id, m);
|
|
145
|
-
|
|
146
144
|
(0, _actions.signUp)(id);
|
|
147
|
-
|
|
148
145
|
var _coreActionsMock2 = coreActionsMock(),
|
|
149
|
-
|
|
150
|
-
|
|
146
|
+
validateAndSubmitMock = _coreActionsMock2.validateAndSubmit.mock;
|
|
151
147
|
validateAndSubmitMock.calls[0][2](m);
|
|
152
|
-
|
|
153
148
|
var _webApiMock2 = webApiMock(),
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
signUpMock = _webApiMock2.signUp.mock;
|
|
156
150
|
expect(hookRunner).toHaveBeenCalledTimes(1);
|
|
157
151
|
expect(hookRunner).toHaveBeenCalledWith('signingUp', m, null, expect.any(Function));
|
|
158
152
|
expect(signUpMock.calls.length).toBe(1);
|
|
159
153
|
expect(signUpMock.calls[0][0]).toBe(id);
|
|
160
154
|
});
|
|
161
|
-
|
|
162
155
|
it('sanitizes additionalSignUp fields using dompurify', function () {
|
|
163
156
|
var id = 1;
|
|
164
157
|
var hookRunner = jest.fn(function (str, m, context, fn) {
|
|
165
158
|
return fn();
|
|
166
159
|
});
|
|
167
|
-
|
|
168
160
|
require('connection/database/index').databaseConnectionName = function () {
|
|
169
161
|
return 'test-connection';
|
|
170
162
|
};
|
|
@@ -174,7 +166,7 @@ describe('database/actions.js', function () {
|
|
|
174
166
|
|
|
175
167
|
// Test different fields using some examples from DOMPurify
|
|
176
168
|
// https://github.com/cure53/DOMPurify#some-purification-samples-please
|
|
177
|
-
var m =
|
|
169
|
+
var m = _immutable.default.fromJS({
|
|
178
170
|
field: {
|
|
179
171
|
email: {
|
|
180
172
|
value: 'test@email.com'
|
|
@@ -185,6 +177,7 @@ describe('database/actions.js', function () {
|
|
|
185
177
|
family_name: {
|
|
186
178
|
value: 'Test <a href="https://www.google.co.uk">Fake link</a>' // HTML but not malicious
|
|
187
179
|
},
|
|
180
|
+
|
|
188
181
|
given_name: {
|
|
189
182
|
value: '<img src=x onerror=alert(1)//>'
|
|
190
183
|
},
|
|
@@ -196,24 +189,30 @@ describe('database/actions.js', function () {
|
|
|
196
189
|
}
|
|
197
190
|
},
|
|
198
191
|
database: {
|
|
199
|
-
additionalSignUpFields: [{
|
|
192
|
+
additionalSignUpFields: [{
|
|
193
|
+
name: 'family_name',
|
|
194
|
+
storage: 'root'
|
|
195
|
+
}, {
|
|
196
|
+
name: 'given_name',
|
|
197
|
+
storage: 'root'
|
|
198
|
+
}, {
|
|
199
|
+
name: 'name',
|
|
200
|
+
storage: 'root'
|
|
201
|
+
}, {
|
|
202
|
+
name: 'other_name'
|
|
203
|
+
}]
|
|
200
204
|
},
|
|
201
205
|
core: {
|
|
202
206
|
hookRunner: hookRunner
|
|
203
207
|
}
|
|
204
208
|
});
|
|
205
|
-
|
|
206
209
|
(0, _store.swap)(_store.setEntity, 'lock', id, m);
|
|
207
210
|
(0, _actions.signUp)(id);
|
|
208
|
-
|
|
209
211
|
var _coreActionsMock3 = coreActionsMock(),
|
|
210
|
-
|
|
211
|
-
|
|
212
|
+
validateAndSubmitMock = _coreActionsMock3.validateAndSubmit.mock;
|
|
212
213
|
validateAndSubmitMock.calls[0][2](m);
|
|
213
|
-
|
|
214
214
|
var _webApiMock3 = webApiMock(),
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
signUpMock = _webApiMock3.signUp.mock;
|
|
217
216
|
expect(signUpMock.calls[0][1]).toMatchObject({
|
|
218
217
|
connection: 'test-connection',
|
|
219
218
|
email: 'test@email.com',
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _immutable = require('immutable');
|
|
4
|
-
|
|
5
|
-
var _immutable2 = _interopRequireDefault(_immutable);
|
|
6
|
-
|
|
7
|
-
var _database = require('../../../connection/database');
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
"use strict";
|
|
10
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
var _immutable = _interopRequireWildcard(require("immutable"));
|
|
5
|
+
var _database = require("../../../connection/database");
|
|
6
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
7
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
8
|
describe('database/index.js', function () {
|
|
12
9
|
describe('databaseUsernameValue', function () {
|
|
13
10
|
var getModel = function getModel(email, username, usernameRequired) {
|
|
14
|
-
return
|
|
11
|
+
return _immutable.default.fromJS({
|
|
15
12
|
field: {
|
|
16
13
|
email: {
|
|
17
14
|
value: email
|
|
@@ -31,49 +28,44 @@ describe('database/index.js', function () {
|
|
|
31
28
|
}
|
|
32
29
|
});
|
|
33
30
|
};
|
|
34
|
-
|
|
35
31
|
beforeEach(function () {
|
|
36
32
|
jest.resetAllMocks();
|
|
37
33
|
});
|
|
38
|
-
|
|
39
34
|
describe('for database connection without username required', function () {
|
|
40
35
|
var model = getModel('user@auth0.com', null, false);
|
|
41
|
-
|
|
42
36
|
it('should get the email', function () {
|
|
43
37
|
expect((0, _database.databaseUsernameValue)(model)).toEqual('user@auth0.com');
|
|
44
38
|
});
|
|
45
39
|
});
|
|
46
|
-
|
|
47
40
|
describe('for database connection with username required', function () {
|
|
48
41
|
var model = getModel('user@auth0.com', 'user', true);
|
|
49
|
-
|
|
50
42
|
it('should get the username when `emailFirst` is not set', function () {
|
|
51
43
|
expect((0, _database.databaseUsernameValue)(model)).toEqual('user');
|
|
52
44
|
});
|
|
53
45
|
it('should get the username when `emailFirst` is false', function () {
|
|
54
|
-
expect((0, _database.databaseUsernameValue)(model, {
|
|
46
|
+
expect((0, _database.databaseUsernameValue)(model, {
|
|
47
|
+
emailFirst: false
|
|
48
|
+
})).toEqual('user');
|
|
55
49
|
});
|
|
56
50
|
it('should get the email when `emailFirst` is true', function () {
|
|
57
|
-
expect((0, _database.databaseUsernameValue)(model, {
|
|
51
|
+
expect((0, _database.databaseUsernameValue)(model, {
|
|
52
|
+
emailFirst: true
|
|
53
|
+
})).toEqual('user@auth0.com');
|
|
58
54
|
});
|
|
59
|
-
|
|
60
55
|
describe('and only email address is filled in', function () {
|
|
61
56
|
var model = getModel('user@auth0.com', null, true);
|
|
62
|
-
|
|
63
57
|
it('should get the email address', function () {
|
|
64
58
|
expect((0, _database.databaseUsernameValue)(model)).toEqual('user@auth0.com');
|
|
65
59
|
});
|
|
66
60
|
});
|
|
67
61
|
});
|
|
68
62
|
});
|
|
69
|
-
|
|
70
63
|
describe('databaseUsernameStyle', function () {
|
|
71
64
|
beforeEach(function () {
|
|
72
65
|
jest.resetAllMocks();
|
|
73
66
|
});
|
|
74
|
-
|
|
75
67
|
it('it should resolve to "username" if a connectionResolver is present', function () {
|
|
76
|
-
var model =
|
|
68
|
+
var model = _immutable.default.fromJS({
|
|
77
69
|
core: {
|
|
78
70
|
connectionResolver: function connectionResolver() {
|
|
79
71
|
return true;
|
|
@@ -87,15 +79,13 @@ describe('database/index.js', function () {
|
|
|
87
79
|
}
|
|
88
80
|
}
|
|
89
81
|
});
|
|
90
|
-
|
|
91
82
|
expect((0, _database.databaseUsernameStyle)(model)).toBe('username');
|
|
92
83
|
});
|
|
93
84
|
});
|
|
94
|
-
|
|
95
85
|
describe('initDatabase', function () {
|
|
96
86
|
describe('calls initNS with the correct additionalSignUpFields', function () {
|
|
97
87
|
describe('uses the `storage` attribute', function () {
|
|
98
|
-
var model =
|
|
88
|
+
var model = _immutable.default.fromJS({});
|
|
99
89
|
var modelOut = (0, _database.initDatabase)(model, {
|
|
100
90
|
additionalSignUpFields: [{
|
|
101
91
|
type: 'hidden',
|
|
@@ -113,7 +103,7 @@ describe('database/index.js', function () {
|
|
|
113
103
|
}]);
|
|
114
104
|
});
|
|
115
105
|
describe('with a valid hidden field', function () {
|
|
116
|
-
var model =
|
|
106
|
+
var model = _immutable.default.fromJS({});
|
|
117
107
|
var modelOut = (0, _database.initDatabase)(model, {
|
|
118
108
|
additionalSignUpFields: [{
|
|
119
109
|
type: 'hidden',
|
|
@@ -123,7 +113,11 @@ describe('database/index.js', function () {
|
|
|
123
113
|
});
|
|
124
114
|
var modelOutJS = modelOut.toJS();
|
|
125
115
|
expect(modelOutJS.field).toEqual({
|
|
126
|
-
hidden_field: {
|
|
116
|
+
hidden_field: {
|
|
117
|
+
showInvalid: false,
|
|
118
|
+
valid: true,
|
|
119
|
+
value: 'hidden_value'
|
|
120
|
+
}
|
|
127
121
|
});
|
|
128
122
|
expect(modelOutJS.database.additionalSignUpFields).toEqual([{
|
|
129
123
|
type: 'hidden',
|
|
@@ -132,7 +126,7 @@ describe('database/index.js', function () {
|
|
|
132
126
|
}]);
|
|
133
127
|
});
|
|
134
128
|
describe('with a hidden field without a value', function () {
|
|
135
|
-
var model =
|
|
129
|
+
var model = _immutable.default.fromJS({});
|
|
136
130
|
var modelOut = (0, _database.initDatabase)(model, {
|
|
137
131
|
additionalSignUpFields: [{
|
|
138
132
|
type: 'hidden',
|
|
@@ -1,30 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _react = require('react');
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(_react);
|
|
6
|
-
|
|
7
|
-
var _immutable = require('immutable');
|
|
8
|
-
|
|
9
|
-
var _immutable2 = _interopRequireDefault(_immutable);
|
|
10
|
-
|
|
11
|
-
var _testUtils = require('testUtils');
|
|
12
|
-
|
|
13
|
-
var _login_pane = require('../../../connection/database/login_pane');
|
|
14
|
-
|
|
15
|
-
var _login_pane2 = _interopRequireDefault(_login_pane);
|
|
1
|
+
"use strict";
|
|
16
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _immutable = _interopRequireDefault(require("immutable"));
|
|
6
|
+
var _testUtils = require("testUtils");
|
|
7
|
+
var _login_pane = _interopRequireDefault(require("../../../connection/database/login_pane"));
|
|
17
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
var lock =
|
|
22
|
-
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
|
+
var lock = _immutable.default.fromJS({
|
|
13
|
+
id: '__lock-id__'
|
|
14
|
+
});
|
|
23
15
|
jest.mock('core/index');
|
|
24
|
-
|
|
25
16
|
jest.mock('engine/classic');
|
|
26
17
|
jest.mock('connection/enterprise');
|
|
27
|
-
|
|
28
18
|
describe('LoginPane', function () {
|
|
29
19
|
var defaultProps = {
|
|
30
20
|
emailInputPlaceholder: '',
|
|
@@ -36,58 +26,47 @@ describe('LoginPane', function () {
|
|
|
36
26
|
usernameInputPlaceholder: '',
|
|
37
27
|
lock: lock
|
|
38
28
|
};
|
|
39
|
-
|
|
40
29
|
beforeEach(function () {
|
|
41
30
|
jest.resetAllMocks();
|
|
42
31
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
32
|
+
it('renders correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
33
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
46
34
|
while (1) {
|
|
47
35
|
switch (_context.prev = _context.next) {
|
|
48
36
|
case 0:
|
|
49
|
-
(0, _testUtils.expectShallowComponent)(
|
|
50
|
-
|
|
37
|
+
(0, _testUtils.expectShallowComponent)( /*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
|
|
51
38
|
case 1:
|
|
52
|
-
case
|
|
39
|
+
case "end":
|
|
53
40
|
return _context.stop();
|
|
54
41
|
}
|
|
55
42
|
}
|
|
56
|
-
}, _callee
|
|
43
|
+
}, _callee);
|
|
57
44
|
})));
|
|
58
|
-
|
|
59
45
|
it('renders a captcha', function () {
|
|
60
46
|
require('core/index').captcha.mockReturnValue({
|
|
61
47
|
get: function get() {
|
|
62
48
|
return true;
|
|
63
49
|
}
|
|
64
50
|
});
|
|
65
|
-
|
|
66
|
-
(0, _testUtils.expectShallowComponent)(_react2.default.createElement(_login_pane2.default, defaultProps)).toMatchSnapshot();
|
|
51
|
+
(0, _testUtils.expectShallowComponent)( /*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
|
|
67
52
|
});
|
|
68
|
-
|
|
69
53
|
it('hides the captcha for SSO connections', function () {
|
|
70
54
|
require('core/index').captcha.mockReturnValue({
|
|
71
55
|
get: function get() {
|
|
72
56
|
return true;
|
|
73
57
|
}
|
|
74
58
|
});
|
|
75
|
-
|
|
76
59
|
require('engine/classic').isSSOEnabled.mockReturnValue(true);
|
|
77
|
-
|
|
78
|
-
(0, _testUtils.expectShallowComponent)(_react2.default.createElement(_login_pane2.default, defaultProps)).toMatchSnapshot();
|
|
60
|
+
(0, _testUtils.expectShallowComponent)( /*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
|
|
79
61
|
});
|
|
80
|
-
|
|
81
62
|
it('shows the captcha for SSO (ADFS) connections', function () {
|
|
82
63
|
require('core/index').captcha.mockReturnValue({
|
|
83
64
|
get: function get() {
|
|
84
65
|
return true;
|
|
85
66
|
}
|
|
86
67
|
});
|
|
87
|
-
|
|
88
68
|
require('engine/classic').isSSOEnabled.mockReturnValue(true);
|
|
89
69
|
require('connection/enterprise').isHRDDomain.mockReturnValue(true);
|
|
90
|
-
|
|
91
|
-
(0, _testUtils.expectShallowComponent)(_react2.default.createElement(_login_pane2.default, defaultProps)).toMatchSnapshot();
|
|
70
|
+
(0, _testUtils.expectShallowComponent)( /*#__PURE__*/_react.default.createElement(_login_pane.default, defaultProps)).toMatchSnapshot();
|
|
92
71
|
});
|
|
93
72
|
});
|