@auth0/auth0-checkmate 1.4.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.
Files changed (114) hide show
  1. package/.github/CODEOWNERS +1 -0
  2. package/.github/workflows/npm-release.yml +77 -0
  3. package/.github/workflows/sca_scan.yml +10 -0
  4. package/.github/workflows/test.yml +48 -0
  5. package/AUTHORS +5 -0
  6. package/LICENSE +203 -0
  7. package/README.md +166 -0
  8. package/THIRD-PARTY-NOTICES +226 -0
  9. package/analyzer/lib/actions/checkActionsHardCodedValues.js +151 -0
  10. package/analyzer/lib/actions/checkActionsRuntime.js +105 -0
  11. package/analyzer/lib/actions/checkDependencies.js +111 -0
  12. package/analyzer/lib/attack_protection/checkBotDetectionSetting.js +76 -0
  13. package/analyzer/lib/attack_protection/checkBreachedPassword.js +140 -0
  14. package/analyzer/lib/attack_protection/checkBruteForce.js +89 -0
  15. package/analyzer/lib/attack_protection/checkSuspiciousIPThrottling.js +89 -0
  16. package/analyzer/lib/canonical_domain/checkCanonicalDomain.js +63 -0
  17. package/analyzer/lib/clients/checkAllowedCallbacks.js +122 -0
  18. package/analyzer/lib/clients/checkAllowedLogoutUrl.js +124 -0
  19. package/analyzer/lib/clients/checkApplicationLoginUri.js +125 -0
  20. package/analyzer/lib/clients/checkCrossOriginAuthentication.js +91 -0
  21. package/analyzer/lib/clients/checkGrantTypes.js +138 -0
  22. package/analyzer/lib/clients/checkJWTSignAlg.js +118 -0
  23. package/analyzer/lib/clients/checkRefreshToken.js +108 -0
  24. package/analyzer/lib/clients/checkWebOrigins.js +55 -0
  25. package/analyzer/lib/constants.js +63 -0
  26. package/analyzer/lib/custom_domain/checkCustomDomain.js +53 -0
  27. package/analyzer/lib/databases/checkAuthenticationMethods.js +98 -0
  28. package/analyzer/lib/databases/checkDASHardCodedValues.js +163 -0
  29. package/analyzer/lib/databases/checkEmailAttributeVerification.js +114 -0
  30. package/analyzer/lib/databases/checkEnabledDatabaseCustomization.js +83 -0
  31. package/analyzer/lib/databases/checkPasswordComplexity.js +100 -0
  32. package/analyzer/lib/databases/checkPasswordHistory.js +92 -0
  33. package/analyzer/lib/databases/checkPasswordNoPersonalInfo.js +91 -0
  34. package/analyzer/lib/databases/checkPasswordPolicy.js +95 -0
  35. package/analyzer/lib/databases/checkPromotedDBConnection.js +96 -0
  36. package/analyzer/lib/email_provider/checkEmailProvider.js +37 -0
  37. package/analyzer/lib/email_templates/checkEmailTemplates.js +71 -0
  38. package/analyzer/lib/error_page_template/checkErrorPageTemplate.js +153 -0
  39. package/analyzer/lib/event_streams/checkEventStreams.js +71 -0
  40. package/analyzer/lib/executeCheck.js +12 -0
  41. package/analyzer/lib/hooks/checkHooks.js +43 -0
  42. package/analyzer/lib/listOfAnalyser.js +24 -0
  43. package/analyzer/lib/log_streams/checkLogStream.js +60 -0
  44. package/analyzer/lib/logger.js +16 -0
  45. package/analyzer/lib/multifactor/checkGuardianFactors.js +72 -0
  46. package/analyzer/lib/multifactor/checkGuardianPolicy.js +40 -0
  47. package/analyzer/lib/network_acl/checkNetworkACL.js +35 -0
  48. package/analyzer/lib/rules/checkRules.js +102 -0
  49. package/analyzer/lib/tenant_settings/checkDefaultAudience.js +53 -0
  50. package/analyzer/lib/tenant_settings/checkDefaultDirectory.js +48 -0
  51. package/analyzer/lib/tenant_settings/checkEnabledDynamicClientRegistration.js +60 -0
  52. package/analyzer/lib/tenant_settings/checkSandboxVersion.js +37 -0
  53. package/analyzer/lib/tenant_settings/checkSessionLifetime.js +95 -0
  54. package/analyzer/lib/tenant_settings/checkSupportEmail.js +61 -0
  55. package/analyzer/lib/tenant_settings/checkSupportUrl.js +61 -0
  56. package/analyzer/lib/tenant_settings/checkTenantLoginUrl.js +71 -0
  57. package/analyzer/lib/tenant_settings/checkTenantLogoutUrl.js +60 -0
  58. package/analyzer/report.js +404 -0
  59. package/analyzer/tools/auth0.js +443 -0
  60. package/analyzer/tools/helpers.js +71 -0
  61. package/analyzer/tools/summary.js +84 -0
  62. package/analyzer/tools/utils.js +72 -0
  63. package/bin/index.js +393 -0
  64. package/eslint.config.mjs +16 -0
  65. package/images/auth0.png +0 -0
  66. package/images/okta.png +0 -0
  67. package/locales/en.json +1417 -0
  68. package/package.json +66 -0
  69. package/tests/actions/checkActionsHardCodedValues.test.js +106 -0
  70. package/tests/actions/checkActionsRuntime.test.js +102 -0
  71. package/tests/actions/checkDependencies.test.js +131 -0
  72. package/tests/attack_protection/checkBreachedPassword.test.js +253 -0
  73. package/tests/attack_protection/checkBruteForce.test.js +181 -0
  74. package/tests/attack_protection/checkSuspiciousIPThrottling.test.js +222 -0
  75. package/tests/canonical_domain/checkCanonicalDomain.test.js +94 -0
  76. package/tests/clients/checkAllowedCallbacks.test.js +149 -0
  77. package/tests/clients/checkAllowedLogoutUrl.test.js +149 -0
  78. package/tests/clients/checkApplicationLoginUri.test.js +180 -0
  79. package/tests/clients/checkCrossOriginAuthentication.test.js +99 -0
  80. package/tests/clients/checkGrantTypes.test.js +154 -0
  81. package/tests/clients/checkJWTSignAlg.test.js +121 -0
  82. package/tests/clients/checkRefreshToken.test.js +63 -0
  83. package/tests/clients/checkWebOrigins.test.js +140 -0
  84. package/tests/custom_domain/checkCustomDomain.test.js +73 -0
  85. package/tests/databases/checkAuthenticationMethods.test.js +124 -0
  86. package/tests/databases/checkDASHardCodedValues.test.js +77 -0
  87. package/tests/databases/checkEmailAttributeVerification.test.js +79 -0
  88. package/tests/databases/checkEnabledDatabaseCustomization.test.js +68 -0
  89. package/tests/databases/checkPasswordComplexity.test.js +127 -0
  90. package/tests/databases/checkPasswordHistory.test.js +100 -0
  91. package/tests/databases/checkPasswordNoPersonalInfo.test.js +94 -0
  92. package/tests/databases/checkPasswordPolicy.test.js +161 -0
  93. package/tests/databases/checkPromotedDBConnection.test.js +62 -0
  94. package/tests/email_provider/checkEmailProvider.test.js +58 -0
  95. package/tests/email_templates/checkEmailTemplates.test.js +120 -0
  96. package/tests/error_page_template/checkErrorPageTemplate.test.js +315 -0
  97. package/tests/event_streams/checkEventStreams.test.js +118 -0
  98. package/tests/hooks/checkHooks.test.js +112 -0
  99. package/tests/log_streams/checkLogStream.test.js +140 -0
  100. package/tests/multifactor/checkGuardianFactors.test.js +94 -0
  101. package/tests/multifactor/checkGuardianPolicy.test.js +49 -0
  102. package/tests/rules/checkRules.test.js +102 -0
  103. package/tests/tenant_settings/checkDefaultAudience.test.js +62 -0
  104. package/tests/tenant_settings/checkDefaultDirectory.test.js +62 -0
  105. package/tests/tenant_settings/checkEnabledDynamicClientRegistration.test.js +97 -0
  106. package/tests/tenant_settings/checkSandboxVersion.test.js +50 -0
  107. package/tests/tenant_settings/checkSessionLifetime.test.js +108 -0
  108. package/tests/tenant_settings/checkSupportEmail.test.js +77 -0
  109. package/tests/tenant_settings/checkSupportUrl.test.js +77 -0
  110. package/tests/tenant_settings/checkTenantLoginUri.test.js +82 -0
  111. package/tests/tenant_settings/checkTenantLogoutUrl.test.js +108 -0
  112. package/tests/tools/auth0.test.js +833 -0
  113. package/tests/tools/helpers.test.js +692 -0
  114. package/views/pdf_cli_report.handlebars +571 -0
@@ -0,0 +1,63 @@
1
+ const chai = require("chai");
2
+ const expect = chai.expect;
3
+
4
+ const checkRefreshToken = require("../../analyzer/lib/clients/checkRefreshToken");
5
+ const CONSTANTS = require("../../analyzer/lib/constants");
6
+
7
+ describe("checkRefreshToken", function() {
8
+
9
+ it("should report failure if refresh_token is used but rotation_type is not rotating", function() {
10
+ const options = {
11
+ clients: [{
12
+ name: "Default App",
13
+ client_id: "client_id",
14
+ app_type: "spa",
15
+ grant_types: ["authorization_code", "refresh_token"],
16
+ refresh_token: {
17
+ rotation_type: "non-rotating",
18
+ },
19
+ }]
20
+ };;
21
+
22
+ checkRefreshToken(options, (result) => {
23
+ expect(result).to.be.an("array").with.lengthOf(1);
24
+ expect(result[0].name).to.equal("Default App (client_id)");
25
+ expect(result[0].report).to.be.an("array").with.lengthOf(1);
26
+ expect(result[0].report[0]).to.include({
27
+ name: "Default App (client_id)",
28
+ client_id: "client_id",
29
+ field: "use_rotating_refresh_token",
30
+ status: CONSTANTS.FAIL,
31
+ value: "non-rotating",
32
+ });
33
+ });
34
+ });
35
+
36
+ it("should return an empty report if refresh_token uses rotating", function() {
37
+ const options = {
38
+ clients: [{
39
+ name: "Secure App",
40
+ client_id: "client_secure",
41
+ app_type: "spa",
42
+ grant_types: ["authorization_code", "refresh_token"],
43
+ refresh_token: {
44
+ rotation_type: "rotating",
45
+ },
46
+ }]
47
+ };;
48
+
49
+ checkRefreshToken(options, (result) => {
50
+
51
+ expect(result).to.be.an("array").with.lengthOf(1);
52
+ expect(result[0].name).to.equal("Secure App (client_secure)");
53
+ expect(result[0].report).to.be.an("array").that.is.empty;
54
+ })
55
+ });
56
+
57
+ it("should return empty result if no clients are provided", function() {
58
+ const options = {clients: []};
59
+ checkRefreshToken(options, (result) => {
60
+ expect(result).to.be.an("array").that.is.empty;
61
+ });
62
+ });
63
+ });
@@ -0,0 +1,140 @@
1
+ const chai = require("chai");
2
+ const expect = chai.expect;
3
+
4
+ const checkWebOrigins = require("../../analyzer/lib/clients/checkWebOrigins");
5
+ const CONSTANTS = require("../../analyzer/lib/constants");
6
+
7
+ describe("checkWebOrigins", function () {
8
+ it("should return an empty report when there are no clients", function () {
9
+ const options = {
10
+ clients: [], // No clients
11
+ };
12
+
13
+ checkWebOrigins(options, (reports) => {
14
+ expect(reports).to.deep.equal([]); // No reports expected
15
+ });
16
+ });
17
+
18
+ it("should return a empty report when client has no web origins URLs and app_type is not non_interactive and native", function () {
19
+ const options = {
20
+ clients: [
21
+ {
22
+ name: "Test App",
23
+ client_id: "client_id",
24
+ app_type: "spa", // Not non_interactive
25
+ web_origins: [], // No allowed logout URLs
26
+ },
27
+ ],
28
+ };
29
+
30
+ checkWebOrigins(options, (reports) => {
31
+ expect(reports).to.deep.equal([
32
+ {
33
+ name: "Test App",
34
+ report: [],
35
+ },
36
+ ]);
37
+ });
38
+ });
39
+
40
+ it("should return a fail report when client has insecure web origin URLs (http://localhost)", function () {
41
+ const options = {
42
+ clients: [
43
+ {
44
+ name: "Test App",
45
+ client_id: "client_id",
46
+ web_origins: ["http://localhost:3000"], // Insecure logout URL
47
+ app_type: "spa",
48
+ },
49
+ ],
50
+ };
51
+
52
+ checkWebOrigins(options, (reports) => {
53
+ expect(reports).to.deep.equal([
54
+ {
55
+ name: "Test App",
56
+ report: [
57
+ {
58
+ name: "Test App",
59
+ client_id: "client_id",
60
+ field: "insecure_web_origins_urls",
61
+ url: "http://localhost:3000",
62
+ status: CONSTANTS.FAIL,
63
+ app_type: "spa",
64
+ },
65
+ ],
66
+ },
67
+ ]);
68
+ });
69
+ });
70
+
71
+ it("should return a success report when client has secure aweb origin URLs (https://contoso.com)", function () {
72
+ const options = {
73
+ clients: [
74
+ {
75
+ name: "Test App",
76
+ client_id: "client_id",
77
+ web_origins: ["https://contoso.com"], // Secure logout URL
78
+ app_type: "spa",
79
+ },
80
+ ],
81
+ };
82
+
83
+ checkWebOrigins(options, (reports) => {
84
+ expect(reports).to.deep.equal([
85
+ {
86
+ name: "Test App",
87
+ report: [
88
+ {
89
+ name: "Test App",
90
+ client_id: "client_id",
91
+ field: "secure_web_origins_urls",
92
+ status: CONSTANTS.SUCCESS,
93
+ url: "https://contoso.com",
94
+ app_type: "spa",
95
+ },
96
+ ],
97
+ },
98
+ ]);
99
+ });
100
+ });
101
+
102
+ it("should return both fail and success reports when client has both insecure and secure allowed logout URLs", function () {
103
+ const options = {
104
+ clients: [
105
+ {
106
+ name: "Test App",
107
+ client_id: "client_id",
108
+ web_origins: ["http://localhost:3000", "https://contoso.com"], // Mix of insecure and secure URLs
109
+ app_type: "spa",
110
+ },
111
+ ],
112
+ };
113
+
114
+ checkWebOrigins(options, (reports) => {
115
+ expect(reports).to.deep.equal([
116
+ {
117
+ name: "Test App",
118
+ report: [
119
+ {
120
+ name: "Test App",
121
+ client_id: "client_id",
122
+ field: "insecure_web_originst_urls",
123
+ url: "http://localhost:3000",
124
+ status: CONSTANTS.FAIL,
125
+ app_type: "spa",
126
+ },
127
+ {
128
+ name: "Test App",
129
+ client_id: "client_id",
130
+ field: "secure_web_originst_urls",
131
+ status: CONSTANTS.SUCCESS,
132
+ url: "https://contoso.com",
133
+ app_type: "spa",
134
+ },
135
+ ],
136
+ },
137
+ ]);
138
+ });
139
+ });
140
+ });
@@ -0,0 +1,73 @@
1
+ const chai = require("chai");
2
+ const expect = chai.expect;
3
+
4
+ const customDomainConfigured = require("../../analyzer/lib/custom_domain/checkCustomDomain"); // Adjust the path accordingly
5
+ const CONSTANTS = require("../../analyzer/lib/constants");
6
+
7
+ describe("checkCustomDomain", function () {
8
+ it("should return fail when customDomains is empty", function () {
9
+ const options = { customDomains: [] };
10
+
11
+ customDomainConfigured(options, (report) => {
12
+ expect(report.checkName).to.equal("checkCustomDomain");
13
+ expect(report.result).to.equal("fail");
14
+ expect(report.timestamp).to.be.ok;
15
+ expect(report.details).to.deep.equal([
16
+ {
17
+ field: "not_configured",
18
+ status: CONSTANTS.FAIL,
19
+ },
20
+ ]);
21
+ });
22
+ });
23
+
24
+ it("should return success when a domain is ready", function () {
25
+ const options = {
26
+ customDomains: [
27
+ {
28
+ domain: "apac-tam-team.oauth101.net",
29
+ primary: true,
30
+ status: "ready",
31
+ tls_policy: "recommended",
32
+ type: "auth0_managed_certs",
33
+ verification: {},
34
+ },
35
+ ],
36
+ };
37
+
38
+ customDomainConfigured(options, (report) => {
39
+ expect(report).to.deep.equal([
40
+ {
41
+ field: "ready",
42
+ status: CONSTANTS.SUCCESS,
43
+ value: "auth.contoso.com",
44
+ },
45
+ ]);
46
+ });
47
+ });
48
+
49
+ it("should return fail when a domain is pending verification", function () {
50
+ const options = {
51
+ customDomains: [
52
+ {
53
+ domain: "auth.contoso.com",
54
+ primary: true,
55
+ status: "pending_verification",
56
+ tls_policy: "recommended",
57
+ type: "auth0_managed_certs",
58
+ verification: {},
59
+ },
60
+ ],
61
+ };
62
+
63
+ customDomainConfigured(options, (report) => {
64
+ expect(report).to.deep.equal([
65
+ {
66
+ field: "pending_verification",
67
+ status: CONSTANTS.FAIL,
68
+ value: "auth.contoso.com",
69
+ },
70
+ ]);
71
+ });
72
+ });
73
+ });
@@ -0,0 +1,124 @@
1
+ const chai = require("chai");
2
+ const expect = chai.expect;
3
+ const checkAuthenticationMethods = require("../../analyzer/lib/databases/checkAuthenticationMethods");
4
+ const CONSTANTS = require("../../analyzer/lib/constants");
5
+
6
+ describe("checkAuthenticationMethods", function () {
7
+ it("should return a failure report when no database connections are found", function () {
8
+ const options = { databases: [] }; // No databases provided
9
+ checkAuthenticationMethods(options, (report) => {
10
+ expect(report).to.be.an("array").that.has.lengthOf(1);
11
+ expect(report[0]).to.deep.equal({
12
+ field: "no_database_connections_found",
13
+ status: CONSTANTS.FAIL,
14
+ });
15
+ });
16
+ });
17
+
18
+ it("should return a failure report when authentication methods are missing", function () {
19
+ const options = {
20
+ databases: [
21
+ {
22
+ name: "Username-Password-Authentication",
23
+ options: {
24
+ authentication_methods: {},
25
+ },
26
+ },
27
+ ],
28
+ };
29
+ checkAuthenticationMethods(options, (report) => {
30
+ expect(report).to.be.an("array").that.has.lengthOf(1);
31
+ expect(report[0]).to.deep.equal({
32
+ name: "Username-Password-Authentication",
33
+ status: CONSTANTS.FAIL,
34
+ field: "only_password_method",
35
+ });
36
+ });
37
+ });
38
+
39
+ it("should return a failure report when password is enabled but passkey is missing", function () {
40
+ const options = {
41
+ databases: [
42
+ {
43
+ name: "Username-Password-Authentication",
44
+ options: {
45
+ authentication_methods: {
46
+ password: { enabled: true },
47
+ passkey: { enabled: false },
48
+ },
49
+ },
50
+ },
51
+ ],
52
+ };
53
+ checkAuthenticationMethods(options, (report) => {
54
+ expect(report).to.be.an("array").that.has.lengthOf(1);
55
+ expect(report[0]).to.deep.equal({
56
+ name: "Username-Password-Authentication",
57
+ status: CONSTANTS.FAIL,
58
+ field: "only_password_method",
59
+ });
60
+ });
61
+ });
62
+
63
+ it("should return a success report when passkey is enabled", function () {
64
+ const options = {
65
+ databases: [
66
+ {
67
+ name: "Username-Password-Authentication",
68
+ options: {
69
+ authentication_methods: {
70
+ password: { enabled: false },
71
+ passkey: { enabled: true },
72
+ },
73
+ },
74
+ },
75
+ ],
76
+ };
77
+ checkAuthenticationMethods(options, (report) => {
78
+ expect(report).to.be.an("array").that.has.lengthOf(1);
79
+ expect(report[0]).to.deep.equal({
80
+ name: "Username-Password-Authentication",
81
+ status: CONSTANTS.SUCCESS,
82
+ field: "passkey_enabled",
83
+ });
84
+ });
85
+ });
86
+
87
+ it("should handle multiple databases correctly", function () {
88
+ const options = {
89
+ databases: [
90
+ {
91
+ name: "Username-Password-Authentication",
92
+ options: {
93
+ authentication_methods: {
94
+ password: { enabled: true },
95
+ passkey: { enabled: false },
96
+ },
97
+ },
98
+ },
99
+ {
100
+ name: "Another-Authentication",
101
+ options: {
102
+ authentication_methods: {
103
+ password: { enabled: false },
104
+ passkey: { enabled: true },
105
+ },
106
+ },
107
+ },
108
+ ],
109
+ };
110
+ checkAuthenticationMethods(options, (report) => {
111
+ expect(report).to.be.an("array").that.has.lengthOf(2);
112
+ expect(report[0]).to.deep.equal({
113
+ name: "Username-Password-Authentication",
114
+ status: CONSTANTS.FAIL,
115
+ field: "only_password_method",
116
+ });
117
+ expect(report[1]).to.deep.equal({
118
+ name: "Another-Authentication",
119
+ status: CONSTANTS.SUCCESS,
120
+ field: "passkey_enabled",
121
+ });
122
+ });
123
+ });
124
+ });
@@ -0,0 +1,77 @@
1
+ const chai = require("chai");
2
+ const expect = chai.expect;
3
+
4
+ const checkDASHardCodedValues = require("../../analyzer/lib/databases/checkDASHardCodedValues");
5
+ const CONSTANTS = require("../../analyzer/lib/constants");
6
+
7
+ describe("checkDASHardCodedValues", function() {
8
+
9
+ it("should detect hardcoded values in login script", async function() {
10
+ const mockData = {
11
+ databases: [
12
+ {
13
+ name: "Username-Password-Authentication",
14
+ options: {
15
+ enabledDatabaseCustomization: true,
16
+ customScripts: {
17
+ login: `
18
+ function login(identifierValue, password, callback) {
19
+ const mysql = require('mysql');
20
+ const connection = mysql.createConnection({
21
+ host: 'localhost',
22
+ user: 'admin',
23
+ password: 'secret',
24
+ database: 'users_db'
25
+ });
26
+ connection.connect();
27
+ const query = 'SELECT * FROM users WHERE email = ?';
28
+ connection.query(query, [ identifierValue ], callback);
29
+ }
30
+ `,
31
+ },
32
+ },
33
+ },
34
+ ],
35
+ };
36
+
37
+ const result = await checkDASHardCodedValues(mockData);
38
+ expect(result.details).to.have.lengthOf(1);
39
+ const report = result.details[0];
40
+ expect(report.report).to.have.lengthOf(5);
41
+ expect(report.report[0].scriptName).to.equal("login");
42
+ expect(report.report[0].type).to.equal("string");
43
+ expect(report.report[0].field).to.equal("hard_coded_value_detected");
44
+ expect(report.report[0].status).to.equal(CONSTANTS.FAIL);
45
+
46
+ const findings = report.report.map((r) => r.variableName);
47
+ expect(findings).to.include.members(["host", "user", "password", "database", "query"]);
48
+ });
49
+
50
+ it("should return no findings if customization is disabled", async function() {
51
+ const mockData = {
52
+ databases: [
53
+ {
54
+ name: "NoCustomization",
55
+ options: {
56
+ enabledDatabaseCustomization: false,
57
+ customScripts: {
58
+ login: "function login() { return; }",
59
+ },
60
+ },
61
+ },
62
+ ],
63
+ };
64
+
65
+ const result = await checkDASHardCodedValues(mockData);
66
+ expect(result.details).to.be.an("array").that.is.empty;
67
+ });
68
+
69
+ it("should return failure if no databases are present", async function() {
70
+ const report = await checkDASHardCodedValues({ databases: [] });
71
+ expect(report.details).to.be.an("array").that.has.lengthOf(1);
72
+ expect(report.details[0]).to.deep.equal({
73
+ field: "no_database_connections_found",
74
+ status: CONSTANTS.FAIL,
75
+ });
76
+ });
77
+ });
@@ -0,0 +1,79 @@
1
+ const chai = require("chai");
2
+ const expect = chai.expect;
3
+ const checkEmailAttributeVerification = require("../../analyzer/lib/databases/checkEmailAttributeVerification");
4
+ const CONSTANTS = require("../../analyzer/lib/constants");
5
+
6
+ describe("checkEmailAttributeVerification", function () {
7
+ it("should return a failure report when no database connections are found", function () {
8
+ const options = { databases: [] }; // No databases provided
9
+ checkEmailAttributeVerification(options, (report) => {
10
+ expect(report).to.be.an("array").that.has.lengthOf(1);
11
+ expect(report[0]).to.deep.equal({
12
+ field: "no_database_connections_found",
13
+ status: CONSTANTS.FAIL,
14
+ });
15
+ });
16
+ });
17
+
18
+ it("should return a failure report when attributes are missing", function () {
19
+ const options = {
20
+ databases: [
21
+ {
22
+ name: "Username-Password-Authentication",
23
+ options: {
24
+ authentication_methods: {},
25
+ },
26
+ },
27
+ ],
28
+ };
29
+ checkEmailAttributeVerification(options, (report) => {
30
+ expect(report).to.be.an("array").that.has.lengthOf(1);
31
+ expect(report[0]).to.deep.equal({
32
+ name: "Username-Password-Authentication",
33
+ status: CONSTANTS.FAIL,
34
+ field: "flexible_identifiers_disabled",
35
+ });
36
+ });
37
+ });
38
+
39
+ it("should return a failure report when verification_method is not otp", function () {
40
+ const options = {
41
+ databases: [
42
+ {
43
+ name: "Username-Password-Authentication",
44
+ options: {
45
+ attributes: {
46
+ email: { verification_method: "link" },
47
+ },
48
+ },
49
+ },
50
+ ],
51
+ };
52
+ checkEmailAttributeVerification(options, (report) => {
53
+ expect(report).to.be.an("array").that.has.lengthOf(1);
54
+ expect(report[0]).to.deep.equal({
55
+ name: "Username-Password-Authentication",
56
+ status: CONSTANTS.FAIL,
57
+ field: "verification_by_link_method",
58
+ });
59
+ });
60
+ });
61
+
62
+ it("should return a success report when verification_method is otp", function () {
63
+ const options = {
64
+ databases: [
65
+ {
66
+ name: "Username-Password-Authentication",
67
+ options: {
68
+ attributes: {
69
+ email: { verification_method: "otp" },
70
+ },
71
+ },
72
+ },
73
+ ],
74
+ };
75
+ checkEmailAttributeVerification(options, (report) => {
76
+ expect(report).to.be.an("array").that.has.lengthOf(0);
77
+ });
78
+ });
79
+ });
@@ -0,0 +1,68 @@
1
+ const chai = require("chai");
2
+ const expect = chai.expect;
3
+ const checkEnabledDatabaseCustomization = require("../../analyzer/lib/databases/checkEnabledDatabaseCustomization");
4
+ const CONSTANTS = require("../../analyzer/lib/constants");
5
+
6
+ describe("checkEnabledDatabaseCustomization", function () {
7
+ it("should return a failure report when no database connections are found", function () {
8
+ const options = { databases: [] }; // No databases provided
9
+ checkEnabledDatabaseCustomization(options, (report) => {
10
+ expect(report).to.be.an("array").that.has.lengthOf(1);
11
+ expect(report[0]).to.deep.equal({
12
+ field: "no_database_connections_found",
13
+ status: CONSTANTS.FAIL,
14
+ });
15
+ });
16
+ });
17
+
18
+ it("should return a failure report when import_mode is false and enabledDatabaseCustomization is true", function () {
19
+ const options = {
20
+ databases: [
21
+ {
22
+ name: "Username-Password-Authentication",
23
+ options: {
24
+ import_mode: false,
25
+ enabledDatabaseCustomization: true
26
+ },
27
+ },
28
+ ],
29
+ };
30
+ checkEnabledDatabaseCustomization(options, (report) => {
31
+ expect(report).to.be.an("array").that.has.lengthOf(1);
32
+ expect(report[0]).to.deep.equal({
33
+ name: "Username-Password-Authentication",
34
+ status: CONSTANTS.FAIL,
35
+ field: "external_user_store",
36
+ });
37
+ });
38
+ });
39
+
40
+ it("should handle multiple databases correctly", function () {
41
+ const options = {
42
+ databases: [
43
+ {
44
+ name: "Username-Password-Authentication",
45
+ options: {
46
+ import_mode: false,
47
+ enabledDatabaseCustomization: true
48
+ },
49
+ },
50
+ {
51
+ name: "Another-Authentication",
52
+ options: {
53
+ import_mode: false,
54
+ enabledDatabaseCustomization: false
55
+ },
56
+ },
57
+ ],
58
+ };
59
+ checkEnabledDatabaseCustomization(options, (report) => {
60
+ expect(report).to.be.an("array").that.has.lengthOf(1);
61
+ expect(report[0]).to.deep.equal({
62
+ name: "Username-Password-Authentication",
63
+ status: CONSTANTS.FAIL,
64
+ field: "external_user_store",
65
+ });
66
+ });
67
+ });
68
+ });