Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into checkupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgallan committed Oct 21, 2024
2 parents df7ebee + caa2290 commit c9184bb
Show file tree
Hide file tree
Showing 67 changed files with 176 additions and 1,523 deletions.
6 changes: 6 additions & 0 deletions .changeset/poor-deers-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@azure-tools/cadl-ranch-specs": minor
"@azure-tools/cadl-ranch": minor
---

Remove handler code and commonapi file
12 changes: 6 additions & 6 deletions packages/cadl-ranch-specs/cadl-ranch-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ Expects header 'authorization': 'Bearer https://security.microsoft.com/.default'
- `get /azure/client-generator-core/access/internalOperation/publicDecoratorInInternal`

This scenario contains internal operations. All should be generated but not exposed.
Expected query parameter: name=<any string>
Expected query parameter: name= "sample"
Expected response body:

```json
{
"name": <any string>
"name": "sample"
}
```

Expand All @@ -95,12 +95,12 @@ Expected response body:
- `get /azure/client-generator-core/access/publicOperation/publicDecoratorInPublic`

This scenario contains public operations. It should be generated and exported.
Expected query parameter: name=<any string>
Expected query parameter: name="sample"
Expected response body:

```json
{
"name": <any string>
"name": "sample"
}
```

Expand All @@ -119,12 +119,12 @@ This scenario contains internal operations. All should be generated but not expo
- `get /azure/client-generator-core/access/sharedModelInOperation/internal`

This scenario contains two operations, one public, another internal. The public one should be generated and exported while the internal one should be generated but not exposed.
Expected query parameter: name=<any string>
Expected query parameter: name= "sample"
Expected response body:

```json
{
"name": <any string>
"name": "sample"
}
```

Expand Down
14 changes: 1 addition & 13 deletions packages/cadl-ranch-specs/http/authentication/api-key/mockapi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json, MockRequest, passOnCode, passOnSuccess } from "@azure-tools/cadl-ranch-api";
import { json, passOnCode, passOnSuccess } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};
Expand All @@ -14,10 +14,6 @@ Scenarios.Authentication_ApiKey_valid = passOnSuccess({
response: {
status: 204,
},
handler: (req: MockRequest) => {
req.expect.containsHeader("x-ms-api-key", "valid-key");
return { status: 204 };
},
kind: "MockApiDefinition",
});

Expand All @@ -36,13 +32,5 @@ Scenarios.Authentication_ApiKey_invalid = passOnCode(403, {
error: "invalid-api-key",
}),
},
handler: (req: MockRequest) => {
return {
status: 403,
body: json({
error: "invalid-api-key",
}),
};
},
kind: "MockApiDefinition",
});
43 changes: 0 additions & 43 deletions packages/cadl-ranch-specs/http/authentication/commonapi.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json, MockRequest, passOnSuccess, passOnCode } from "@azure-tools/cadl-ranch-api";
import { json, passOnSuccess, passOnCode } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};
Expand All @@ -14,10 +14,6 @@ Scenarios.Authentication_Http_Custom_valid = passOnSuccess({
response: {
status: 204,
},
handler: (req: MockRequest) => {
req.expect.containsHeader("authorization", "SharedAccessKey valid-key");
return { status: 204 };
},
kind: "MockApiDefinition",
});

Expand All @@ -36,13 +32,5 @@ Scenarios.Authentication_Http_Custom_invalid = passOnCode(403, {
error: "invalid-api-key",
}),
},
handler: (req: MockRequest) => {
return {
status: 403,
body: json({
error: "invalid-api-key",
}),
};
},
kind: "MockApiDefinition",
});
14 changes: 1 addition & 13 deletions packages/cadl-ranch-specs/http/authentication/oauth2/mockapi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { json, MockRequest, passOnSuccess, passOnCode } from "@azure-tools/cadl-ranch-api";
import { json, passOnSuccess, passOnCode } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};
Expand All @@ -14,10 +14,6 @@ Scenarios.Authentication_OAuth2_valid = passOnSuccess({
response: {
status: 204,
},
handler: (req: MockRequest) => {
req.expect.containsHeader("authorization", "Bearer https://security.microsoft.com/.default");
return { status: 204 };
},
kind: "MockApiDefinition",
});

Expand All @@ -33,13 +29,5 @@ Scenarios.Authentication_OAuth2_invalid = passOnCode(403, {
error: "invalid-grant",
}),
},
handler: (req: MockRequest) => {
return {
status: 403,
body: json({
error: "invalid-grant",
}),
};
},
kind: "MockApiDefinition",
});
10 changes: 1 addition & 9 deletions packages/cadl-ranch-specs/http/authentication/union/mockapi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { passOnSuccess, MockRequest } from "@azure-tools/cadl-ranch-api";
import { passOnSuccess } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};
Expand All @@ -14,10 +14,6 @@ Scenarios.Authentication_Union_validKey = passOnSuccess({
response: {
status: 204,
},
handler: (req: MockRequest) => {
req.expect.containsHeader("x-ms-api-key", "valid-key");
return { status: 204 };
},
kind: "MockApiDefinition",
});

Expand All @@ -32,9 +28,5 @@ Scenarios.Authentication_Union_validToken = passOnSuccess({
response: {
status: 204,
},
handler: (req: MockRequest) => {
req.expect.containsHeader("authorization", "Bearer https://security.microsoft.com/.default");
return { status: 204 };
},
kind: "MockApiDefinition",
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ namespace _Specs_.Azure.ClientGenerator.Core.Access;
@scenario
@scenarioDoc("""
This scenario contains public operations. It should be generated and exported.
Expected query parameter: name=<any string>
Expected query parameter: name="sample"
Expected response body:
```json
{
"name": <any string>
"name": "sample"
}
```
""")
Expand Down Expand Up @@ -51,11 +51,11 @@ namespace PublicOperation {
@scenario
@scenarioDoc("""
This scenario contains internal operations. All should be generated but not exposed.
Expected query parameter: name=<any string>
Expected query parameter: name= "sample"
Expected response body:
```json
{
"name": <any string>
"name": "sample"
}
```
""")
Expand Down Expand Up @@ -98,11 +98,11 @@ namespace InternalOperation {
@scenario
@scenarioDoc("""
This scenario contains two operations, one public, another internal. The public one should be generated and exported while the internal one should be generated but not exposed.
Expected query parameter: name=<any string>
Expected query parameter: name= "sample"
Expected response body:
```json
{
"name": <any string>
"name": "sample"
}
```
""")
Expand Down Expand Up @@ -157,14 +157,14 @@ namespace RelativeModelInOperation {
}

@doc("""
Expected query parameter: name=<any string>
Expected query parameter: name="Madge"
Expected response body:
```json
{
"name": <any string>,
"name": "Madge",
"inner":
{
"name": <any string>
"name": "Madge"
}
}
```
Expand All @@ -175,11 +175,11 @@ namespace RelativeModelInOperation {
op operation(@query name: string): OuterModel;

@doc("""
Expected query parameter: kind=<any string>
Expected query parameter: kind= "real"
Expected response body:
```json
{
"name": <any string>,
"name": "Madge",
"kind": "real"
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { passOnSuccess, ValidationError, json, MockApiDefinition, MockRequest } from "@azure-tools/cadl-ranch-api";
import { passOnSuccess, json, MockApiDefinition } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};
Expand All @@ -16,15 +16,6 @@ function createMockApiDefinitions(route: string): MockApiDefinition {
status: 200,
body: json({ name: "sample" }),
},
handler: (req: MockRequest) => {
if (!("name" in req.query)) {
throw new ValidationError("Should submit name query", "any string", undefined);
}
return {
status: 200,
body: json({ name: req.query["name"] }),
};
},
kind: "MockApiDefinition",
};
}
Expand Down Expand Up @@ -58,15 +49,6 @@ Scenarios.Azure_ClientGenerator_Core_Access_RelativeModelInOperation = passOnSuc
status: 200,
body: json({ name: "Madge", inner: { name: "Madge" } }),
},
handler: (req: MockRequest) => {
if (!("name" in req.query)) {
throw new ValidationError("Should submit name query", "any string", undefined);
}
return {
status: 200,
body: json({ name: "Madge", inner: { name: "Madge" } }),
};
},
kind: "MockApiDefinition",
},
{
Expand All @@ -81,15 +63,6 @@ Scenarios.Azure_ClientGenerator_Core_Access_RelativeModelInOperation = passOnSuc
status: 200,
body: json({ name: "Madge", kind: "real" }),
},
handler: (req: MockRequest) => {
if (!("kind" in req.query)) {
throw new ValidationError("Should submit name query", "any string", undefined);
}
return {
status: 200,
body: json({ name: "Madge", kind: "real" }),
};
},
kind: "MockApiDefinition",
},
]);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { passOnSuccess, json, MockApiDefinition, MockRequest } from "@azure-tools/cadl-ranch-api";
import { passOnSuccess, json, MockApiDefinition } from "@azure-tools/cadl-ranch-api";
import { ScenarioMockApi } from "@azure-tools/cadl-ranch-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};
Expand All @@ -13,13 +13,6 @@ function createMockApiDefinitions(route: string, request: any, response: any): M
status: 200,
body: json(response),
},
handler: (req: MockRequest) => {
req.expect.bodyEquals(request);
return {
status: 200,
body: json(response),
};
},
kind: "MockApiDefinition",
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace ModelInOperation {
Expected body parameter:
```json
{
"name": <any string>
"name": "Madge"
}
```
""")
Expand All @@ -48,7 +48,7 @@ namespace ModelInOperation {
Expected response body:
```json
{
"name": <any string>
"name": "Madge"
}
```
""")
Expand Down Expand Up @@ -78,7 +78,7 @@ namespace ModelInOperation {
```json
{
"result": {
"name": <any string>
"name": "Madge"
}
}
```
Expand Down
Loading

0 comments on commit c9184bb

Please sign in to comment.