From 657d4a0f1c86acb2a0d31b51aa1d128d2a4d6571 Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Wed, 16 Oct 2024 00:28:30 +0800 Subject: [PATCH] specs, fix mockapi in auth scenarios (#4740) for invalid case, test is considered pass on 403 response code. --- packages/http-specs/specs/authentication/api-key/mockapi.ts | 4 ++-- .../http-specs/specs/authentication/http/custom/mockapi.ts | 6 +++--- packages/http-specs/specs/authentication/oauth2/mockapi.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/http-specs/specs/authentication/api-key/mockapi.ts b/packages/http-specs/specs/authentication/api-key/mockapi.ts index 2d8bfd807..34cc3972e 100644 --- a/packages/http-specs/specs/authentication/api-key/mockapi.ts +++ b/packages/http-specs/specs/authentication/api-key/mockapi.ts @@ -1,8 +1,8 @@ -import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; +import { json, passOnCode, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; export const Scenarios: Record = {}; -Scenarios.Authentication_ApiKey_invalid = passOnSuccess({ +Scenarios.Authentication_ApiKey_invalid = passOnCode(403, { uri: `/authentication/api-key/invalid`, method: `get`, request: { diff --git a/packages/http-specs/specs/authentication/http/custom/mockapi.ts b/packages/http-specs/specs/authentication/http/custom/mockapi.ts index 9ebb14b97..1d9e4e5ac 100644 --- a/packages/http-specs/specs/authentication/http/custom/mockapi.ts +++ b/packages/http-specs/specs/authentication/http/custom/mockapi.ts @@ -1,4 +1,4 @@ -import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; +import { json, passOnCode, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; export const Scenarios: Record = {}; @@ -16,12 +16,12 @@ Scenarios.Authentication_Http_Custom_valid = passOnSuccess({ kind: "MockApiDefinition", }); -Scenarios.Authentication_Http_Custom_invalid = passOnSuccess({ +Scenarios.Authentication_Http_Custom_invalid = passOnCode(403, { uri: `/authentication/http/custom/invalid`, method: "get", request: { headers: { - authorization: "SharedAccessKey valid-key", + authorization: "SharedAccessKey invalid-key", }, status: 403, }, diff --git a/packages/http-specs/specs/authentication/oauth2/mockapi.ts b/packages/http-specs/specs/authentication/oauth2/mockapi.ts index 85fcaf576..3911a1e37 100644 --- a/packages/http-specs/specs/authentication/oauth2/mockapi.ts +++ b/packages/http-specs/specs/authentication/oauth2/mockapi.ts @@ -1,4 +1,4 @@ -import { json, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; +import { json, passOnCode, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api"; export const Scenarios: Record = {}; @@ -16,7 +16,7 @@ Scenarios.Authentication_OAuth2_valid = passOnSuccess({ kind: "MockApiDefinition", }); -Scenarios.Authentication_OAuth2_invalid = passOnSuccess({ +Scenarios.Authentication_OAuth2_invalid = passOnCode(403, { uri: `/authentication/oauth2/invalid`, method: "get", request: {