2022-10-07 04:03:47 +13:00
|
|
|
import { generator, uuid } from "."
|
2023-03-31 04:35:25 +13:00
|
|
|
import { generateGlobalUserID } from "../../../../src/docIds"
|
2023-02-21 21:23:53 +13:00
|
|
|
import {
|
|
|
|
Account,
|
|
|
|
AccountSSOProvider,
|
|
|
|
AccountSSOProviderType,
|
|
|
|
AuthType,
|
|
|
|
CloudAccount,
|
|
|
|
Hosting,
|
|
|
|
SSOAccount,
|
2023-03-03 03:38:15 +13:00
|
|
|
CreateAccount,
|
|
|
|
CreatePassswordAccount,
|
2023-02-21 21:23:53 +13:00
|
|
|
} from "@budibase/types"
|
|
|
|
import _ from "lodash"
|
2022-10-07 04:03:47 +13:00
|
|
|
|
2022-11-12 00:10:07 +13:00
|
|
|
export const account = (): Account => {
|
2022-10-07 04:03:47 +13:00
|
|
|
return {
|
|
|
|
accountId: uuid(),
|
2022-11-12 00:10:07 +13:00
|
|
|
tenantId: generator.word(),
|
|
|
|
email: generator.email(),
|
|
|
|
tenantName: generator.word(),
|
|
|
|
hosting: Hosting.SELF,
|
2022-10-07 04:03:47 +13:00
|
|
|
createdAt: Date.now(),
|
|
|
|
verified: true,
|
|
|
|
verificationSent: true,
|
2022-11-12 00:10:07 +13:00
|
|
|
tier: "FREE", // DEPRECATED
|
2022-10-07 04:03:47 +13:00
|
|
|
authType: AuthType.PASSWORD,
|
|
|
|
name: generator.name(),
|
|
|
|
size: "10+",
|
|
|
|
profession: "Software Engineer",
|
2022-11-12 00:10:07 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-03 03:38:15 +13:00
|
|
|
export function selfHostAccount() {
|
|
|
|
return account()
|
|
|
|
}
|
|
|
|
|
2022-11-12 00:10:07 +13:00
|
|
|
export const cloudAccount = (): CloudAccount => {
|
|
|
|
return {
|
|
|
|
...account(),
|
|
|
|
hosting: Hosting.CLOUD,
|
2023-03-31 04:07:59 +13:00
|
|
|
budibaseUserId: generateGlobalUserID(),
|
2022-10-07 04:03:47 +13:00
|
|
|
}
|
|
|
|
}
|
2023-02-21 21:23:53 +13:00
|
|
|
|
|
|
|
function providerType(): AccountSSOProviderType {
|
|
|
|
return _.sample(
|
|
|
|
Object.values(AccountSSOProviderType)
|
|
|
|
) as AccountSSOProviderType
|
|
|
|
}
|
|
|
|
|
|
|
|
function provider(): AccountSSOProvider {
|
|
|
|
return _.sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
|
|
|
|
}
|
|
|
|
|
2023-03-03 03:38:15 +13:00
|
|
|
export function ssoAccount(account: Account = cloudAccount()): SSOAccount {
|
2023-02-21 21:23:53 +13:00
|
|
|
return {
|
2023-03-03 03:38:15 +13:00
|
|
|
...account,
|
2023-02-21 21:23:53 +13:00
|
|
|
authType: AuthType.SSO,
|
|
|
|
oauth2: {
|
|
|
|
accessToken: generator.string(),
|
|
|
|
refreshToken: generator.string(),
|
|
|
|
},
|
|
|
|
pictureUrl: generator.url(),
|
|
|
|
provider: provider(),
|
|
|
|
providerType: providerType(),
|
|
|
|
thirdPartyProfile: {},
|
|
|
|
}
|
|
|
|
}
|
2023-03-03 03:38:15 +13:00
|
|
|
|
|
|
|
export const cloudCreateAccount: CreatePassswordAccount = {
|
|
|
|
email: "cloud@budibase.com",
|
|
|
|
tenantId: "cloud",
|
|
|
|
hosting: Hosting.CLOUD,
|
|
|
|
authType: AuthType.PASSWORD,
|
|
|
|
password: "Password123!",
|
|
|
|
tenantName: "cloud",
|
|
|
|
name: "Budi Armstrong",
|
|
|
|
size: "10+",
|
|
|
|
profession: "Software Engineer",
|
|
|
|
}
|
|
|
|
|
|
|
|
export const cloudSSOCreateAccount: CreateAccount = {
|
|
|
|
email: "cloud-sso@budibase.com",
|
|
|
|
tenantId: "cloud-sso",
|
|
|
|
hosting: Hosting.CLOUD,
|
|
|
|
authType: AuthType.SSO,
|
|
|
|
tenantName: "cloudsso",
|
|
|
|
name: "Budi Armstrong",
|
|
|
|
size: "10+",
|
|
|
|
profession: "Software Engineer",
|
|
|
|
}
|
|
|
|
|
|
|
|
export const selfCreateAccount: CreatePassswordAccount = {
|
|
|
|
email: "self@budibase.com",
|
|
|
|
tenantId: "self",
|
|
|
|
hosting: Hosting.SELF,
|
|
|
|
authType: AuthType.PASSWORD,
|
|
|
|
password: "Password123!",
|
|
|
|
tenantName: "self",
|
|
|
|
name: "Budi Armstrong",
|
|
|
|
size: "10+",
|
|
|
|
profession: "Software Engineer",
|
|
|
|
}
|
|
|
|
|
|
|
|
export const selfSSOCreateAccount: CreateAccount = {
|
|
|
|
email: "self-sso@budibase.com",
|
|
|
|
tenantId: "self-sso",
|
|
|
|
hosting: Hosting.SELF,
|
|
|
|
authType: AuthType.SSO,
|
|
|
|
tenantName: "selfsso",
|
|
|
|
name: "Budi Armstrong",
|
|
|
|
size: "10+",
|
|
|
|
profession: "Software Engineer",
|
|
|
|
}
|