@budibase/worker 2.1.22-alpha.5 → 2.1.22-alpha.6
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/__mocks__/oauth.ts +57 -0
- package/coverage/clover.xml +1093 -1033
- package/coverage/coverage-final.json +77 -72
- package/coverage/lcov-report/index.html +83 -83
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +70 -70
- package/coverage/lcov-report/src/api/controllers/global/configs.js.html +35 -35
- package/coverage/lcov-report/src/api/controllers/global/email.js.html +4 -4
- package/coverage/lcov-report/src/api/controllers/global/index.html +38 -38
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/global/roles.js.html +10 -10
- package/coverage/lcov-report/src/api/controllers/global/self.ts.html +58 -58
- package/coverage/lcov-report/src/api/controllers/global/templates.ts.html +11 -11
- package/coverage/lcov-report/src/api/controllers/global/users.ts.html +75 -69
- package/coverage/lcov-report/src/api/controllers/global/workspaces.js.html +7 -7
- package/coverage/lcov-report/src/api/controllers/system/accounts.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/system/{environment.js.html → environment.ts.html} +21 -18
- package/coverage/lcov-report/src/api/controllers/system/index.html +63 -63
- package/coverage/lcov-report/src/api/controllers/system/migrations.ts.html +23 -23
- package/coverage/lcov-report/src/api/controllers/system/restore.ts.html +22 -22
- package/coverage/lcov-report/src/api/controllers/system/{status.js.html → status.ts.html} +29 -26
- package/coverage/lcov-report/src/api/controllers/system/tenants.ts.html +34 -163
- package/coverage/lcov-report/src/api/index.html +11 -11
- package/coverage/lcov-report/src/api/index.ts.html +113 -44
- package/coverage/lcov-report/src/api/routes/global/auth.js.html +38 -89
- package/coverage/lcov-report/src/api/routes/global/configs.js.html +17 -17
- package/coverage/lcov-report/src/api/routes/global/email.js.html +11 -11
- package/coverage/lcov-report/src/api/routes/global/index.html +11 -11
- package/coverage/lcov-report/src/api/routes/global/license.ts.html +6 -6
- package/coverage/lcov-report/src/api/routes/global/roles.js.html +7 -7
- package/coverage/lcov-report/src/api/routes/global/self.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/global/templates.ts.html +11 -11
- package/coverage/lcov-report/src/api/routes/global/users.js.html +17 -17
- package/coverage/lcov-report/src/api/routes/global/workspaces.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.ts.html +19 -19
- package/coverage/lcov-report/src/api/routes/system/accounts.ts.html +7 -7
- package/coverage/lcov-report/src/api/routes/system/{environment.js.html → environment.ts.html} +11 -11
- package/coverage/lcov-report/src/api/routes/system/index.html +4 -4
- package/coverage/lcov-report/src/api/routes/system/migrations.ts.html +7 -7
- package/coverage/lcov-report/src/api/routes/system/restore.ts.html +6 -6
- package/coverage/lcov-report/src/api/routes/system/{status.js.html → status.ts.html} +11 -11
- package/coverage/lcov-report/src/api/routes/system/{tenants.js.html → tenants.ts.html} +20 -17
- package/coverage/lcov-report/src/api/routes/validation/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/validation/index.ts.html +2 -2
- package/coverage/lcov-report/src/api/routes/validation/users.ts.html +13 -13
- package/coverage/lcov-report/src/constants/index.html +1 -1
- package/coverage/lcov-report/src/constants/index.js.html +18 -18
- package/coverage/lcov-report/src/constants/templates/index.html +1 -1
- package/coverage/lcov-report/src/constants/templates/index.js.html +10 -10
- package/coverage/lcov-report/src/db/index.html +1 -1
- package/coverage/lcov-report/src/db/index.ts.html +8 -8
- package/coverage/lcov-report/src/environment.ts.html +15 -15
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +40 -40
- package/coverage/lcov-report/src/middleware/cloudRestricted.js.html +22 -22
- package/coverage/lcov-report/src/middleware/index.html +21 -21
- package/coverage/lcov-report/src/migrations/functions/globalInfoSyncUsers.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.ts.html +17 -17
- package/coverage/lcov-report/src/sdk/accounts/accounts.ts.html +6 -6
- package/coverage/lcov-report/src/sdk/accounts/index.html +1 -1
- package/coverage/lcov-report/src/sdk/accounts/index.ts.html +2 -2
- package/coverage/lcov-report/src/sdk/index.html +1 -1
- package/coverage/lcov-report/src/sdk/index.ts.html +4 -4
- package/coverage/lcov-report/src/sdk/users/events.ts.html +43 -43
- package/coverage/lcov-report/src/sdk/users/index.html +19 -19
- package/coverage/lcov-report/src/sdk/users/index.ts.html +2 -2
- package/coverage/lcov-report/src/sdk/users/users.ts.html +99 -99
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +261 -123
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +12 -21
- package/coverage/lcov-report/src/tests/api/auth.ts.html +11 -20
- package/coverage/lcov-report/src/tests/api/base.ts.html +133 -0
- package/coverage/lcov-report/src/tests/api/configs.ts.html +44 -23
- package/coverage/lcov-report/src/tests/api/email.ts.html +9 -18
- package/coverage/lcov-report/src/tests/api/environment.ts.html +130 -0
- package/coverage/lcov-report/src/tests/api/index.html +106 -16
- package/coverage/lcov-report/src/tests/api/index.ts.html +62 -17
- package/coverage/lcov-report/src/tests/{structures/accounts.ts.html → api/migrations.ts.html} +31 -37
- package/coverage/lcov-report/src/tests/api/restore.ts.html +127 -0
- package/coverage/lcov-report/src/tests/api/self.ts.html +31 -16
- package/coverage/lcov-report/src/tests/api/status.ts.html +121 -0
- package/coverage/lcov-report/src/tests/api/tenants.ts.html +130 -0
- package/coverage/lcov-report/src/tests/api/users.ts.html +121 -25
- package/coverage/lcov-report/src/tests/controllers.js.html +2 -2
- package/coverage/lcov-report/src/tests/index.html +20 -20
- package/coverage/lcov-report/src/tests/index.ts.html +21 -9
- package/coverage/lcov-report/src/tests/mocks/email.js.html +2 -2
- package/coverage/lcov-report/src/tests/mocks/index.html +1 -1
- package/coverage/lcov-report/src/tests/mocks/index.ts.html +4 -4
- package/coverage/lcov-report/src/tests/structures/configs.js.html +8 -8
- package/coverage/lcov-report/src/tests/structures/groups.ts.html +2 -2
- package/coverage/lcov-report/src/tests/structures/index.html +9 -24
- package/coverage/lcov-report/src/tests/structures/index.ts.html +21 -15
- package/coverage/lcov-report/src/tests/structures/users.ts.html +13 -10
- package/coverage/lcov-report/src/utilities/appService.js.html +11 -11
- package/coverage/lcov-report/src/utilities/email.js.html +16 -16
- package/coverage/lcov-report/src/utilities/fileSystem.js.html +4 -4
- package/coverage/lcov-report/src/utilities/index.html +1 -1
- package/coverage/lcov-report/src/utilities/index.js.html +2 -2
- package/coverage/lcov-report/src/utilities/redis.js.html +13 -13
- package/coverage/lcov-report/src/utilities/templates.js.html +7 -7
- package/coverage/lcov-report/src/utilities/users.js.html +8 -8
- package/coverage/lcov.info +1685 -1511
- package/package.json +8 -6
- package/scripts/localdomain.js +33 -7
- package/src/api/controllers/global/auth.ts +1 -1
- package/src/api/controllers/global/users.ts +3 -1
- package/src/api/controllers/system/{environment.js → environment.ts} +3 -2
- package/src/api/controllers/system/{status.js → status.ts} +4 -3
- package/src/api/controllers/system/tenants.ts +8 -51
- package/src/api/index.ts +29 -6
- package/src/api/routes/global/auth.js +22 -39
- package/src/api/routes/global/tests/auth.spec.ts +134 -64
- package/src/api/routes/global/tests/configs.spec.ts +5 -6
- package/src/api/routes/global/tests/email.spec.ts +4 -3
- package/src/api/routes/global/tests/license.spec.ts +31 -0
- package/src/api/routes/global/tests/realEmail.spec.ts +2 -3
- package/src/api/routes/global/tests/roles.spec.ts +27 -0
- package/src/api/routes/global/tests/self.spec.ts +3 -4
- package/src/api/routes/global/tests/templates.spec.ts +35 -0
- package/src/api/routes/global/tests/users.spec.ts +51 -43
- package/src/api/routes/global/tests/workspaces.spec.ts +29 -0
- package/src/api/routes/system/environment.ts +8 -0
- package/src/api/routes/system/status.ts +8 -0
- package/src/api/routes/system/tenants.ts +13 -0
- package/src/api/routes/system/tests/accounts.spec.ts +5 -6
- package/src/api/routes/system/tests/environment.spec.ts +29 -0
- package/src/api/routes/system/tests/migrations.spec.ts +63 -0
- package/src/api/routes/system/tests/restore.spec.ts +36 -0
- package/src/api/routes/system/tests/status.spec.ts +48 -0
- package/src/api/routes/system/tests/tenants.spec.ts +61 -0
- package/src/middleware/tests/tenancy.spec.ts +73 -0
- package/src/tests/TestConfiguration.ts +88 -42
- package/src/tests/api/accounts.ts +5 -8
- package/src/tests/api/auth.ts +3 -6
- package/src/tests/api/base.ts +16 -0
- package/src/tests/api/configs.ts +15 -8
- package/src/tests/api/email.ts +3 -6
- package/src/tests/api/environment.ts +15 -0
- package/src/tests/api/index.ts +15 -0
- package/src/tests/api/migrations.ts +22 -0
- package/src/tests/api/restore.ts +14 -0
- package/src/tests/api/self.ts +11 -6
- package/src/tests/api/status.ts +12 -0
- package/src/tests/api/tenants.ts +15 -0
- package/src/tests/api/users.ts +38 -6
- package/src/tests/index.ts +4 -0
- package/src/tests/jestSetup.ts +7 -1
- package/src/tests/structures/index.ts +4 -2
- package/src/tests/structures/users.ts +1 -0
- package/__mocks__/node-fetch.ts +0 -1
- package/src/api/routes/system/environment.js +0 -8
- package/src/api/routes/system/status.js +0 -8
- package/src/api/routes/system/tenants.js +0 -12
- package/src/tests/structures/accounts.ts +0 -24
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI } from "./base"
|
|
3
|
+
|
|
4
|
+
export class EnvironmentAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getEnvironment = () => {
|
|
10
|
+
return this.request
|
|
11
|
+
.get(`/api/system/environment`)
|
|
12
|
+
.expect("Content-Type", /json/)
|
|
13
|
+
.expect(200)
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/tests/api/index.ts
CHANGED
|
@@ -5,6 +5,11 @@ import { ConfigAPI } from "./configs"
|
|
|
5
5
|
import { EmailAPI } from "./email"
|
|
6
6
|
import { SelfAPI } from "./self"
|
|
7
7
|
import { UserAPI } from "./users"
|
|
8
|
+
import { EnvironmentAPI } from "./environment"
|
|
9
|
+
import { MigrationAPI } from "./migrations"
|
|
10
|
+
import { StatusAPI } from "./status"
|
|
11
|
+
import { RestoreAPI } from "./restore"
|
|
12
|
+
import { TenantAPI } from "./tenants"
|
|
8
13
|
|
|
9
14
|
export default class API {
|
|
10
15
|
accounts: AccountAPI
|
|
@@ -13,6 +18,11 @@ export default class API {
|
|
|
13
18
|
emails: EmailAPI
|
|
14
19
|
self: SelfAPI
|
|
15
20
|
users: UserAPI
|
|
21
|
+
environment: EnvironmentAPI
|
|
22
|
+
migrations: MigrationAPI
|
|
23
|
+
status: StatusAPI
|
|
24
|
+
restore: RestoreAPI
|
|
25
|
+
tenants: TenantAPI
|
|
16
26
|
|
|
17
27
|
constructor(config: TestConfiguration) {
|
|
18
28
|
this.accounts = new AccountAPI(config)
|
|
@@ -21,5 +31,10 @@ export default class API {
|
|
|
21
31
|
this.emails = new EmailAPI(config)
|
|
22
32
|
this.self = new SelfAPI(config)
|
|
23
33
|
this.users = new UserAPI(config)
|
|
34
|
+
this.environment = new EnvironmentAPI(config)
|
|
35
|
+
this.migrations = new MigrationAPI(config)
|
|
36
|
+
this.status = new StatusAPI(config)
|
|
37
|
+
this.restore = new RestoreAPI(config)
|
|
38
|
+
this.tenants = new TenantAPI(config)
|
|
24
39
|
}
|
|
25
40
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI, TestAPIOpts } from "./base"
|
|
3
|
+
|
|
4
|
+
export class MigrationAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
runMigrations = (opts?: TestAPIOpts) => {
|
|
10
|
+
return this.request
|
|
11
|
+
.post(`/api/system/migrations/run`)
|
|
12
|
+
.set(opts?.headers ? opts.headers : this.config.internalAPIHeaders())
|
|
13
|
+
.expect(opts?.status ? opts.status : 200)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getMigrationDefinitions = (opts?: TestAPIOpts) => {
|
|
17
|
+
return this.request
|
|
18
|
+
.get(`/api/system/migrations/definitions`)
|
|
19
|
+
.set(opts?.headers ? opts.headers : this.config.internalAPIHeaders())
|
|
20
|
+
.expect(opts?.status ? opts.status : 200)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI, TestAPIOpts } from "./base"
|
|
3
|
+
|
|
4
|
+
export class RestoreAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
restored = (opts?: TestAPIOpts) => {
|
|
10
|
+
return this.request
|
|
11
|
+
.post(`/api/system/restored`)
|
|
12
|
+
.expect(opts?.status ? opts.status : 200)
|
|
13
|
+
}
|
|
14
|
+
}
|
package/src/tests/api/self.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import TestConfiguration from "../TestConfiguration"
|
|
2
2
|
import { User } from "@budibase/types"
|
|
3
|
+
import { TestAPI } from "./base"
|
|
3
4
|
|
|
4
|
-
export class SelfAPI {
|
|
5
|
-
config: TestConfiguration
|
|
6
|
-
request: any
|
|
7
|
-
|
|
5
|
+
export class SelfAPI extends TestAPI {
|
|
8
6
|
constructor(config: TestConfiguration) {
|
|
9
|
-
|
|
10
|
-
this.request = config.request
|
|
7
|
+
super(config)
|
|
11
8
|
}
|
|
12
9
|
|
|
13
10
|
updateSelf = (user: User) => {
|
|
@@ -18,4 +15,12 @@ export class SelfAPI {
|
|
|
18
15
|
.expect("Content-Type", /json/)
|
|
19
16
|
.expect(200)
|
|
20
17
|
}
|
|
18
|
+
|
|
19
|
+
getSelf = (user: User) => {
|
|
20
|
+
return this.request
|
|
21
|
+
.get(`/api/global/self`)
|
|
22
|
+
.set(this.config.authHeaders(user))
|
|
23
|
+
.expect("Content-Type", /json/)
|
|
24
|
+
.expect(200)
|
|
25
|
+
}
|
|
21
26
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI } from "./base"
|
|
3
|
+
|
|
4
|
+
export class StatusAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getStatus = () => {
|
|
10
|
+
return this.request.get(`/api/system/status`).expect(200)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI, TestAPIOpts } from "./base"
|
|
3
|
+
|
|
4
|
+
export class TenantAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
delete = (tenantId: string, opts?: TestAPIOpts) => {
|
|
10
|
+
return this.request
|
|
11
|
+
.delete(`/api/system/tenants/${tenantId}`)
|
|
12
|
+
.set(opts?.headers)
|
|
13
|
+
.expect(opts?.status ? opts.status : 204)
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/tests/api/users.ts
CHANGED
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
BulkUserRequest,
|
|
4
4
|
InviteUsersRequest,
|
|
5
5
|
User,
|
|
6
|
+
CreateAdminUserRequest,
|
|
6
7
|
} from "@budibase/types"
|
|
8
|
+
import * as structures from "../structures"
|
|
9
|
+
import { generator } from "@budibase/backend-core/tests"
|
|
7
10
|
import TestConfiguration from "../TestConfiguration"
|
|
11
|
+
import { TestAPI, TestAPIOpts } from "./base"
|
|
8
12
|
|
|
9
|
-
export class UserAPI {
|
|
10
|
-
config: TestConfiguration
|
|
11
|
-
request: any
|
|
12
|
-
|
|
13
|
+
export class UserAPI extends TestAPI {
|
|
13
14
|
constructor(config: TestConfiguration) {
|
|
14
|
-
|
|
15
|
-
this.request = config.request
|
|
15
|
+
super(config)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// INVITE
|
|
@@ -91,6 +91,30 @@ export class UserAPI {
|
|
|
91
91
|
|
|
92
92
|
// USER
|
|
93
93
|
|
|
94
|
+
createAdminUser = async (
|
|
95
|
+
request?: CreateAdminUserRequest,
|
|
96
|
+
opts?: TestAPIOpts
|
|
97
|
+
) => {
|
|
98
|
+
if (!request) {
|
|
99
|
+
request = {
|
|
100
|
+
email: structures.email(),
|
|
101
|
+
password: generator.string(),
|
|
102
|
+
tenantId: structures.uuid(),
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const res = await this.request
|
|
106
|
+
.post(`/api/global/users/init`)
|
|
107
|
+
.send(request)
|
|
108
|
+
.set(this.config.internalAPIHeaders())
|
|
109
|
+
.expect("Content-Type", /json/)
|
|
110
|
+
.expect(opts?.status ? opts.status : 200)
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
...request,
|
|
114
|
+
userId: res.body._id,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
94
118
|
saveUser = (user: User, status?: number) => {
|
|
95
119
|
return this.request
|
|
96
120
|
.post(`/api/global/users`)
|
|
@@ -107,4 +131,12 @@ export class UserAPI {
|
|
|
107
131
|
.expect("Content-Type", /json/)
|
|
108
132
|
.expect(status ? status : 200)
|
|
109
133
|
}
|
|
134
|
+
|
|
135
|
+
getUser = (userId: string, opts?: TestAPIOpts) => {
|
|
136
|
+
return this.request
|
|
137
|
+
.get(`/api/global/users/${userId}`)
|
|
138
|
+
.set(opts?.headers ? opts.headers : this.config.defaultHeaders())
|
|
139
|
+
.expect("Content-Type", /json/)
|
|
140
|
+
.expect(opts?.status ? opts.status : 200)
|
|
141
|
+
}
|
|
110
142
|
}
|
package/src/tests/index.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import mocks from "./mocks"
|
|
2
|
+
import { generator } from "@budibase/backend-core/tests"
|
|
2
3
|
import TestConfiguration from "./TestConfiguration"
|
|
3
4
|
import structures from "./structures"
|
|
4
5
|
import API from "./api"
|
|
6
|
+
import { v4 as uuid } from "uuid"
|
|
5
7
|
|
|
6
8
|
const pkg = {
|
|
7
9
|
structures,
|
|
10
|
+
generator,
|
|
11
|
+
uuid,
|
|
8
12
|
TENANT_1: structures.TENANT_1,
|
|
9
13
|
mocks,
|
|
10
14
|
TestConfiguration,
|
package/src/tests/jestSetup.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import env from "../environment"
|
|
2
2
|
|
|
3
|
-
env._set("SELF_HOSTED", "
|
|
3
|
+
env._set("SELF_HOSTED", "0")
|
|
4
4
|
env._set("NODE_ENV", "jest")
|
|
5
5
|
env._set("JWT_SECRET", "test-jwtsecret")
|
|
6
6
|
env._set("LOG_LEVEL", "silent")
|
|
@@ -8,9 +8,15 @@ env._set("MULTI_TENANCY", true)
|
|
|
8
8
|
env._set("MINIO_URL", "http://localhost")
|
|
9
9
|
env._set("MINIO_ACCESS_KEY", "test")
|
|
10
10
|
env._set("MINIO_SECRET_KEY", "test")
|
|
11
|
+
env._set("PLATFORM_URL", "http://localhost:10000")
|
|
12
|
+
env._set("INTERNAL_API_KEY", "test")
|
|
13
|
+
env._set("DISABLE_ACCOUNT_PORTAL", false)
|
|
11
14
|
|
|
12
15
|
import { mocks } from "@budibase/backend-core/tests"
|
|
13
16
|
|
|
17
|
+
// must explicitly enable fetch mock
|
|
18
|
+
mocks.fetch.enable()
|
|
19
|
+
|
|
14
20
|
// mock all dates to 2020-01-01T00:00:00.000Z
|
|
15
21
|
// use tk.reset() to use real dates in individual tests
|
|
16
22
|
const tk = require("timekeeper")
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { structures } from "@budibase/backend-core/tests"
|
|
1
2
|
import configs from "./configs"
|
|
2
3
|
import * as users from "./users"
|
|
3
4
|
import * as groups from "./groups"
|
|
4
|
-
import
|
|
5
|
+
import { v4 as uuid } from "uuid"
|
|
5
6
|
|
|
6
7
|
const TENANT_ID = "default"
|
|
7
8
|
const TENANT_1 = "tenant1"
|
|
8
9
|
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306"
|
|
9
10
|
|
|
10
11
|
const pkg = {
|
|
12
|
+
...structures,
|
|
13
|
+
uuid,
|
|
11
14
|
configs,
|
|
12
15
|
users,
|
|
13
|
-
accounts,
|
|
14
16
|
TENANT_ID,
|
|
15
17
|
TENANT_1,
|
|
16
18
|
CSRF_TOKEN,
|
package/__mocks__/node-fetch.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
jest.mock("node-fetch", () => jest.fn())
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const Router = require("@koa/router")
|
|
2
|
-
const controller = require("../../controllers/system/tenants")
|
|
3
|
-
const { adminOnly } = require("@budibase/backend-core/auth")
|
|
4
|
-
|
|
5
|
-
const router = new Router()
|
|
6
|
-
|
|
7
|
-
router
|
|
8
|
-
.get("/api/system/tenants/:tenantId/exists", controller.exists)
|
|
9
|
-
.get("/api/system/tenants", adminOnly, controller.fetch)
|
|
10
|
-
.delete("/api/system/tenants/:tenantId", adminOnly, controller.delete)
|
|
11
|
-
|
|
12
|
-
module.exports = router
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Account, AuthType, Hosting, CloudAccount } from "@budibase/types"
|
|
2
|
-
import { v4 as uuid } from "uuid"
|
|
3
|
-
import { utils } from "@budibase/backend-core"
|
|
4
|
-
|
|
5
|
-
export const account = (): Account => {
|
|
6
|
-
return {
|
|
7
|
-
email: `${uuid()}@test.com`,
|
|
8
|
-
tenantId: utils.newid(),
|
|
9
|
-
hosting: Hosting.SELF,
|
|
10
|
-
authType: AuthType.SSO,
|
|
11
|
-
accountId: uuid(),
|
|
12
|
-
createdAt: Date.now(),
|
|
13
|
-
verified: true,
|
|
14
|
-
verificationSent: true,
|
|
15
|
-
tier: "FREE",
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const cloudAccount = (): CloudAccount => {
|
|
20
|
-
return {
|
|
21
|
-
...account(),
|
|
22
|
-
budibaseUserId: uuid(),
|
|
23
|
-
}
|
|
24
|
-
}
|