Changes for Account API Testing
This commit is contained in:
parent
6f7ef18084
commit
fa94b8b9fc
|
@ -53,6 +53,8 @@ async function passportCallback(
|
|||
}
|
||||
|
||||
export const login = async (ctx: Ctx<LoginRequest>, next: any) => {
|
||||
const tenantId = context.getTenantId()
|
||||
console.log(tenantId)
|
||||
const email = ctx.request.body.username
|
||||
|
||||
const user = await userSdk.getUserByEmail(email)
|
||||
|
|
|
@ -73,6 +73,13 @@ export default class AccountAPI {
|
|||
return response
|
||||
}
|
||||
|
||||
async deleteCurrentAccount() {
|
||||
const [response, json] = await this.client.del(
|
||||
`/api/accounts`
|
||||
)
|
||||
return response
|
||||
}
|
||||
|
||||
async verifyAccount(
|
||||
verificationCode: string,
|
||||
opts: APIRequestOpts = { doExpect: true }
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class AuthAPI {
|
|||
`/api/auth/login`,
|
||||
{
|
||||
body: {
|
||||
username: email,
|
||||
email: email,
|
||||
password: password,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@ export default class TestConfiguration<T> extends BudibaseTestConfiguration {
|
|||
this.state.apiKey = apiKeyResponse.apiKey
|
||||
}
|
||||
|
||||
async setCookieAuth() {
|
||||
const apiKeyResponse = await this.internalApi.self.getApiKey()
|
||||
this.state.apiKey = apiKeyResponse.apiKey
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,9 +12,26 @@ describe("Account API - Delete Account", () => {
|
|||
await config.afterAll()
|
||||
})
|
||||
|
||||
// it("Deletes an account", async () => {
|
||||
//
|
||||
// })
|
||||
it("Deletes an account", async () => {
|
||||
// Create account
|
||||
const createAccountRequest = fixtures.accounts.generateAccount()
|
||||
|
||||
await config.api.accounts.create(
|
||||
createAccountRequest
|
||||
)
|
||||
|
||||
// Login - Get cookie
|
||||
await config.login(
|
||||
createAccountRequest.email,
|
||||
createAccountRequest.password,
|
||||
createAccountRequest.tenantId
|
||||
)
|
||||
|
||||
// Delete account
|
||||
const [ res ] = await config.api.accounts.deleteCurrentAccount()
|
||||
|
||||
expect(res.status).toBe(204)
|
||||
})
|
||||
|
||||
it("Deletes an account by ID", async () => {
|
||||
const [response, account] = await config.api.accounts.create({
|
||||
|
|
|
@ -18,10 +18,12 @@ describe("Account API - Validate Account", () => {
|
|||
|
||||
|
||||
it("Validates an email", async () => {
|
||||
|
||||
await config.api.accounts.validateEmail(email)
|
||||
})
|
||||
|
||||
it("Validates a tenant ID", async () => {
|
||||
|
||||
await config.api.accounts.validateTenantId(tenant)
|
||||
})
|
||||
})
|
|
@ -15,10 +15,24 @@ describe("Account API - Verify Account", () => {
|
|||
|
||||
|
||||
it("Verify an account", async () => {
|
||||
// Create account
|
||||
await config.api.accounts.create({
|
||||
...fixtures.accounts.generateAccount()
|
||||
})
|
||||
// Invite user
|
||||
|
||||
// Verify account via code
|
||||
await config.api.accounts.verifyAccount()
|
||||
})
|
||||
|
||||
it("Send account verification email ", async () => {
|
||||
// Create account
|
||||
await config.api.accounts.create({
|
||||
...fixtures.accounts.generateAccount()
|
||||
})
|
||||
// Invite user
|
||||
|
||||
// Verify account via email
|
||||
await config.api.accounts.verifyAccountSendEmail()
|
||||
})
|
||||
})
|
|
@ -43,7 +43,8 @@ export default class BudibaseTestConfiguration {
|
|||
async login(email: string, password: string, tenantId?: string) {
|
||||
if (!tenantId && this.state.tenantId) {
|
||||
tenantId = this.state.tenantId
|
||||
} else {
|
||||
}
|
||||
if (!tenantId) {
|
||||
throw new Error("Could not determine tenant id")
|
||||
}
|
||||
const [res, cookie] = await this.internalApi.auth.login(
|
||||
|
|
Loading…
Reference in New Issue