Merge branch 'master' into BUDI-8416/allow-updating-email-via-scim
This commit is contained in:
commit
e74847585e
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||||
"version": "2.29.6",
|
"version": "2.29.10",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import env from "../../environment"
|
import env from "../../environment"
|
||||||
|
|
||||||
export const getCouchInfo = (connection?: string) => {
|
export const getCouchInfo = (connection?: string) => {
|
||||||
|
// clean out any auth credentials
|
||||||
const urlInfo = getUrlInfo(connection)
|
const urlInfo = getUrlInfo(connection)
|
||||||
let username
|
let username
|
||||||
let password
|
let password
|
||||||
|
@ -23,9 +24,16 @@ export const getCouchInfo = (connection?: string) => {
|
||||||
throw new Error("CouchDB password not set")
|
throw new Error("CouchDB password not set")
|
||||||
}
|
}
|
||||||
const authCookie = Buffer.from(`${username}:${password}`).toString("base64")
|
const authCookie = Buffer.from(`${username}:${password}`).toString("base64")
|
||||||
|
let sqlUrl = env.COUCH_DB_SQL_URL
|
||||||
|
if (!sqlUrl && urlInfo.url) {
|
||||||
|
const parsed = new URL(urlInfo.url)
|
||||||
|
// attempt to connect on default port
|
||||||
|
sqlUrl = urlInfo.url.replace(parsed.port, "4984")
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
url: urlInfo.url!,
|
url: urlInfo.url!,
|
||||||
sqlUrl: env.COUCH_DB_SQL_URL,
|
// clean out any auth credentials
|
||||||
|
sqlUrl: getUrlInfo(sqlUrl).url,
|
||||||
auth: {
|
auth: {
|
||||||
username: username,
|
username: username,
|
||||||
password: password,
|
password: password,
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import env from "../../environment"
|
||||||
|
import { getCouchInfo } from "../couch"
|
||||||
|
|
||||||
|
const MAIN_COUCH_URL = "http://user:test@localhost:5984"
|
||||||
|
|
||||||
|
describe("connections", () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
env._set("COUCH_DB_SQL_URL", "https://user:test@localhost:4984")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should strip URL credentials", () => {
|
||||||
|
const response = getCouchInfo(MAIN_COUCH_URL)
|
||||||
|
expect(response.url).toBe("http://localhost:5984")
|
||||||
|
expect(response.sqlUrl).toBe("https://localhost:4984")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should return separate auth credentials", () => {
|
||||||
|
const response = getCouchInfo(MAIN_COUCH_URL)
|
||||||
|
expect(response.auth.username).toBe("user")
|
||||||
|
expect(response.auth.password).toBe("test")
|
||||||
|
})
|
||||||
|
})
|
|
@ -94,7 +94,7 @@
|
||||||
"koa2-ratelimit": "1.1.1",
|
"koa2-ratelimit": "1.1.1",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"memorystream": "0.3.1",
|
"memorystream": "0.3.1",
|
||||||
"mongodb": "^6.3.0",
|
"mongodb": "6.7.0",
|
||||||
"mssql": "10.0.1",
|
"mssql": "10.0.1",
|
||||||
"mysql2": "3.9.8",
|
"mysql2": "3.9.8",
|
||||||
"node-fetch": "2.6.7",
|
"node-fetch": "2.6.7",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as automationUtils from "./automationUtils"
|
import * as automationUtils from "./automationUtils"
|
||||||
|
import { isPlainObject } from "lodash"
|
||||||
|
|
||||||
type ObjValue = {
|
type ObjValue = {
|
||||||
[key: string]: string | ObjValue
|
[key: string]: string | ObjValue
|
||||||
|
@ -18,6 +19,10 @@ function replaceBindingsRecursive(
|
||||||
value: string | ObjValue,
|
value: string | ObjValue,
|
||||||
loopStepNumber: number
|
loopStepNumber: number
|
||||||
) {
|
) {
|
||||||
|
if (value === null || value === undefined) {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof value === "object") {
|
if (typeof value === "object") {
|
||||||
for (const [innerKey, innerValue] of Object.entries(value)) {
|
for (const [innerKey, innerValue] of Object.entries(value)) {
|
||||||
if (typeof innerValue === "string") {
|
if (typeof innerValue === "string") {
|
||||||
|
@ -25,7 +30,11 @@ function replaceBindingsRecursive(
|
||||||
innerValue,
|
innerValue,
|
||||||
`steps.${loopStepNumber}`
|
`steps.${loopStepNumber}`
|
||||||
)
|
)
|
||||||
} else if (typeof innerValue === "object") {
|
} else if (
|
||||||
|
innerValue &&
|
||||||
|
isPlainObject(innerValue) &&
|
||||||
|
Object.keys(innerValue).length > 0
|
||||||
|
) {
|
||||||
value[innerKey] = replaceBindingsRecursive(innerValue, loopStepNumber)
|
value[innerKey] = replaceBindingsRecursive(innerValue, loopStepNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { loopAutomation } from "../../tests/utilities/structures"
|
||||||
import { context } from "@budibase/backend-core"
|
import { context } from "@budibase/backend-core"
|
||||||
import * as setup from "./utilities"
|
import * as setup from "./utilities"
|
||||||
import { Table } from "@budibase/types"
|
import { Table } from "@budibase/types"
|
||||||
|
import * as loopUtils from "../loopUtils"
|
||||||
import { LoopInput, LoopStepType } from "../../definitions/automations"
|
import { LoopInput, LoopStepType } from "../../definitions/automations"
|
||||||
|
|
||||||
describe("Attempt to run a basic loop automation", () => {
|
describe("Attempt to run a basic loop automation", () => {
|
||||||
|
@ -51,4 +52,98 @@ describe("Attempt to run a basic loop automation", () => {
|
||||||
})
|
})
|
||||||
expect(resp.steps[2].outputs.iterations).toBe(1)
|
expect(resp.steps[2].outputs.iterations).toBe(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("replaceFakeBindings", () => {
|
||||||
|
it("should replace loop bindings in nested objects", () => {
|
||||||
|
const originalStepInput = {
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
length: { maximum: null },
|
||||||
|
presence: false,
|
||||||
|
},
|
||||||
|
name: "name",
|
||||||
|
display: { type: "Text" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
row: {
|
||||||
|
tableId: "ta_aaad4296e9f74b12b1b90ef7a84afcad",
|
||||||
|
name: "{{ loop.currentItem.pokemon }}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const loopStepNumber = 3
|
||||||
|
|
||||||
|
const result = loopUtils.replaceFakeBindings(
|
||||||
|
originalStepInput,
|
||||||
|
loopStepNumber
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
schema: {
|
||||||
|
name: {
|
||||||
|
type: "string",
|
||||||
|
constraints: {
|
||||||
|
type: "string",
|
||||||
|
length: { maximum: null },
|
||||||
|
presence: false,
|
||||||
|
},
|
||||||
|
name: "name",
|
||||||
|
display: { type: "Text" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
row: {
|
||||||
|
tableId: "ta_aaad4296e9f74b12b1b90ef7a84afcad",
|
||||||
|
name: "{{ steps.3.currentItem.pokemon }}",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should handle null values in nested objects", () => {
|
||||||
|
const originalStepInput = {
|
||||||
|
nullValue: null,
|
||||||
|
nestedNull: {
|
||||||
|
someKey: null,
|
||||||
|
},
|
||||||
|
validValue: "{{ loop.someValue }}",
|
||||||
|
}
|
||||||
|
|
||||||
|
const loopStepNumber = 2
|
||||||
|
|
||||||
|
const result = loopUtils.replaceFakeBindings(
|
||||||
|
originalStepInput,
|
||||||
|
loopStepNumber
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
nullValue: null,
|
||||||
|
nestedNull: {
|
||||||
|
someKey: null,
|
||||||
|
},
|
||||||
|
validValue: "{{ steps.2.someValue }}",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("should handle empty objects and arrays", () => {
|
||||||
|
const originalStepInput = {
|
||||||
|
emptyObject: {},
|
||||||
|
emptyArray: [],
|
||||||
|
nestedEmpty: {
|
||||||
|
emptyObj: {},
|
||||||
|
emptyArr: [],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const loopStepNumber = 1
|
||||||
|
|
||||||
|
const result = loopUtils.replaceFakeBindings(
|
||||||
|
originalStepInput,
|
||||||
|
loopStepNumber
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result).toEqual(originalStepInput)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
28
yarn.lock
28
yarn.lock
|
@ -3636,10 +3636,10 @@
|
||||||
semver "^7.3.5"
|
semver "^7.3.5"
|
||||||
tar "^6.1.11"
|
tar "^6.1.11"
|
||||||
|
|
||||||
"@mongodb-js/saslprep@^1.1.0":
|
"@mongodb-js/saslprep@^1.1.5":
|
||||||
version "1.1.4"
|
version "1.1.7"
|
||||||
resolved "https://registry.yarnpkg.com/@mongodb-js/saslprep/-/saslprep-1.1.4.tgz#24ec1c4915a65f5c506bb88c081731450d91bb1c"
|
resolved "https://registry.yarnpkg.com/@mongodb-js/saslprep/-/saslprep-1.1.7.tgz#d1700facfd6916c50c2c88fd6d48d363a56c702f"
|
||||||
integrity sha512-8zJ8N1x51xo9hwPh6AWnKdLGEC5N3lDa6kms1YHmFBoRhTpJR6HG8wWk0td1MVCu9cD4YBrvjZEtd5Obw0Fbnw==
|
integrity sha512-dCHW/oEX0KJ4NjDULBo3JiOaK5+6axtpBbS+ao2ZInoAL9/YRQLhXzSNAFz7hP4nzLkIqsfYAK/PDE3+XHny0Q==
|
||||||
dependencies:
|
dependencies:
|
||||||
sparse-bitfield "^3.0.3"
|
sparse-bitfield "^3.0.3"
|
||||||
|
|
||||||
|
@ -8001,10 +8001,10 @@ bser@2.1.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
node-int64 "^0.4.0"
|
node-int64 "^0.4.0"
|
||||||
|
|
||||||
bson@^6.2.0:
|
bson@^6.7.0:
|
||||||
version "6.3.0"
|
version "6.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/bson/-/bson-6.3.0.tgz#d47acba525ba7d7eb0e816c10538bce26a337fe0"
|
resolved "https://registry.yarnpkg.com/bson/-/bson-6.8.0.tgz#5063c41ba2437c2b8ff851b50d9e36cb7aaa7525"
|
||||||
integrity sha512-balJfqwwTBddxfnidJZagCBPP/f48zj9Sdp3OJswREOgsJzHiQSaOIAtApSgDQFYgHqAvFkp53AFSqjMDZoTFw==
|
integrity sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ==
|
||||||
|
|
||||||
btoa@^1.2.1:
|
btoa@^1.2.1:
|
||||||
version "1.2.1"
|
version "1.2.1"
|
||||||
|
@ -16112,13 +16112,13 @@ mongodb-connection-string-url@^3.0.0:
|
||||||
"@types/whatwg-url" "^11.0.2"
|
"@types/whatwg-url" "^11.0.2"
|
||||||
whatwg-url "^13.0.0"
|
whatwg-url "^13.0.0"
|
||||||
|
|
||||||
mongodb@^6.3.0:
|
mongodb@6.7.0:
|
||||||
version "6.3.0"
|
version "6.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-6.3.0.tgz#ec9993b19f7ed2ea715b903fcac6171c9d1d38ca"
|
resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-6.7.0.tgz#f86e51e6530e6a2ca4a99d7cfdf6f409223ac199"
|
||||||
integrity sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==
|
integrity sha512-TMKyHdtMcO0fYBNORiYdmM25ijsHs+Njs963r4Tro4OQZzqYigAzYQouwWRg4OIaiLRUEGUh/1UAcH5lxdSLIA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@mongodb-js/saslprep" "^1.1.0"
|
"@mongodb-js/saslprep" "^1.1.5"
|
||||||
bson "^6.2.0"
|
bson "^6.7.0"
|
||||||
mongodb-connection-string-url "^3.0.0"
|
mongodb-connection-string-url "^3.0.0"
|
||||||
|
|
||||||
ms@2.1.2:
|
ms@2.1.2:
|
||||||
|
|
Loading…
Reference in New Issue