@budibase/server 1.0.27-alpha.2 → 1.0.27-alpha.23
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__/node-fetch.ts +18 -0
- package/builder/assets/{index.5522fcd5.css → index.39e01193.css} +1 -1
- package/builder/assets/{index.e9e2c4d7.js → index.52b37e8a.js} +247 -242
- package/builder/assets/{vendor.f9faf6ab.js → vendor.10e2ad1b.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1128 -968
- package/coverage/coverage-final.json +70 -70
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +3 -3
- package/coverage/lcov-report/api/controllers/application.js.html +73 -64
- package/coverage/lcov-report/api/controllers/auth.js.html +2 -2
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +13 -4
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +150 -48
- package/coverage/lcov-report/api/controllers/dev.js.html +3 -3
- package/coverage/lcov-report/api/controllers/hosting.js.html +3 -3
- package/coverage/lcov-report/api/controllers/index.html +20 -20
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +3 -3
- package/coverage/lcov-report/api/controllers/query/index.html +21 -21
- package/coverage/lcov-report/api/controllers/query/index.js.html +102 -120
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -3
- package/coverage/lcov-report/api/controllers/role.js.html +2 -2
- package/coverage/lcov-report/api/controllers/routing.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +11 -11
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +38 -11
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +2 -2
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +14 -5
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +2 -2
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +6 -6
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +2 -2
- package/coverage/lcov-report/api/routes/application.js.html +2 -2
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +2 -2
- package/coverage/lcov-report/api/routes/backup.js.html +2 -2
- package/coverage/lcov-report/api/routes/cloud.js.html +2 -2
- package/coverage/lcov-report/api/routes/component.js.html +2 -2
- package/coverage/lcov-report/api/routes/datasource.js.html +2 -2
- package/coverage/lcov-report/api/routes/deploy.js.html +2 -2
- package/coverage/lcov-report/api/routes/dev.js.html +2 -2
- package/coverage/lcov-report/api/routes/hosting.js.html +2 -2
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +2 -2
- package/coverage/lcov-report/api/routes/layout.js.html +2 -2
- package/coverage/lcov-report/api/routes/metadata.js.html +2 -2
- package/coverage/lcov-report/api/routes/permission.js.html +12 -3
- package/coverage/lcov-report/api/routes/query.js.html +25 -4
- package/coverage/lcov-report/api/routes/role.js.html +2 -2
- package/coverage/lcov-report/api/routes/routing.js.html +2 -2
- package/coverage/lcov-report/api/routes/row.js.html +2 -2
- package/coverage/lcov-report/api/routes/screen.js.html +2 -2
- package/coverage/lcov-report/api/routes/script.js.html +2 -2
- package/coverage/lcov-report/api/routes/static.js.html +2 -2
- package/coverage/lcov-report/api/routes/table.js.html +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +2 -2
- package/coverage/lcov-report/api/routes/user.js.html +2 -2
- package/coverage/lcov-report/api/routes/view.js.html +2 -2
- package/coverage/lcov-report/api/routes/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +2 -2
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +32 -8
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +11 -11
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/automations/utils.js.html +6 -6
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +4 -4
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +2 -2
- package/coverage/lcov-report/db/client.js.html +2 -2
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +19 -19
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +69 -69
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +12 -12
- package/coverage/lcov-report/middleware/builder.js.html +10 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +79 -40
- package/coverage/lcov-report/middleware/index.html +10 -10
- package/coverage/lcov-report/middleware/joi-validator.js.html +9 -9
- package/coverage/lcov-report/middleware/resourceId.js.html +18 -18
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +2 -2
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +3 -3
- package/coverage/lcov-report/threads/index.html +31 -31
- package/coverage/lcov-report/threads/index.js.html +12 -12
- package/coverage/lcov-report/threads/query.js.html +531 -87
- package/coverage/lcov-report/threads/utils.js.html +210 -15
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +2 -2
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +28 -19
- package/coverage/lcov-report/utilities/index.html +4 -4
- package/coverage/lcov-report/utilities/index.js.html +13 -13
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +19 -19
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +211 -10
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +13 -4
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +22 -22
- package/coverage/lcov.info +1921 -1630
- package/dist/api/controllers/apikeys.js +2 -2
- package/dist/api/controllers/application.js +4 -4
- package/dist/api/controllers/auth.js +1 -1
- package/dist/api/controllers/cloud.js +2 -2
- package/dist/api/controllers/datasource.js +29 -0
- package/dist/api/controllers/deploy/index.js +2 -2
- package/dist/api/controllers/dev.js +2 -2
- package/dist/api/controllers/hosting.js +2 -2
- package/dist/api/controllers/permission.js +2 -2
- package/dist/api/controllers/query/import/sources/base/index.js +2 -1
- package/dist/api/controllers/query/import/sources/curl.js +11 -5
- package/dist/api/controllers/query/import/sources/openapi2.js +8 -5
- package/dist/api/controllers/query/index.js +46 -47
- package/dist/api/controllers/query/validation.js +2 -1
- package/dist/api/controllers/role.js +1 -1
- package/dist/api/controllers/routing.js +1 -1
- package/dist/api/controllers/row/internal.js +14 -6
- package/dist/api/controllers/row/internalSearch.js +1 -1
- package/dist/api/controllers/screen.js +1 -1
- package/dist/api/controllers/user.js +3 -3
- package/dist/api/controllers/webhook.js +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes/apikeys.js +1 -1
- package/dist/api/routes/application.js +1 -1
- package/dist/api/routes/automation.js +1 -1
- package/dist/api/routes/backup.js +1 -1
- package/dist/api/routes/cloud.js +1 -1
- package/dist/api/routes/component.js +1 -1
- package/dist/api/routes/datasource.js +1 -1
- package/dist/api/routes/deploy.js +1 -1
- package/dist/api/routes/dev.js +1 -1
- package/dist/api/routes/hosting.js +1 -1
- package/dist/api/routes/integration.js +1 -1
- package/dist/api/routes/layout.js +1 -1
- package/dist/api/routes/metadata.js +1 -1
- package/dist/api/routes/permission.js +1 -1
- package/dist/api/routes/query.js +4 -2
- package/dist/api/routes/role.js +1 -1
- package/dist/api/routes/routing.js +1 -1
- package/dist/api/routes/row.js +1 -1
- package/dist/api/routes/screen.js +1 -1
- package/dist/api/routes/script.js +1 -1
- package/dist/api/routes/static.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/templates.js +1 -1
- package/dist/api/routes/tests/utilities/TestFunctions.js +1 -1
- package/dist/api/routes/user.js +1 -1
- package/dist/api/routes/view.js +1 -1
- package/dist/api/routes/webhook.js +1 -1
- package/dist/app.js +1 -1
- package/dist/automations/bullboard.js +1 -1
- package/dist/automations/steps/executeQuery.js +9 -2
- package/dist/automations/utils.js +1 -1
- package/dist/constants/index.js +3 -3
- package/dist/constants/screens.js +1 -1
- package/dist/db/client.js +1 -1
- package/dist/db/utils.js +1 -1
- package/dist/environment.js +1 -0
- package/dist/integrations/base/sqlTable.js +1 -1
- package/dist/integrations/dynamodb.js +19 -0
- package/dist/integrations/rest.js +71 -22
- package/dist/integrations/s3.js +17 -8
- package/dist/integrations/utils.js +40 -37
- package/dist/middleware/authorized.js +2 -2
- package/dist/middleware/builder.js +2 -2
- package/dist/middleware/currentapp.js +15 -6
- package/dist/middleware/usageQuota.js +1 -1
- package/dist/package.json +5 -4
- package/dist/tests/utilities/TestConfiguration.js +55 -8
- package/dist/tests/utilities/structures.js +2 -2
- package/dist/threads/automation.js +2 -2
- package/dist/threads/query.js +195 -50
- package/dist/threads/utils.js +62 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +1 -1
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/dist/utilities/global.js +5 -5
- package/dist/utilities/index.js +2 -2
- package/dist/utilities/redis.js +1 -1
- package/dist/utilities/rowProcessor/index.js +63 -0
- package/dist/utilities/security.js +2 -2
- package/dist/utilities/usageQuota.js +2 -2
- package/dist/utilities/workerRequests.js +3 -3
- package/package.json +6 -5
- package/scripts/replicateApp.js +1 -1
- package/src/api/controllers/apikeys.js +2 -2
- package/src/api/controllers/application.js +7 -4
- package/src/api/controllers/auth.js +1 -1
- package/src/api/controllers/cloud.js +5 -2
- package/src/api/controllers/datasource.js +34 -0
- package/src/api/controllers/deploy/index.js +2 -2
- package/src/api/controllers/dev.js +2 -2
- package/src/api/controllers/hosting.js +2 -2
- package/src/api/controllers/permission.js +2 -2
- package/src/api/controllers/query/import/sources/base/index.ts +3 -1
- package/src/api/controllers/query/import/sources/curl.ts +12 -4
- package/src/api/controllers/query/import/sources/openapi2.ts +9 -5
- package/src/api/controllers/query/import/sources/tests/curl/curl.spec.js +2 -3
- package/src/api/controllers/query/import/sources/tests/openapi2/openapi2.spec.js +6 -7
- package/src/api/controllers/query/import/tests/index.spec.js +0 -6
- package/src/api/controllers/query/index.js +49 -55
- package/src/api/controllers/query/validation.js +2 -1
- package/src/api/controllers/role.js +1 -1
- package/src/api/controllers/routing.js +1 -1
- package/src/api/controllers/row/internal.js +14 -5
- package/src/api/controllers/row/internalSearch.js +1 -1
- package/src/api/controllers/screen.js +1 -1
- package/src/api/controllers/user.js +6 -3
- package/src/api/controllers/webhook.js +1 -1
- package/src/api/index.js +1 -1
- package/src/api/routes/apikeys.js +1 -1
- package/src/api/routes/application.js +1 -1
- package/src/api/routes/automation.js +1 -1
- package/src/api/routes/backup.js +1 -1
- package/src/api/routes/cloud.js +1 -1
- package/src/api/routes/component.js +1 -1
- package/src/api/routes/datasource.js +1 -1
- package/src/api/routes/deploy.js +1 -1
- package/src/api/routes/dev.js +1 -1
- package/src/api/routes/hosting.js +1 -1
- package/src/api/routes/integration.js +1 -1
- package/src/api/routes/layout.js +1 -1
- package/src/api/routes/metadata.js +1 -1
- package/src/api/routes/permission.js +4 -1
- package/src/api/routes/query.js +9 -2
- package/src/api/routes/role.js +1 -1
- package/src/api/routes/routing.js +1 -1
- package/src/api/routes/row.js +1 -1
- package/src/api/routes/screen.js +1 -1
- package/src/api/routes/script.js +1 -1
- package/src/api/routes/static.js +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/templates.js +1 -1
- package/src/api/routes/tests/datasource.spec.js +45 -0
- package/src/api/routes/tests/permissions.spec.js +1 -1
- package/src/api/routes/tests/query.spec.js +70 -1
- package/src/api/routes/tests/role.spec.js +2 -2
- package/src/api/routes/tests/routing.spec.js +1 -1
- package/src/api/routes/tests/user.spec.js +1 -1
- package/src/api/routes/tests/utilities/TestFunctions.js +1 -1
- package/src/api/routes/user.js +1 -1
- package/src/api/routes/view.js +1 -1
- package/src/api/routes/webhook.js +1 -1
- package/src/app.ts +1 -1
- package/src/automations/bullboard.js +1 -1
- package/src/automations/steps/executeQuery.js +10 -2
- package/src/automations/utils.js +1 -1
- package/src/constants/index.js +3 -3
- package/src/constants/screens.js +1 -1
- package/src/db/client.js +1 -1
- package/src/db/utils.js +1 -1
- package/src/definitions/datasource.ts +25 -0
- package/src/environment.js +1 -0
- package/src/integrations/base/sqlTable.ts +1 -1
- package/src/integrations/dynamodb.ts +18 -0
- package/src/integrations/rest.ts +103 -20
- package/src/integrations/s3.ts +18 -7
- package/src/integrations/tests/rest.spec.js +287 -24
- package/src/integrations/utils.ts +8 -7
- package/src/middleware/authorized.js +2 -2
- package/src/middleware/builder.js +2 -2
- package/src/middleware/currentapp.js +20 -7
- package/src/middleware/tests/authorized.spec.js +2 -2
- package/src/middleware/tests/currentapp.spec.js +35 -41
- package/src/middleware/tests/usageQuota.spec.js +1 -1
- package/src/middleware/usageQuota.js +1 -1
- package/src/tests/utilities/TestConfiguration.js +65 -8
- package/src/tests/utilities/structures.js +2 -2
- package/src/threads/automation.js +2 -2
- package/src/threads/query.js +203 -55
- package/src/threads/utils.js +66 -1
- package/src/utilities/budibaseDir.js +1 -1
- package/src/utilities/fileSystem/utilities.js +3 -1
- package/src/utilities/global.js +8 -5
- package/src/utilities/index.js +2 -2
- package/src/utilities/redis.js +1 -1
- package/src/utilities/rowProcessor/index.js +67 -0
- package/src/utilities/security.js +5 -2
- package/src/utilities/usageQuota.js +2 -2
- package/src/utilities/workerRequests.js +3 -3
|
@@ -4,19 +4,23 @@ jest.mock("node-fetch", () =>
|
|
|
4
4
|
raw: () => {
|
|
5
5
|
return { "content-type": ["application/json"] }
|
|
6
6
|
},
|
|
7
|
-
get: () => ["application/json"]
|
|
7
|
+
get: () => ["application/json"],
|
|
8
8
|
},
|
|
9
|
-
json: jest.fn()
|
|
10
|
-
|
|
9
|
+
json: jest.fn(() => ({
|
|
10
|
+
my_next_cursor: 123,
|
|
11
|
+
})),
|
|
12
|
+
text: jest.fn(),
|
|
11
13
|
}))
|
|
12
14
|
)
|
|
13
15
|
const fetch = require("node-fetch")
|
|
14
16
|
const RestIntegration = require("../rest")
|
|
15
17
|
const { AuthType } = require("../rest")
|
|
18
|
+
const FormData = require("form-data")
|
|
19
|
+
const { URLSearchParams } = require("url")
|
|
16
20
|
|
|
17
21
|
const HEADERS = {
|
|
18
|
-
|
|
19
|
-
"Content-Type": "application/json"
|
|
22
|
+
Accept: "application/json",
|
|
23
|
+
"Content-Type": "application/json",
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
class TestConfiguration {
|
|
@@ -165,17 +169,20 @@ describe("REST Integration", () => {
|
|
|
165
169
|
status: 200,
|
|
166
170
|
json: json ? async () => json : undefined,
|
|
167
171
|
text: text ? async () => text : undefined,
|
|
168
|
-
headers: {
|
|
172
|
+
headers: {
|
|
173
|
+
get: key => (key === "content-length" ? 100 : header),
|
|
174
|
+
raw: () => ({ "content-type": header }),
|
|
175
|
+
},
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
178
|
|
|
172
179
|
it("should be able to parse JSON response", async () => {
|
|
173
|
-
const input = buildInput({a: 1}, null, "application/json")
|
|
180
|
+
const input = buildInput({ a: 1 }, null, "application/json")
|
|
174
181
|
const output = await config.integration.parseResponse(input)
|
|
175
|
-
expect(output.data).toEqual({a: 1})
|
|
182
|
+
expect(output.data).toEqual({ a: 1 })
|
|
176
183
|
expect(output.info.code).toEqual(200)
|
|
177
184
|
expect(output.info.size).toEqual("100B")
|
|
178
|
-
expect(output.extra.raw).toEqual(JSON.stringify({a: 1}))
|
|
185
|
+
expect(output.extra.raw).toEqual(JSON.stringify({ a: 1 }))
|
|
179
186
|
expect(output.extra.headers["content-type"]).toEqual("application/json")
|
|
180
187
|
})
|
|
181
188
|
|
|
@@ -192,7 +199,7 @@ describe("REST Integration", () => {
|
|
|
192
199
|
const text = "<root><a>1</a><b>2</b></root>"
|
|
193
200
|
const input = buildInput(null, text, "application/xml")
|
|
194
201
|
const output = await config.integration.parseResponse(input)
|
|
195
|
-
expect(output.data).toEqual({a: "1", b: "2"})
|
|
202
|
+
expect(output.data).toEqual({ a: "1", b: "2" })
|
|
196
203
|
expect(output.extra.raw).toEqual(text)
|
|
197
204
|
expect(output.extra.headers["content-type"]).toEqual("application/xml")
|
|
198
205
|
})
|
|
@@ -202,53 +209,309 @@ describe("REST Integration", () => {
|
|
|
202
209
|
const basicAuth = {
|
|
203
210
|
_id: "c59c14bd1898a43baa08da68959b24686",
|
|
204
211
|
name: "basic-1",
|
|
205
|
-
type
|
|
206
|
-
config
|
|
212
|
+
type: AuthType.BASIC,
|
|
213
|
+
config: {
|
|
207
214
|
username: "user",
|
|
208
|
-
password: "password"
|
|
209
|
-
}
|
|
215
|
+
password: "password",
|
|
216
|
+
},
|
|
210
217
|
}
|
|
211
|
-
|
|
218
|
+
|
|
212
219
|
const bearerAuth = {
|
|
213
220
|
_id: "0d91d732f34e4befabeff50b392a8ff3",
|
|
214
221
|
name: "bearer-1",
|
|
215
|
-
type
|
|
216
|
-
config
|
|
217
|
-
|
|
218
|
-
}
|
|
222
|
+
type: AuthType.BEARER,
|
|
223
|
+
config: {
|
|
224
|
+
token: "mytoken",
|
|
225
|
+
},
|
|
219
226
|
}
|
|
220
227
|
|
|
221
228
|
beforeEach(() => {
|
|
222
229
|
config = new TestConfiguration({
|
|
223
230
|
url: BASE_URL,
|
|
224
|
-
authConfigs
|
|
231
|
+
authConfigs: [basicAuth, bearerAuth],
|
|
225
232
|
})
|
|
226
233
|
})
|
|
227
234
|
|
|
228
235
|
it("adds basic auth", async () => {
|
|
229
236
|
const query = {
|
|
230
|
-
authConfigId: "c59c14bd1898a43baa08da68959b24686"
|
|
237
|
+
authConfigId: "c59c14bd1898a43baa08da68959b24686",
|
|
231
238
|
}
|
|
232
239
|
await config.integration.read(query)
|
|
233
240
|
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/?`, {
|
|
234
241
|
method: "GET",
|
|
235
242
|
headers: {
|
|
236
|
-
Authorization: "Basic dXNlcjpwYXNzd29yZA=="
|
|
243
|
+
Authorization: "Basic dXNlcjpwYXNzd29yZA==",
|
|
237
244
|
},
|
|
238
245
|
})
|
|
239
246
|
})
|
|
240
247
|
|
|
241
248
|
it("adds bearer auth", async () => {
|
|
242
249
|
const query = {
|
|
243
|
-
authConfigId: "0d91d732f34e4befabeff50b392a8ff3"
|
|
250
|
+
authConfigId: "0d91d732f34e4befabeff50b392a8ff3",
|
|
244
251
|
}
|
|
245
252
|
await config.integration.read(query)
|
|
246
253
|
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/?`, {
|
|
247
254
|
method: "GET",
|
|
248
255
|
headers: {
|
|
249
|
-
Authorization: "Bearer mytoken"
|
|
256
|
+
Authorization: "Bearer mytoken",
|
|
257
|
+
},
|
|
258
|
+
})
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
describe("page based pagination", () => {
|
|
263
|
+
it("can paginate using query params", async () => {
|
|
264
|
+
const pageParam = "my_page_param"
|
|
265
|
+
const sizeParam = "my_size_param"
|
|
266
|
+
const pageValue = 3
|
|
267
|
+
const sizeValue = 10
|
|
268
|
+
const query = {
|
|
269
|
+
path: "api",
|
|
270
|
+
pagination: {
|
|
271
|
+
type: "page",
|
|
272
|
+
location: "query",
|
|
273
|
+
pageParam,
|
|
274
|
+
sizeParam,
|
|
275
|
+
},
|
|
276
|
+
paginationValues: {
|
|
277
|
+
page: pageValue,
|
|
278
|
+
limit: sizeValue,
|
|
279
|
+
},
|
|
280
|
+
}
|
|
281
|
+
await config.integration.read(query)
|
|
282
|
+
expect(fetch).toHaveBeenCalledWith(
|
|
283
|
+
`${BASE_URL}/api?${pageParam}=${pageValue}&${sizeParam}=${sizeValue}&`,
|
|
284
|
+
{
|
|
285
|
+
headers: {},
|
|
286
|
+
method: "GET",
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
it("can paginate using JSON request body", async () => {
|
|
292
|
+
const pageParam = "my_page_param"
|
|
293
|
+
const sizeParam = "my_size_param"
|
|
294
|
+
const pageValue = 3
|
|
295
|
+
const sizeValue = 10
|
|
296
|
+
const query = {
|
|
297
|
+
bodyType: "json",
|
|
298
|
+
path: "api",
|
|
299
|
+
pagination: {
|
|
300
|
+
type: "page",
|
|
301
|
+
location: "body",
|
|
302
|
+
pageParam,
|
|
303
|
+
sizeParam,
|
|
304
|
+
},
|
|
305
|
+
paginationValues: {
|
|
306
|
+
page: pageValue,
|
|
307
|
+
limit: sizeValue,
|
|
308
|
+
},
|
|
309
|
+
}
|
|
310
|
+
await config.integration.create(query)
|
|
311
|
+
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?`, {
|
|
312
|
+
body: JSON.stringify({
|
|
313
|
+
[pageParam]: pageValue,
|
|
314
|
+
[sizeParam]: sizeValue,
|
|
315
|
+
}),
|
|
316
|
+
headers: {
|
|
317
|
+
"Content-Type": "application/json",
|
|
318
|
+
},
|
|
319
|
+
method: "POST",
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
it("can paginate using form-data request body", async () => {
|
|
324
|
+
const pageParam = "my_page_param"
|
|
325
|
+
const sizeParam = "my_size_param"
|
|
326
|
+
const pageValue = 3
|
|
327
|
+
const sizeValue = 10
|
|
328
|
+
const query = {
|
|
329
|
+
bodyType: "form",
|
|
330
|
+
path: "api",
|
|
331
|
+
pagination: {
|
|
332
|
+
type: "page",
|
|
333
|
+
location: "body",
|
|
334
|
+
pageParam,
|
|
335
|
+
sizeParam,
|
|
336
|
+
},
|
|
337
|
+
paginationValues: {
|
|
338
|
+
page: pageValue,
|
|
339
|
+
limit: sizeValue,
|
|
340
|
+
},
|
|
341
|
+
}
|
|
342
|
+
await config.integration.create(query)
|
|
343
|
+
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?`, {
|
|
344
|
+
body: expect.any(FormData),
|
|
345
|
+
headers: {},
|
|
346
|
+
method: "POST",
|
|
347
|
+
})
|
|
348
|
+
const sentData = JSON.stringify(fetch.mock.calls[0][1].body)
|
|
349
|
+
expect(sentData).toContain(pageParam)
|
|
350
|
+
expect(sentData).toContain(sizeParam)
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
it("can paginate using form-encoded request body", async () => {
|
|
354
|
+
const pageParam = "my_page_param"
|
|
355
|
+
const sizeParam = "my_size_param"
|
|
356
|
+
const pageValue = 3
|
|
357
|
+
const sizeValue = 10
|
|
358
|
+
const query = {
|
|
359
|
+
bodyType: "encoded",
|
|
360
|
+
path: "api",
|
|
361
|
+
pagination: {
|
|
362
|
+
type: "page",
|
|
363
|
+
location: "body",
|
|
364
|
+
pageParam,
|
|
365
|
+
sizeParam,
|
|
366
|
+
},
|
|
367
|
+
paginationValues: {
|
|
368
|
+
page: pageValue,
|
|
369
|
+
limit: sizeValue,
|
|
370
|
+
},
|
|
371
|
+
}
|
|
372
|
+
await config.integration.create(query)
|
|
373
|
+
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?`, {
|
|
374
|
+
body: expect.any(URLSearchParams),
|
|
375
|
+
headers: {},
|
|
376
|
+
method: "POST",
|
|
377
|
+
})
|
|
378
|
+
const sentData = fetch.mock.calls[0][1].body
|
|
379
|
+
expect(sentData.has(pageParam))
|
|
380
|
+
expect(sentData.get(pageParam)).toEqual(pageValue.toString())
|
|
381
|
+
expect(sentData.has(sizeParam))
|
|
382
|
+
expect(sentData.get(sizeParam)).toEqual(sizeValue.toString())
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
describe("cursor based pagination", () => {
|
|
387
|
+
it("can paginate using query params", async () => {
|
|
388
|
+
const pageParam = "my_page_param"
|
|
389
|
+
const sizeParam = "my_size_param"
|
|
390
|
+
const pageValue = 3
|
|
391
|
+
const sizeValue = 10
|
|
392
|
+
const query = {
|
|
393
|
+
path: "api",
|
|
394
|
+
pagination: {
|
|
395
|
+
type: "cursor",
|
|
396
|
+
location: "query",
|
|
397
|
+
pageParam,
|
|
398
|
+
sizeParam,
|
|
399
|
+
responseParam: "my_next_cursor",
|
|
400
|
+
},
|
|
401
|
+
paginationValues: {
|
|
402
|
+
page: pageValue,
|
|
403
|
+
limit: sizeValue,
|
|
404
|
+
},
|
|
405
|
+
}
|
|
406
|
+
const res = await config.integration.read(query)
|
|
407
|
+
expect(fetch).toHaveBeenCalledWith(
|
|
408
|
+
`${BASE_URL}/api?${pageParam}=${pageValue}&${sizeParam}=${sizeValue}&`,
|
|
409
|
+
{
|
|
410
|
+
headers: {},
|
|
411
|
+
method: "GET",
|
|
412
|
+
}
|
|
413
|
+
)
|
|
414
|
+
expect(res.pagination.cursor).toEqual(123)
|
|
415
|
+
})
|
|
416
|
+
|
|
417
|
+
it("can paginate using JSON request body", async () => {
|
|
418
|
+
const pageParam = "my_page_param"
|
|
419
|
+
const sizeParam = "my_size_param"
|
|
420
|
+
const pageValue = 3
|
|
421
|
+
const sizeValue = 10
|
|
422
|
+
const query = {
|
|
423
|
+
bodyType: "json",
|
|
424
|
+
path: "api",
|
|
425
|
+
pagination: {
|
|
426
|
+
type: "page",
|
|
427
|
+
location: "body",
|
|
428
|
+
pageParam,
|
|
429
|
+
sizeParam,
|
|
430
|
+
responseParam: "my_next_cursor",
|
|
431
|
+
},
|
|
432
|
+
paginationValues: {
|
|
433
|
+
page: pageValue,
|
|
434
|
+
limit: sizeValue,
|
|
435
|
+
},
|
|
436
|
+
}
|
|
437
|
+
const res = await config.integration.create(query)
|
|
438
|
+
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?`, {
|
|
439
|
+
body: JSON.stringify({
|
|
440
|
+
[pageParam]: pageValue,
|
|
441
|
+
[sizeParam]: sizeValue,
|
|
442
|
+
}),
|
|
443
|
+
headers: {
|
|
444
|
+
"Content-Type": "application/json",
|
|
445
|
+
},
|
|
446
|
+
method: "POST",
|
|
447
|
+
})
|
|
448
|
+
expect(res.pagination.cursor).toEqual(123)
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
it("can paginate using form-data request body", async () => {
|
|
452
|
+
const pageParam = "my_page_param"
|
|
453
|
+
const sizeParam = "my_size_param"
|
|
454
|
+
const pageValue = 3
|
|
455
|
+
const sizeValue = 10
|
|
456
|
+
const query = {
|
|
457
|
+
bodyType: "form",
|
|
458
|
+
path: "api",
|
|
459
|
+
pagination: {
|
|
460
|
+
type: "page",
|
|
461
|
+
location: "body",
|
|
462
|
+
pageParam,
|
|
463
|
+
sizeParam,
|
|
464
|
+
responseParam: "my_next_cursor",
|
|
465
|
+
},
|
|
466
|
+
paginationValues: {
|
|
467
|
+
page: pageValue,
|
|
468
|
+
limit: sizeValue,
|
|
250
469
|
},
|
|
470
|
+
}
|
|
471
|
+
const res = await config.integration.create(query)
|
|
472
|
+
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?`, {
|
|
473
|
+
body: expect.any(FormData),
|
|
474
|
+
headers: {},
|
|
475
|
+
method: "POST",
|
|
476
|
+
})
|
|
477
|
+
const sentData = JSON.stringify(fetch.mock.calls[0][1].body)
|
|
478
|
+
expect(sentData).toContain(pageParam)
|
|
479
|
+
expect(sentData).toContain(sizeParam)
|
|
480
|
+
expect(res.pagination.cursor).toEqual(123)
|
|
481
|
+
})
|
|
482
|
+
|
|
483
|
+
it("can paginate using form-encoded request body", async () => {
|
|
484
|
+
const pageParam = "my_page_param"
|
|
485
|
+
const sizeParam = "my_size_param"
|
|
486
|
+
const pageValue = 3
|
|
487
|
+
const sizeValue = 10
|
|
488
|
+
const query = {
|
|
489
|
+
bodyType: "encoded",
|
|
490
|
+
path: "api",
|
|
491
|
+
pagination: {
|
|
492
|
+
type: "page",
|
|
493
|
+
location: "body",
|
|
494
|
+
pageParam,
|
|
495
|
+
sizeParam,
|
|
496
|
+
responseParam: "my_next_cursor",
|
|
497
|
+
},
|
|
498
|
+
paginationValues: {
|
|
499
|
+
page: pageValue,
|
|
500
|
+
limit: sizeValue,
|
|
501
|
+
},
|
|
502
|
+
}
|
|
503
|
+
const res = await config.integration.create(query)
|
|
504
|
+
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?`, {
|
|
505
|
+
body: expect.any(URLSearchParams),
|
|
506
|
+
headers: {},
|
|
507
|
+
method: "POST",
|
|
251
508
|
})
|
|
509
|
+
const sentData = fetch.mock.calls[0][1].body
|
|
510
|
+
expect(sentData.has(pageParam))
|
|
511
|
+
expect(sentData.get(pageParam)).toEqual(pageValue.toString())
|
|
512
|
+
expect(sentData.has(sizeParam))
|
|
513
|
+
expect(sentData.get(sizeParam)).toEqual(sizeValue.toString())
|
|
514
|
+
expect(res.pagination.cursor).toEqual(123)
|
|
252
515
|
})
|
|
253
516
|
})
|
|
254
517
|
})
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { SqlQuery } from "../definitions/datasource"
|
|
2
2
|
import { Datasource, Table } from "../definitions/common"
|
|
3
3
|
import { SourceNames } from "../definitions/datasource"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
FieldTypes,
|
|
7
|
-
BuildSchemaErrors,
|
|
8
|
-
InvalidColumns,
|
|
9
|
-
} = require("../constants")
|
|
4
|
+
import { DocumentTypes, SEPARATOR } from "../db/utils"
|
|
5
|
+
import { FieldTypes, BuildSchemaErrors, InvalidColumns } from "../constants"
|
|
10
6
|
|
|
11
7
|
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
|
12
8
|
const ROW_ID_REGEX = /^\[.*]$/g
|
|
@@ -158,7 +154,12 @@ function copyExistingPropsOver(
|
|
|
158
154
|
if (!existingTableSchema.hasOwnProperty(key)) {
|
|
159
155
|
continue
|
|
160
156
|
}
|
|
161
|
-
if (
|
|
157
|
+
if (
|
|
158
|
+
existingTableSchema[key].type === FieldTypes.LINK ||
|
|
159
|
+
existingTableSchema[key].type === FieldTypes.OPTIONS ||
|
|
160
|
+
((!table.schema[key] || table.schema[key].type === FieldTypes.NUMBER) &&
|
|
161
|
+
existingTableSchema[key].type === FieldTypes.BOOLEAN)
|
|
162
|
+
) {
|
|
162
163
|
table.schema[key] = existingTableSchema[key]
|
|
163
164
|
}
|
|
164
165
|
}
|
|
@@ -2,11 +2,11 @@ const {
|
|
|
2
2
|
getUserRoleHierarchy,
|
|
3
3
|
getRequiredResourceRole,
|
|
4
4
|
BUILTIN_ROLE_IDS,
|
|
5
|
-
} = require("@budibase/
|
|
5
|
+
} = require("@budibase/backend-core/roles")
|
|
6
6
|
const {
|
|
7
7
|
PermissionTypes,
|
|
8
8
|
doesHaveBasePermission,
|
|
9
|
-
} = require("@budibase/
|
|
9
|
+
} = require("@budibase/backend-core/permissions")
|
|
10
10
|
const builderMiddleware = require("./builder")
|
|
11
11
|
const { isWebhookEndpoint } = require("./utils")
|
|
12
12
|
|
|
@@ -7,8 +7,8 @@ const {
|
|
|
7
7
|
} = require("../utilities/redis")
|
|
8
8
|
const CouchDB = require("../db")
|
|
9
9
|
const { DocumentTypes } = require("../db/utils")
|
|
10
|
-
const { PermissionTypes } = require("@budibase/
|
|
11
|
-
const { app: appCache } = require("@budibase/
|
|
10
|
+
const { PermissionTypes } = require("@budibase/backend-core/permissions")
|
|
11
|
+
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
12
12
|
|
|
13
13
|
const DEBOUNCE_TIME_SEC = 30
|
|
14
14
|
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const {
|
|
2
|
+
getAppId,
|
|
3
|
+
setCookie,
|
|
4
|
+
getCookie,
|
|
5
|
+
clearCookie,
|
|
6
|
+
} = require("@budibase/backend-core/utils")
|
|
7
|
+
const { Cookies } = require("@budibase/backend-core/constants")
|
|
8
|
+
const { getRole } = require("@budibase/backend-core/roles")
|
|
9
|
+
const { BUILTIN_ROLE_IDS } = require("@budibase/backend-core/roles")
|
|
6
10
|
const { generateUserMetadataID, isDevAppID } = require("../db/utils")
|
|
7
|
-
const { dbExists } = require("@budibase/
|
|
8
|
-
const { isUserInAppTenant } = require("@budibase/
|
|
11
|
+
const { dbExists } = require("@budibase/backend-core/db")
|
|
12
|
+
const { isUserInAppTenant } = require("@budibase/backend-core/tenancy")
|
|
9
13
|
const { getCachedSelf } = require("../utilities/global")
|
|
10
14
|
const CouchDB = require("../db")
|
|
11
15
|
const env = require("../environment")
|
|
@@ -43,6 +47,15 @@ module.exports = async (ctx, next) => {
|
|
|
43
47
|
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global)
|
|
44
48
|
) {
|
|
45
49
|
clearCookie(ctx, Cookies.CurrentApp)
|
|
50
|
+
// have to set the return url on the server side as client side is not available
|
|
51
|
+
setCookie(ctx, ctx.url, Cookies.RETURN_URL, {
|
|
52
|
+
// don't sign so the browser can easily read
|
|
53
|
+
sign: false,
|
|
54
|
+
// use the request domain to match how ui handles the return url cookie.
|
|
55
|
+
// it's important we don't use the shared domain here as the builder
|
|
56
|
+
// can't delete from it without awareness of the domain.
|
|
57
|
+
requestDomain: true,
|
|
58
|
+
})
|
|
46
59
|
return ctx.redirect("/")
|
|
47
60
|
}
|
|
48
61
|
|
|
@@ -9,8 +9,8 @@ jest.mock("../../environment", () => ({
|
|
|
9
9
|
)
|
|
10
10
|
const authorizedMiddleware = require("../authorized")
|
|
11
11
|
const env = require("../../environment")
|
|
12
|
-
const { PermissionTypes, PermissionLevels } = require("@budibase/
|
|
13
|
-
require("@budibase/
|
|
12
|
+
const { PermissionTypes, PermissionLevels } = require("@budibase/backend-core/permissions")
|
|
13
|
+
require("@budibase/backend-core").init(require("../../db"))
|
|
14
14
|
|
|
15
15
|
class TestConfiguration {
|
|
16
16
|
constructor(role) {
|
|
@@ -23,7 +23,7 @@ function mockReset() {
|
|
|
23
23
|
function mockAuthWithNoCookie() {
|
|
24
24
|
jest.resetModules()
|
|
25
25
|
mockWorker()
|
|
26
|
-
jest.mock("@budibase/
|
|
26
|
+
jest.mock("@budibase/backend-core/cache", () => ({
|
|
27
27
|
user: {
|
|
28
28
|
getUser: () => {
|
|
29
29
|
return {
|
|
@@ -32,34 +32,30 @@ function mockAuthWithNoCookie() {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
}))
|
|
35
|
-
jest.mock("@budibase/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Cookies: {},
|
|
43
|
-
},
|
|
35
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
36
|
+
getAppId: jest.fn(),
|
|
37
|
+
setCookie: jest.fn(),
|
|
38
|
+
getCookie: jest.fn(),
|
|
39
|
+
}))
|
|
40
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
41
|
+
Cookies: {},
|
|
44
42
|
}))
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
function mockAuthWithCookie() {
|
|
48
46
|
jest.resetModules()
|
|
49
47
|
mockWorker()
|
|
50
|
-
jest.mock("@budibase/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return "app_test"
|
|
54
|
-
},
|
|
55
|
-
setCookie: jest.fn(),
|
|
56
|
-
getCookie: () => ({appId: "app_different", roleId: "PUBLIC"}),
|
|
48
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
49
|
+
getAppId: () => {
|
|
50
|
+
return "app_test"
|
|
57
51
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
setCookie: jest.fn(),
|
|
53
|
+
getCookie: () => ({appId: "app_different", roleId: "PUBLIC"}),
|
|
54
|
+
}))
|
|
55
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
56
|
+
Cookies: {
|
|
57
|
+
Auth: "auth",
|
|
58
|
+
CurrentApp: "currentapp",
|
|
63
59
|
},
|
|
64
60
|
}))
|
|
65
61
|
}
|
|
@@ -121,7 +117,7 @@ describe("Current app middleware", () => {
|
|
|
121
117
|
async function checkExpected(setCookie) {
|
|
122
118
|
config.setUser()
|
|
123
119
|
await config.executeMiddleware()
|
|
124
|
-
|
|
120
|
+
let { setCookie: cookieFn } = require("@budibase/backend-core/utils")
|
|
125
121
|
if (setCookie) {
|
|
126
122
|
expect(cookieFn).toHaveBeenCalled()
|
|
127
123
|
} else {
|
|
@@ -140,32 +136,30 @@ describe("Current app middleware", () => {
|
|
|
140
136
|
|
|
141
137
|
it("should perform correct when no cookie exists", async () => {
|
|
142
138
|
mockReset()
|
|
143
|
-
jest.mock("@budibase/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return "app_test"
|
|
147
|
-
},
|
|
148
|
-
setCookie: jest.fn(),
|
|
149
|
-
getCookie: jest.fn(),
|
|
150
|
-
},
|
|
151
|
-
constants: {
|
|
152
|
-
Cookies: {},
|
|
139
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
140
|
+
getAppId: () => {
|
|
141
|
+
return "app_test"
|
|
153
142
|
},
|
|
143
|
+
setCookie: jest.fn(),
|
|
144
|
+
getCookie: jest.fn(),
|
|
145
|
+
}))
|
|
146
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
147
|
+
Cookies: {},
|
|
154
148
|
}))
|
|
155
149
|
await checkExpected(true)
|
|
156
150
|
})
|
|
157
151
|
|
|
158
152
|
it("lastly check what occurs when cookie doesn't need updated", async () => {
|
|
159
153
|
mockReset()
|
|
160
|
-
jest.mock("@budibase/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return "app_test"
|
|
164
|
-
},
|
|
165
|
-
setCookie: jest.fn(),
|
|
166
|
-
getCookie: () => ({appId: "app_test", roleId: "PUBLIC"}),
|
|
154
|
+
jest.mock("@budibase/backend-core/utils", () => ({
|
|
155
|
+
getAppId: () => {
|
|
156
|
+
return "app_test"
|
|
167
157
|
},
|
|
168
|
-
|
|
158
|
+
setCookie: jest.fn(),
|
|
159
|
+
getCookie: () => ({appId: "app_test", roleId: "PUBLIC"}),
|
|
160
|
+
}))
|
|
161
|
+
jest.mock("@budibase/backend-core/constants", () => ({
|
|
162
|
+
Cookies: {},
|
|
169
163
|
}))
|
|
170
164
|
await checkExpected(false)
|
|
171
165
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const CouchDB = require("../db")
|
|
2
2
|
const usageQuota = require("../utilities/usageQuota")
|
|
3
3
|
const env = require("../environment")
|
|
4
|
-
const { getTenantId } = require("@budibase/
|
|
4
|
+
const { getTenantId } = require("@budibase/backend-core/tenancy")
|
|
5
5
|
const {
|
|
6
6
|
isExternalTable,
|
|
7
7
|
isRowId: isExternalRowId,
|