@budibase/worker 2.3.18-alpha.8 → 2.3.18
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/coverage/clover.xml +2199 -0
- package/coverage/coverage-final.json +84 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +431 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +934 -0
- package/coverage/lcov-report/src/api/controllers/global/configs.ts.html +1348 -0
- package/coverage/lcov-report/src/api/controllers/global/email.ts.html +196 -0
- package/coverage/lcov-report/src/api/controllers/global/events.ts.html +136 -0
- package/coverage/lcov-report/src/api/controllers/global/index.html +251 -0
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +187 -0
- package/coverage/lcov-report/src/api/controllers/global/roles.ts.html +283 -0
- package/coverage/lcov-report/src/api/controllers/global/self.ts.html +577 -0
- package/coverage/lcov-report/src/api/controllers/global/templates.ts.html +316 -0
- package/coverage/lcov-report/src/api/controllers/global/users.ts.html +838 -0
- package/coverage/lcov-report/src/api/controllers/global/workspaces.ts.html +244 -0
- package/coverage/lcov-report/src/api/controllers/system/accounts.ts.html +148 -0
- package/coverage/lcov-report/src/api/controllers/system/environment.ts.html +124 -0
- package/coverage/lcov-report/src/api/controllers/system/index.html +191 -0
- package/coverage/lcov-report/src/api/controllers/system/migrations.ts.html +124 -0
- package/coverage/lcov-report/src/api/controllers/system/restore.ts.html +124 -0
- package/coverage/lcov-report/src/api/controllers/system/status.ts.html +133 -0
- package/coverage/lcov-report/src/api/controllers/system/tenants.ts.html +154 -0
- package/coverage/lcov-report/src/api/index.html +116 -0
- package/coverage/lcov-report/src/api/index.ts.html +595 -0
- package/coverage/lcov-report/src/api/routes/global/auth.ts.html +349 -0
- package/coverage/lcov-report/src/api/routes/global/configs.ts.html +457 -0
- package/coverage/lcov-report/src/api/routes/global/email.ts.html +193 -0
- package/coverage/lcov-report/src/api/routes/global/events.ts.html +109 -0
- package/coverage/lcov-report/src/api/routes/global/index.html +251 -0
- package/coverage/lcov-report/src/api/routes/global/license.ts.html +124 -0
- package/coverage/lcov-report/src/api/routes/global/roles.ts.html +133 -0
- package/coverage/lcov-report/src/api/routes/global/self.ts.html +139 -0
- package/coverage/lcov-report/src/api/routes/global/templates.ts.html +196 -0
- package/coverage/lcov-report/src/api/routes/global/users.ts.html +475 -0
- package/coverage/lcov-report/src/api/routes/global/workspaces.ts.html +196 -0
- package/coverage/lcov-report/src/api/routes/index.html +116 -0
- package/coverage/lcov-report/src/api/routes/index.ts.html +202 -0
- package/coverage/lcov-report/src/api/routes/system/accounts.ts.html +142 -0
- package/coverage/lcov-report/src/api/routes/system/environment.ts.html +109 -0
- package/coverage/lcov-report/src/api/routes/system/index.html +191 -0
- package/coverage/lcov-report/src/api/routes/system/migrations.ts.html +142 -0
- package/coverage/lcov-report/src/api/routes/system/restore.ts.html +109 -0
- package/coverage/lcov-report/src/api/routes/system/status.ts.html +109 -0
- package/coverage/lcov-report/src/api/routes/system/tenants.ts.html +124 -0
- package/coverage/lcov-report/src/api/routes/validation/index.html +131 -0
- package/coverage/lcov-report/src/api/routes/validation/index.ts.html +88 -0
- package/coverage/lcov-report/src/api/routes/validation/users.ts.html +235 -0
- package/coverage/lcov-report/src/constants/index.html +116 -0
- package/coverage/lcov-report/src/constants/index.ts.html +637 -0
- package/coverage/lcov-report/src/constants/templates/index.html +116 -0
- package/coverage/lcov-report/src/constants/templates/index.ts.html +316 -0
- package/coverage/lcov-report/src/db/index.html +116 -0
- package/coverage/lcov-report/src/db/index.ts.html +115 -0
- package/coverage/lcov-report/src/environment.ts.html +388 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/index.ts.html +394 -0
- package/coverage/lcov-report/src/middleware/cloudRestricted.ts.html +139 -0
- package/coverage/lcov-report/src/middleware/index.html +116 -0
- package/coverage/lcov-report/src/migrations/functions/globalInfoSyncUsers.ts.html +145 -0
- package/coverage/lcov-report/src/migrations/functions/index.html +116 -0
- package/coverage/lcov-report/src/migrations/index.html +116 -0
- package/coverage/lcov-report/src/migrations/index.ts.html +271 -0
- package/coverage/lcov-report/src/sdk/accounts/accounts.ts.html +262 -0
- package/coverage/lcov-report/src/sdk/accounts/index.html +131 -0
- package/coverage/lcov-report/src/sdk/accounts/index.ts.html +88 -0
- package/coverage/lcov-report/src/sdk/index.html +116 -0
- package/coverage/lcov-report/src/sdk/index.ts.html +106 -0
- package/coverage/lcov-report/src/sdk/users/events.ts.html +601 -0
- package/coverage/lcov-report/src/sdk/users/index.html +146 -0
- package/coverage/lcov-report/src/sdk/users/index.ts.html +88 -0
- package/coverage/lcov-report/src/sdk/users/users.ts.html +1999 -0
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +1075 -0
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +160 -0
- package/coverage/lcov-report/src/tests/api/auth.ts.html +220 -0
- package/coverage/lcov-report/src/tests/api/base.ts.html +133 -0
- package/coverage/lcov-report/src/tests/api/configs.ts.html +226 -0
- package/coverage/lcov-report/src/tests/api/email.ts.html +148 -0
- package/coverage/lcov-report/src/tests/api/environment.ts.html +130 -0
- package/coverage/lcov-report/src/tests/api/groups.ts.html +163 -0
- package/coverage/lcov-report/src/tests/api/index.html +356 -0
- package/coverage/lcov-report/src/tests/api/index.ts.html +238 -0
- package/coverage/lcov-report/src/tests/api/license.ts.html +136 -0
- package/coverage/lcov-report/src/tests/api/migrations.ts.html +151 -0
- package/coverage/lcov-report/src/tests/api/restore.ts.html +127 -0
- package/coverage/lcov-report/src/tests/api/roles.ts.html +181 -0
- package/coverage/lcov-report/src/tests/api/self.ts.html +163 -0
- package/coverage/lcov-report/src/tests/api/status.ts.html +121 -0
- package/coverage/lcov-report/src/tests/api/templates.ts.html +175 -0
- package/coverage/lcov-report/src/tests/api/tenants.ts.html +130 -0
- package/coverage/lcov-report/src/tests/api/users.ts.html +514 -0
- package/coverage/lcov-report/src/tests/controllers.ts.html +100 -0
- package/coverage/lcov-report/src/tests/index.html +146 -0
- package/coverage/lcov-report/src/tests/index.ts.html +103 -0
- package/coverage/lcov-report/src/tests/mocks/email.ts.html +115 -0
- package/coverage/lcov-report/src/tests/mocks/index.html +131 -0
- package/coverage/lcov-report/src/tests/mocks/index.ts.html +106 -0
- package/coverage/lcov-report/src/tests/structures/configs.ts.html +313 -0
- package/coverage/lcov-report/src/tests/structures/groups.ts.html +118 -0
- package/coverage/lcov-report/src/tests/structures/index.html +161 -0
- package/coverage/lcov-report/src/tests/structures/index.ts.html +151 -0
- package/coverage/lcov-report/src/tests/structures/users.ts.html +196 -0
- package/coverage/lcov-report/src/utilities/appService.ts.html +208 -0
- package/coverage/lcov-report/src/utilities/email.ts.html +850 -0
- package/coverage/lcov-report/src/utilities/fileSystem.ts.html +100 -0
- package/coverage/lcov-report/src/utilities/index.html +206 -0
- package/coverage/lcov-report/src/utilities/index.ts.html +112 -0
- package/coverage/lcov-report/src/utilities/redis.ts.html +424 -0
- package/coverage/lcov-report/src/utilities/templates.ts.html +232 -0
- package/coverage/lcov-report/src/utilities/users.ts.html +133 -0
- package/coverage/lcov.info +4187 -0
- package/jest.config.ts +17 -13
- package/package.json +8 -11
- package/scripts/dev/manage.js +0 -1
- package/src/api/controllers/global/auth.ts +70 -77
- package/src/api/controllers/global/self.ts +44 -28
- package/src/api/controllers/global/users.ts +25 -65
- package/src/api/controllers/system/accounts.ts +5 -7
- package/src/api/controllers/system/tenants.ts +8 -4
- package/src/api/index.ts +20 -4
- package/src/api/routes/global/auth.ts +7 -10
- package/src/api/routes/global/tests/auth.spec.ts +17 -226
- package/src/api/routes/global/tests/configs.spec.ts +5 -5
- package/src/api/routes/global/tests/roles.spec.ts +14 -20
- package/src/api/routes/global/tests/self.spec.ts +4 -3
- package/src/api/routes/global/tests/users.spec.ts +27 -24
- package/src/api/routes/system/tenants.ts +1 -1
- package/src/api/routes/system/tests/accounts.spec.ts +4 -4
- package/src/api/routes/system/tests/migrations.spec.ts +2 -2
- package/src/api/routes/system/tests/restore.spec.ts +2 -2
- package/src/api/routes/system/tests/status.spec.ts +5 -5
- package/src/environment.ts +1 -15
- package/src/index.ts +7 -12
- package/src/middleware/tests/tenancy.spec.ts +4 -4
- package/src/migrations/functions/globalInfoSyncUsers.ts +3 -4
- package/src/sdk/accounts/{metadata.ts → accounts.ts} +1 -0
- package/src/sdk/accounts/index.ts +1 -2
- package/src/sdk/users/events.ts +0 -4
- package/src/sdk/users/index.ts +0 -1
- package/src/sdk/users/users.ts +46 -53
- package/src/tests/TestConfiguration.ts +62 -41
- package/src/tests/api/auth.ts +14 -42
- package/src/tests/api/base.ts +1 -2
- package/src/tests/api/configs.ts +2 -2
- package/src/tests/api/restore.ts +0 -1
- package/src/tests/api/users.ts +2 -2
- package/src/tests/jestEnv.ts +1 -2
- package/src/tests/jestSetup.ts +6 -10
- package/src/tests/structures/index.ts +4 -0
- package/src/tests/structures/users.ts +37 -0
- package/src/utilities/email.ts +3 -3
- package/src/utilities/redis.ts +0 -2
- package/__mocks__/node-fetch.ts +0 -23
- package/jest-testcontainers-config.js +0 -8
- package/scripts/test.sh +0 -12
- package/src/ddApm.ts +0 -7
- package/src/elasticApm.ts +0 -10
- package/src/sdk/auth/auth.ts +0 -86
- package/src/sdk/auth/index.ts +0 -1
- package/src/sdk/tenants/index.ts +0 -1
- package/src/sdk/tenants/tenants.ts +0 -76
- package/src/sdk/users/tests/users.spec.ts +0 -52
- package/src/tests/logging.ts +0 -34
package/__mocks__/node-fetch.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import fs from "fs"
|
|
2
|
-
module FetchMock {
|
|
3
|
-
const fetch = jest.requireActual("node-fetch")
|
|
4
|
-
|
|
5
|
-
const func = async (url: any, opts: any) => {
|
|
6
|
-
if (url.includes("http://someconfigurl")) {
|
|
7
|
-
return {
|
|
8
|
-
ok: true,
|
|
9
|
-
json: () => ({
|
|
10
|
-
issuer: "test",
|
|
11
|
-
authorization_endpoint: "http://localhost/auth",
|
|
12
|
-
token_endpoint: "http://localhost/token",
|
|
13
|
-
userinfo_endpoint: "http://localhost/userinfo",
|
|
14
|
-
}),
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return fetch(url, opts)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
func.Headers = fetch.Headers
|
|
21
|
-
|
|
22
|
-
module.exports = func
|
|
23
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const { join } = require("path")
|
|
2
|
-
require("dotenv").config({
|
|
3
|
-
path: join(__dirname, "..", "..", "hosting", ".env"),
|
|
4
|
-
})
|
|
5
|
-
|
|
6
|
-
const jestTestcontainersConfigGenerator = require("../../jestTestcontainersConfigGenerator")
|
|
7
|
-
|
|
8
|
-
module.exports = jestTestcontainersConfigGenerator()
|
package/scripts/test.sh
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
if [[ -n $CI ]]
|
|
4
|
-
then
|
|
5
|
-
# --runInBand performs better in ci where resources are limited
|
|
6
|
-
echo "jest --coverage --runInBand"
|
|
7
|
-
jest --coverage --runInBand
|
|
8
|
-
else
|
|
9
|
-
# --maxWorkers performs better in development
|
|
10
|
-
echo "jest --coverage --maxWorkers=2"
|
|
11
|
-
jest --coverage --maxWorkers=2
|
|
12
|
-
fi
|
package/src/ddApm.ts
DELETED
package/src/elasticApm.ts
DELETED
package/src/sdk/auth/auth.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
auth as authCore,
|
|
3
|
-
tenancy,
|
|
4
|
-
utils as coreUtils,
|
|
5
|
-
sessions,
|
|
6
|
-
events,
|
|
7
|
-
HTTPError,
|
|
8
|
-
} from "@budibase/backend-core"
|
|
9
|
-
import { PlatformLogoutOpts, User } from "@budibase/types"
|
|
10
|
-
import jwt from "jsonwebtoken"
|
|
11
|
-
import env from "../../environment"
|
|
12
|
-
import * as userSdk from "../users"
|
|
13
|
-
import * as emails from "../../utilities/email"
|
|
14
|
-
import * as redis from "../../utilities/redis"
|
|
15
|
-
import { EmailTemplatePurpose } from "../../constants"
|
|
16
|
-
|
|
17
|
-
// LOGIN / LOGOUT
|
|
18
|
-
|
|
19
|
-
export async function loginUser(user: User) {
|
|
20
|
-
const sessionId = coreUtils.newid()
|
|
21
|
-
const tenantId = tenancy.getTenantId()
|
|
22
|
-
await sessions.createASession(user._id!, { sessionId, tenantId })
|
|
23
|
-
const token = jwt.sign(
|
|
24
|
-
{
|
|
25
|
-
userId: user._id,
|
|
26
|
-
sessionId,
|
|
27
|
-
tenantId,
|
|
28
|
-
},
|
|
29
|
-
env.JWT_SECRET!
|
|
30
|
-
)
|
|
31
|
-
return token
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export async function logout(opts: PlatformLogoutOpts) {
|
|
35
|
-
// TODO: This should be moved out of core and into worker only
|
|
36
|
-
// account-portal can call worker endpoint
|
|
37
|
-
return authCore.platformLogout(opts)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// PASSWORD MANAGEMENT
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Reset the user password, used as part of a forgotten password flow.
|
|
44
|
-
*/
|
|
45
|
-
export const reset = async (email: string) => {
|
|
46
|
-
const configured = await emails.isEmailConfigured()
|
|
47
|
-
if (!configured) {
|
|
48
|
-
throw new HTTPError(
|
|
49
|
-
"Please contact your platform administrator, SMTP is not configured.",
|
|
50
|
-
400
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const user = await userSdk.core.getGlobalUserByEmail(email)
|
|
55
|
-
// exit if user doesn't exist
|
|
56
|
-
if (!user) {
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// exit if user has sso
|
|
61
|
-
if (await userSdk.isPreventSSOPasswords(user)) {
|
|
62
|
-
throw new HTTPError("SSO user cannot reset password", 400)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// send password reset
|
|
66
|
-
await emails.sendEmail(email, EmailTemplatePurpose.PASSWORD_RECOVERY, {
|
|
67
|
-
user,
|
|
68
|
-
subject: "{{ company }} platform password reset",
|
|
69
|
-
})
|
|
70
|
-
await events.user.passwordResetRequested(user)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Perform the user password update if the provided reset code is valid.
|
|
75
|
-
*/
|
|
76
|
-
export const resetUpdate = async (resetCode: string, password: string) => {
|
|
77
|
-
const { userId } = await redis.checkResetPasswordCode(resetCode)
|
|
78
|
-
|
|
79
|
-
let user = await userSdk.getUser(userId)
|
|
80
|
-
user.password = password
|
|
81
|
-
user = await userSdk.save(user)
|
|
82
|
-
|
|
83
|
-
// remove password from the user before sending events
|
|
84
|
-
delete user.password
|
|
85
|
-
await events.user.passwordReset(user)
|
|
86
|
-
}
|
package/src/sdk/auth/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./auth"
|
package/src/sdk/tenants/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./tenants"
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { App } from "@budibase/types"
|
|
2
|
-
import { tenancy, db as dbCore, platform } from "@budibase/backend-core"
|
|
3
|
-
import { quotas } from "@budibase/pro"
|
|
4
|
-
|
|
5
|
-
export async function deleteTenant(tenantId: string) {
|
|
6
|
-
await quotas.bustCache()
|
|
7
|
-
await platform.tenants.removeTenant(tenantId)
|
|
8
|
-
await removeTenantUsers(tenantId)
|
|
9
|
-
await removeTenantApps(tenantId)
|
|
10
|
-
await removeGlobalDB(tenantId)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function removeGlobalDB(tenantId: string) {
|
|
14
|
-
try {
|
|
15
|
-
const db = tenancy.getTenantDB(tenantId)
|
|
16
|
-
await db.destroy()
|
|
17
|
-
} catch (err) {
|
|
18
|
-
console.error(`Error removing tenant ${tenantId} users from info db`, err)
|
|
19
|
-
throw err
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function removeTenantApps(tenantId: string) {
|
|
24
|
-
try {
|
|
25
|
-
const apps = (await dbCore.getAllApps({ all: true })) as App[]
|
|
26
|
-
const destroyPromises = apps.map(app => {
|
|
27
|
-
const db = dbCore.getDB(app.appId)
|
|
28
|
-
return db.destroy()
|
|
29
|
-
})
|
|
30
|
-
await Promise.allSettled(destroyPromises)
|
|
31
|
-
} catch (err) {
|
|
32
|
-
console.error(`Error removing tenant ${tenantId} apps`, err)
|
|
33
|
-
throw err
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getTenantUsers(tenantId: string) {
|
|
38
|
-
const db = tenancy.getTenantDB(tenantId)
|
|
39
|
-
|
|
40
|
-
return db.allDocs(
|
|
41
|
-
dbCore.getGlobalUserParams(null, {
|
|
42
|
-
include_docs: true,
|
|
43
|
-
})
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function removeTenantUsers(tenantId: string) {
|
|
48
|
-
try {
|
|
49
|
-
const allUsers = await getTenantUsers(tenantId)
|
|
50
|
-
const allEmails = allUsers.rows.map((row: any) => row.doc.email)
|
|
51
|
-
|
|
52
|
-
// get the id and email doc ids
|
|
53
|
-
let keys = allUsers.rows.map((row: any) => row.id)
|
|
54
|
-
keys = keys.concat(allEmails)
|
|
55
|
-
|
|
56
|
-
const platformDb = platform.getPlatformDB()
|
|
57
|
-
|
|
58
|
-
// retrieve the docs
|
|
59
|
-
const userDocs = await platformDb.allDocs({
|
|
60
|
-
keys,
|
|
61
|
-
include_docs: true,
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
// delete the docs
|
|
65
|
-
const toDelete = userDocs.rows.map((row: any) => {
|
|
66
|
-
return {
|
|
67
|
-
...row.doc,
|
|
68
|
-
_deleted: true,
|
|
69
|
-
}
|
|
70
|
-
})
|
|
71
|
-
await platformDb.bulkDocs(toDelete)
|
|
72
|
-
} catch (err) {
|
|
73
|
-
console.error(`Error removing tenant ${tenantId} users from info db`, err)
|
|
74
|
-
throw err
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { structures } from "../../../tests"
|
|
2
|
-
import * as users from "../users"
|
|
3
|
-
import env from "../../../environment"
|
|
4
|
-
import { mocks } from "@budibase/backend-core/tests"
|
|
5
|
-
import { CloudAccount } from "@budibase/types"
|
|
6
|
-
|
|
7
|
-
describe("users", () => {
|
|
8
|
-
describe("isPreventSSOPasswords", () => {
|
|
9
|
-
it("returns true for sso account user", async () => {
|
|
10
|
-
const user = structures.users.user()
|
|
11
|
-
mocks.accounts.getAccount.mockReturnValue(
|
|
12
|
-
Promise.resolve(structures.accounts.ssoAccount() as CloudAccount)
|
|
13
|
-
)
|
|
14
|
-
const result = await users.isPreventSSOPasswords(user)
|
|
15
|
-
expect(result).toBe(true)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it("returns true for sso user", async () => {
|
|
19
|
-
const user = structures.users.ssoUser()
|
|
20
|
-
const result = await users.isPreventSSOPasswords(user)
|
|
21
|
-
expect(result).toBe(true)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
describe("sso maintenance mode", () => {
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
env._set("ENABLE_SSO_MAINTENANCE_MODE", true)
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
afterEach(() => {
|
|
30
|
-
env._set("ENABLE_SSO_MAINTENANCE_MODE", false)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
describe("non-admin user", () => {
|
|
34
|
-
it("returns true", async () => {
|
|
35
|
-
const user = structures.users.ssoUser()
|
|
36
|
-
const result = await users.isPreventSSOPasswords(user)
|
|
37
|
-
expect(result).toBe(true)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe("admin user", () => {
|
|
42
|
-
it("returns false", async () => {
|
|
43
|
-
const user = structures.users.ssoUser({
|
|
44
|
-
user: structures.users.adminUser(),
|
|
45
|
-
})
|
|
46
|
-
const result = await users.isPreventSSOPasswords(user)
|
|
47
|
-
expect(result).toBe(false)
|
|
48
|
-
})
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
})
|
|
52
|
-
})
|
package/src/tests/logging.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export enum LogLevel {
|
|
2
|
-
TRACE = "trace",
|
|
3
|
-
DEBUG = "debug",
|
|
4
|
-
INFO = "info",
|
|
5
|
-
WARN = "warn",
|
|
6
|
-
ERROR = "error",
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const LOG_INDEX: { [key in LogLevel]: number } = {
|
|
10
|
-
[LogLevel.TRACE]: 1,
|
|
11
|
-
[LogLevel.DEBUG]: 2,
|
|
12
|
-
[LogLevel.INFO]: 3,
|
|
13
|
-
[LogLevel.WARN]: 4,
|
|
14
|
-
[LogLevel.ERROR]: 5,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel]
|
|
18
|
-
|
|
19
|
-
if (setIndex > LOG_INDEX.trace) {
|
|
20
|
-
global.console.trace = jest.fn()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (setIndex > LOG_INDEX.debug) {
|
|
24
|
-
global.console.debug = jest.fn()
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (setIndex > LOG_INDEX.info) {
|
|
28
|
-
global.console.info = jest.fn()
|
|
29
|
-
global.console.log = jest.fn()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (setIndex > LOG_INDEX.warn) {
|
|
33
|
-
global.console.warn = jest.fn()
|
|
34
|
-
}
|