This commit is contained in:
Adria Navarro 2025-03-17 13:28:53 +01:00
parent b262deb7cf
commit 25607c8f3b
5 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
import {
CreateOAuth2ConfigRequest,
CreateOAuth2ConfigResponse,
UpsertOAuth2ConfigRequest,
UpsertOAuth2ConfigResponse,
Ctx,
FetchOAuth2ConfigsResponse,
OAuth2Config,
@ -22,7 +22,7 @@ export async function fetch(ctx: Ctx<void, FetchOAuth2ConfigsResponse>) {
}
export async function create(
ctx: Ctx<CreateOAuth2ConfigRequest, CreateOAuth2ConfigResponse>
ctx: Ctx<UpsertOAuth2ConfigRequest, UpsertOAuth2ConfigResponse>
) {
const { body } = ctx.request
const newConfig: RequiredKeys<Omit<OAuth2Config, "id">> = {
@ -38,7 +38,7 @@ export async function create(
}
export async function edit(
ctx: Ctx<CreateOAuth2ConfigRequest, CreateOAuth2ConfigResponse>
ctx: Ctx<UpsertOAuth2ConfigRequest, UpsertOAuth2ConfigResponse>
) {
const { body } = ctx.request
const toUpdate: RequiredKeys<OAuth2Config> = {

View File

@ -15,7 +15,7 @@ router.post(
router.put(
"/api/oauth2/:id",
authorized(PermissionType.BUILDER),
createOAauth2ConfigValidator(),
oAuth2ConfigValidator(),
controller.create
)

View File

@ -1,11 +1,11 @@
import { CreateOAuth2ConfigRequest, VirtualDocumentType } from "@budibase/types"
import { UpsertOAuth2ConfigRequest, VirtualDocumentType } from "@budibase/types"
import * as setup from "./utilities"
import { generator } from "@budibase/backend-core/tests"
describe("/oauth2", () => {
let config = setup.getConfig()
function makeOAuth2Config(): CreateOAuth2ConfigRequest {
function makeOAuth2Config(): UpsertOAuth2ConfigRequest {
return {
name: generator.guid(),
url: generator.url(),

View File

@ -1,6 +1,6 @@
import {
CreateOAuth2ConfigRequest,
CreateOAuth2ConfigResponse,
UpsertOAuth2ConfigRequest,
UpsertOAuth2ConfigResponse,
FetchOAuth2ConfigsResponse,
} from "@budibase/types"
import { Expectations, TestAPI } from "./base"
@ -13,10 +13,10 @@ export class OAuth2API extends TestAPI {
}
create = async (
body: CreateOAuth2ConfigRequest,
body: UpsertOAuth2ConfigRequest,
expectations?: Expectations
) => {
return await this._post<CreateOAuth2ConfigResponse>("/api/oauth2", {
return await this._post<UpsertOAuth2ConfigResponse>("/api/oauth2", {
body,
expectations: {
status: expectations?.status ?? 201,

View File

@ -1,4 +1,4 @@
export interface OAuth2ConfigResponse {
interface OAuth2ConfigResponse {
id: string
name: string
}
@ -7,13 +7,13 @@ export interface FetchOAuth2ConfigsResponse {
configs: OAuth2ConfigResponse[]
}
export interface CreateOAuth2ConfigRequest {
export interface UpsertOAuth2ConfigRequest {
name: string
url: string
clientId: string
clientSecret: string
}
export interface CreateOAuth2ConfigResponse {
export interface UpsertOAuth2ConfigResponse {
config: OAuth2ConfigResponse
}