1
0
Fork 0
mirror of synced 2024-06-26 18:10:51 +12:00
budibase/qa-core/src/config/internal-api/TestConfiguration/auth.ts

27 lines
688 B
TypeScript
Raw Normal View History

2022-09-27 04:54:14 +13:00
import { Response } from "node-fetch"
import InternalAPIClient from "./InternalAPIClient"
export default class AuthApi {
api: InternalAPIClient
constructor(apiClient: InternalAPIClient) {
this.api = apiClient
}
async login(): Promise<[Response, any]> {
2022-10-04 22:59:53 +13:00
const response = await this.api.post(`/global/auth/default/login`, {
2022-09-27 04:54:14 +13:00
body: {
2022-09-29 06:31:23 +13:00
username: process.env.BB_ADMIN_USER_EMAIL,
2022-10-04 22:59:53 +13:00
password: process.env.BB_ADMIN_USER_PASSWORD,
},
2022-09-27 04:54:14 +13:00
})
2022-09-29 06:21:05 +13:00
const cookie = response.headers.get("set-cookie")
this.api.cookie = cookie as any
return [response, cookie]
}
async logout(): Promise<any> {
2022-09-29 06:31:23 +13:00
return this.api.post(`/global/auth/logout`)
2022-09-27 04:54:14 +13:00
}
}