1
0
Fork 0
mirror of synced 2024-05-19 03:43:08 +12:00
budibase/qa-core/src/config/internal-api/TestConfiguration/auth.ts
Mel O'Hagan 268dd0ace5 lint
2022-10-03 17:18:16 +01:00

27 lines
688 B
TypeScript

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]> {
const response = await this.api.post(`/global/auth/default/login`, {
body: {
username: process.env.BB_ADMIN_USER_EMAIL,
password: process.env.BB_ADMIN_USER_PASSWORD,
},
})
const cookie = response.headers.get("set-cookie")
this.api.cookie = cookie as any
return [response, cookie]
}
async logout(): Promise<any> {
return this.api.post(`/global/auth/logout`)
}
}