Lint
This commit is contained in:
parent
ccf98580d6
commit
f656e97d2d
|
@ -1 +1 @@
|
||||||
Subproject commit 347ee5326812c01ef07f0e744f691ab4823e185a
|
Subproject commit b5124e76b9fa8020641e8d019ac1713c6245d6e6
|
|
@ -49,7 +49,7 @@ export default class AccountInternalAPIClient {
|
||||||
requestOptions.headers = {
|
requestOptions.headers = {
|
||||||
...requestOptions.headers,
|
...requestOptions.headers,
|
||||||
...{ [Header.API_KEY]: env.ACCOUNT_PORTAL_API_KEY },
|
...{ [Header.API_KEY]: env.ACCOUNT_PORTAL_API_KEY },
|
||||||
cookie: ""
|
cookie: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import AccountInternalAPIClient from "../AccountInternalAPIClient"
|
import AccountInternalAPIClient from "../AccountInternalAPIClient"
|
||||||
import { Account, CreateOfflineLicenseRequest, GetOfflineLicenseResponse, UpdateLicenseRequest } from "@budibase/types"
|
import {
|
||||||
|
Account,
|
||||||
|
CreateOfflineLicenseRequest,
|
||||||
|
GetOfflineLicenseResponse,
|
||||||
|
UpdateLicenseRequest,
|
||||||
|
} from "@budibase/types"
|
||||||
import { Response } from "node-fetch"
|
import { Response } from "node-fetch"
|
||||||
import BaseAPI from "./BaseAPI"
|
import BaseAPI from "./BaseAPI"
|
||||||
import { APIRequestOpts } from "../../../types"
|
import { APIRequestOpts } from "../../../types"
|
||||||
|
@ -39,8 +44,8 @@ export default class LicenseAPI extends BaseAPI {
|
||||||
body,
|
body,
|
||||||
internal: true,
|
internal: true,
|
||||||
headers: {
|
headers: {
|
||||||
"x-budibase-tenant-id": tenantId
|
"x-budibase-tenant-id": tenantId,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
expect(response.status).toBe(opts.status ? opts.status : 201)
|
expect(response.status).toBe(opts.status ? opts.status : 201)
|
||||||
|
@ -57,8 +62,8 @@ export default class LicenseAPI extends BaseAPI {
|
||||||
{
|
{
|
||||||
internal: true,
|
internal: true,
|
||||||
headers: {
|
headers: {
|
||||||
"x-budibase-tenant-id": tenantId
|
"x-budibase-tenant-id": tenantId,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
expect(response.status).toBe(opts.status ? opts.status : 200)
|
expect(response.status).toBe(opts.status ? opts.status : 200)
|
||||||
|
|
|
@ -2,21 +2,23 @@ import { generator } from "../../shared"
|
||||||
import { Hosting, CreateAccountRequest } from "@budibase/types"
|
import { Hosting, CreateAccountRequest } from "@budibase/types"
|
||||||
|
|
||||||
// TODO: Refactor me to central location
|
// TODO: Refactor me to central location
|
||||||
export const generateAccount = (partial: Partial<CreateAccountRequest>): CreateAccountRequest => {
|
export const generateAccount = (
|
||||||
const uuid = generator.guid()
|
partial: Partial<CreateAccountRequest>
|
||||||
|
): CreateAccountRequest => {
|
||||||
|
const uuid = generator.guid()
|
||||||
|
|
||||||
const email = `${uuid}@budibase.com`
|
const email = `${uuid}@budibase.com`
|
||||||
const tenant = `tenant${uuid.replace(/-/g, "")}`
|
const tenant = `tenant${uuid.replace(/-/g, "")}`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
email,
|
email,
|
||||||
hosting: Hosting.CLOUD,
|
hosting: Hosting.CLOUD,
|
||||||
name: email,
|
name: email,
|
||||||
password: uuid,
|
password: uuid,
|
||||||
profession: "software_engineer",
|
profession: "software_engineer",
|
||||||
size: "10+",
|
size: "10+",
|
||||||
tenantId: tenant,
|
tenantId: tenant,
|
||||||
tenantName: tenant,
|
tenantName: tenant,
|
||||||
...partial,
|
...partial,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,22 +20,28 @@ describe("offline", () => {
|
||||||
await config.internalApi.license.deleteOfflineLicenseToken()
|
await config.internalApi.license.deleteOfflineLicenseToken()
|
||||||
|
|
||||||
// installation: Assert token not found
|
// installation: Assert token not found
|
||||||
let [getTokenRes] = await config.internalApi.license.getOfflineLicenseToken({ status: 404 })
|
let [getTokenRes] = await config.internalApi.license.getOfflineLicenseToken(
|
||||||
|
{ status: 404 }
|
||||||
|
)
|
||||||
|
|
||||||
// installation: Retrieve Identifier
|
// installation: Retrieve Identifier
|
||||||
const [getIdentifierRes, identifier] = await config.internalApi.license.getOfflineIdentifier()
|
const [getIdentifierRes, identifier] =
|
||||||
|
await config.internalApi.license.getOfflineIdentifier()
|
||||||
|
|
||||||
// account-portal: Create self-host account
|
// account-portal: Create self-host account
|
||||||
const createAccountRequest = fixures.accounts.generateAccount({ hosting: Hosting.SELF })
|
const createAccountRequest = fixures.accounts.generateAccount({
|
||||||
const [createAccountRes, account] = await config.accountsApi.accounts.create(createAccountRequest)
|
hosting: Hosting.SELF,
|
||||||
|
})
|
||||||
|
const [createAccountRes, account] =
|
||||||
|
await config.accountsApi.accounts.create(createAccountRequest)
|
||||||
const accountId = account.accountId!
|
const accountId = account.accountId!
|
||||||
const tenantId = account.tenantId!
|
const tenantId = account.tenantId!
|
||||||
|
|
||||||
// account-portal: Enable feature on license
|
// account-portal: Enable feature on license
|
||||||
await config.accountsApi.licenses.updateLicense(accountId, {
|
await config.accountsApi.licenses.updateLicense(accountId, {
|
||||||
overrides: {
|
overrides: {
|
||||||
features: [Feature.OFFLINE]
|
features: [Feature.OFFLINE],
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// account-portal: Create offline token
|
// account-portal: Create offline token
|
||||||
|
@ -45,16 +51,18 @@ describe("offline", () => {
|
||||||
accountId,
|
accountId,
|
||||||
tenantId,
|
tenantId,
|
||||||
{
|
{
|
||||||
expireAt: expireAt.toISOString(),
|
expireAt: expireAt.toISOString(),
|
||||||
installationIdentifierBase64: identifier.identifierBase64
|
installationIdentifierBase64: identifier.identifierBase64,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// account-portal: Retrieve offline token
|
// account-portal: Retrieve offline token
|
||||||
const [getLicenseRes, offlineLicense] = await config.accountsApi.licenses.getOfflineLicense(accountId, tenantId)
|
const [getLicenseRes, offlineLicense] =
|
||||||
|
await config.accountsApi.licenses.getOfflineLicense(accountId, tenantId)
|
||||||
|
|
||||||
// installation: Activate offline token
|
// installation: Activate offline token
|
||||||
await config.internalApi.license.activateOfflineLicenseToken({
|
await config.internalApi.license.activateOfflineLicenseToken({
|
||||||
offlineLicenseToken: offlineLicense.offlineLicenseToken
|
offlineLicenseToken: offlineLicense.offlineLicenseToken,
|
||||||
})
|
})
|
||||||
|
|
||||||
// installation: Assert token found
|
// installation: Assert token found
|
||||||
|
@ -68,4 +76,4 @@ describe("offline", () => {
|
||||||
// installation: Assert token not found
|
// installation: Assert token not found
|
||||||
await config.internalApi.license.getOfflineLicenseToken({ status: 404 })
|
await config.internalApi.license.getOfflineLicenseToken({ status: 404 })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,8 +12,13 @@ export default class LicenseAPI extends BaseAPI {
|
||||||
super(client)
|
super(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOfflineLicenseToken(opts: { status?: number } = {}): Promise<[Response, GetOfflineLicenseTokenResponse]> {
|
async getOfflineLicenseToken(
|
||||||
const [response, body] = await this.get(`/global/license/offline`, opts.status)
|
opts: { status?: number } = {}
|
||||||
|
): Promise<[Response, GetOfflineLicenseTokenResponse]> {
|
||||||
|
const [response, body] = await this.get(
|
||||||
|
`/global/license/offline`,
|
||||||
|
opts.status
|
||||||
|
)
|
||||||
return [response, body]
|
return [response, body]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,13 +27,19 @@ export default class LicenseAPI extends BaseAPI {
|
||||||
return [response]
|
return [response]
|
||||||
}
|
}
|
||||||
|
|
||||||
async activateOfflineLicenseToken(body: ActivateOfflineLicenseTokenRequest): Promise<[Response]> {
|
async activateOfflineLicenseToken(
|
||||||
|
body: ActivateOfflineLicenseTokenRequest
|
||||||
|
): Promise<[Response]> {
|
||||||
const [response] = await this.post(`/global/license/offline`, body)
|
const [response] = await this.post(`/global/license/offline`, body)
|
||||||
return [response]
|
return [response]
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOfflineIdentifier(): Promise<[Response, GetOfflineIdentifierResponse]> {
|
async getOfflineIdentifier(): Promise<
|
||||||
const [response, body] = await this.get(`/global/license/offline/identifier`)
|
[Response, GetOfflineIdentifierResponse]
|
||||||
|
> {
|
||||||
|
const [response, body] = await this.get(
|
||||||
|
`/global/license/offline/identifier`
|
||||||
|
)
|
||||||
return [response, body]
|
return [response, body]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue