зеркало из https://github.com/Azure/cadl-ranch.git
specs, fix mockapi in auth scenarios (#752)
This commit is contained in:
Родитель
afce8beb1b
Коммит
46e3022589
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
"@azure-tools/cadl-ranch-api": minor
|
||||
"@azure-tools/cadl-ranch-specs": patch
|
||||
---
|
||||
|
||||
Fix mockapi in authentication scenarios.
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
KeyedMockApi,
|
||||
KeyedMockApiDefinition,
|
||||
KeyedMockRequestHandler,
|
||||
MockApi,
|
||||
MockApiDefinition,
|
||||
PassByKeyScenario,
|
||||
|
@ -27,7 +26,7 @@ export function passOnSuccess(
|
|||
* @param code Status code all endpoint should return
|
||||
* @param apis Endpoint or List of endpoints for this scenario
|
||||
*/
|
||||
export function passOnCode(code: number, apis: MockApi | readonly MockApi[]): PassOnCodeScenario {
|
||||
export function passOnCode(code: number, apis: MockApi | readonly MockApi[] | MockApiDefinition): PassOnCodeScenario {
|
||||
return {
|
||||
passCondition: "status-code",
|
||||
code,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { json, MockRequest, passOnSuccess } from "@azure-tools/cadl-ranch-api";
|
||||
import { json, MockRequest, passOnCode, passOnSuccess } from "@azure-tools/cadl-ranch-api";
|
||||
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";
|
||||
|
||||
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
||||
|
@ -21,12 +21,12 @@ Scenarios.Authentication_ApiKey_valid = passOnSuccess({
|
|||
kind: "MockApiDefinition",
|
||||
});
|
||||
|
||||
Scenarios.Authentication_ApiKey_invalid = passOnSuccess({
|
||||
Scenarios.Authentication_ApiKey_invalid = passOnCode(403, {
|
||||
uri: `/authentication/api-key/invalid`,
|
||||
method: `get`,
|
||||
request: {
|
||||
headers: {
|
||||
"x-ms-api-key": "valid-key",
|
||||
"x-ms-api-key": "invalid-key",
|
||||
},
|
||||
status: 403,
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { json, MockRequest, passOnSuccess } from "@azure-tools/cadl-ranch-api";
|
||||
import { json, MockRequest, passOnSuccess, passOnCode } from "@azure-tools/cadl-ranch-api";
|
||||
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";
|
||||
|
||||
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
||||
|
@ -21,12 +21,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,
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { json, MockRequest, passOnSuccess } from "@azure-tools/cadl-ranch-api";
|
||||
import { json, MockRequest, passOnSuccess, passOnCode } from "@azure-tools/cadl-ranch-api";
|
||||
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";
|
||||
|
||||
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
||||
|
@ -21,7 +21,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: {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { passOnSuccess, json, MockApiDefinition, MockRequest } from "@azure-tools/cadl-ranch-api";
|
||||
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";
|
||||
import { Mock } from "node:test";
|
||||
|
||||
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
||||
function createMockApiDefinitions(route: string, request: any, response: any): MockApiDefinition {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { passOnSuccess, json, MockRequest } from "@azure-tools/cadl-ranch-api";
|
||||
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";
|
||||
import { Mock } from "node:test";
|
||||
|
||||
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче