Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
Nilton Lima committed Sep 19, 2024
1 parent 9a2fcc1 commit 67d23ca
Show file tree
Hide file tree
Showing 140 changed files with 1,227 additions and 1,117 deletions.
19 changes: 18 additions & 1 deletion lib/generator/mocker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as uuid from "uuid";
import RandExp from "randexp";
import { log } from "../util/logging";

function randomString(length: number): string {
Expand Down Expand Up @@ -55,6 +56,22 @@ export default class Mocker {
return `${Buffer.from(paramName + "1").toString("base64")}`;
}

if (paramSpec.format == "arm-id") {
const subscriptionId = uuid.v4().toUpperCase();
if (
paramSpec["x-ms-arm-id-details"] &&
paramSpec["x-ms-arm-id-details"]["allowedResources"].Count > 0
) {
return (
`/subscriptions/${subscriptionId}/resourceGroups/myRg/providers` +
paramSpec["x-ms-arm-id-details"]["allowedResources"][0].type +
"/myResource"
);
}

return `/subscriptions/${subscriptionId}/resourceGroups/myRg/providers/resourceProviderNamespace/myResourceType/myResource`;
}

if ("enum" in paramSpec) {
if (paramSpec.enum.lengh > 0) {
console.error(`${paramName}'s enum can not be empty`);
Expand All @@ -67,7 +84,7 @@ export default class Mocker {
let mockedValue = randomString(length);

if ("pattern" in paramSpec) {
return `Replace this value with a string matching RegExp ${paramSpec.pattern}`;
return new RandExp(paramSpec.pattern).gen();
}

if (paramSpec.format === "uri") {
Expand Down
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"newman": "^6.0.0",
"path-to-regexp": "^6.2.1",
"postman-collection": "^4.1.7",
"randexp": "^0.5.3",
"reflect-metadata": "^0.1.13",
"toposort": "^2.0.2",
"uuid": "^3.4.0",
Expand Down Expand Up @@ -138,4 +139,4 @@
"jest-junit": {
"output": "test-results.xml"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@
},
"Domains_Delete_MaximumSet_Gen": {
"$ref": "./examples/Domains_Delete_MaximumSet_Gen.json"
},
"Domains_Delete_MinimumSet_Gen": {
"$ref": "./examples/Domains_Delete_MinimumSet_Gen.json"
}
},
"x-ms-long-running-operation": true
Expand Down Expand Up @@ -692,6 +695,9 @@
},
"DomainTopics_Delete_MaximumSet_Gen": {
"$ref": "./examples/DomainTopics_Delete_MaximumSet_Gen.json"
},
"DomainTopics_Delete_MinimumSet_Gen": {
"$ref": "./examples/DomainTopics_Delete_MinimumSet_Gen.json"
}
},
"x-ms-long-running-operation": true
Expand Down Expand Up @@ -972,6 +978,9 @@
},
"EventSubscriptions_Delete_MaximumSet_Gen": {
"$ref": "./examples/EventSubscriptions_Delete_MaximumSet_Gen.json"
},
"EventSubscriptions_Delete_MinimumSet_Gen": {
"$ref": "./examples/EventSubscriptions_Delete_MinimumSet_Gen.json"
}
},
"x-ms-long-running-operation": true
Expand Down Expand Up @@ -2084,6 +2093,9 @@
},
"Topics_Delete_MaximumSet_Gen": {
"$ref": "./examples/Topics_Delete_MaximumSet_Gen.json"
},
"Topics_Delete_MinimumSet_Gen": {
"$ref": "./examples/Topics_Delete_MinimumSet_Gen.json"
}
},
"x-ms-long-running-operation": true
Expand Down Expand Up @@ -2635,6 +2647,9 @@
},
"PrivateEndpointConnections_Delete_MaximumSet_Gen": {
"$ref": "./examples/PrivateEndpointConnections_Delete_MaximumSet_Gen.json"
},
"PrivateEndpointConnections_Delete_MinimumSet_Gen": {
"$ref": "./examples/PrivateEndpointConnections_Delete_MinimumSet_Gen.json"
}
},
"x-ms-long-running-operation": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "gwkhmaaliulphadcvpjavjqnmeow",
"domainTopicName": "asjpv",
"domainName": "xcoznkjbezjlyatvoaiojaaylv",
"domainTopicName": "pkhchfdfyuqtfotrpc",
"api-version": "2020-06-01"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "iodljwmpvakce",
"domainTopicName": "zcjvlvhrdjqtqoimeq",
"domainName": "suaqltlluoqdlnmi",
"domainTopicName": "mlfnhedrcvnblerltnbuqyymoz",
"api-version": "2020-06-01"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "bpuurjyrmmvjgdkhk",
"domainTopicName": "qpgvxsrh",
"domainName": "ybwrikhyvrq",
"domainTopicName": "ltyljauetekxiuvubvzft",
"api-version": "2020-06-01"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "kfqwmlebsqntdtdybtbqotwtnnlvo",
"domainTopicName": "yxxgwaulyttxrfn",
"domainName": "xngrzx",
"domainTopicName": "mj",
"api-version": "2020-06-01"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "ytvnmzefpuazaurgszj",
"domainTopicName": "mech",
"domainName": "lajfgyhrqqjwgxuicvhnjleueje",
"domainTopicName": "fvscnyezmiuiyyupgnp",
"api-version": "2020-06-01"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "cgqgnbuywyf",
"domainName": "dlvkf",
"api-version": "2020-06-01",
"$filter": "qswocf",
"$top": 30
"$filter": "m",
"$top": 15
},
"responses": {
"200": {
Expand All @@ -30,7 +30,7 @@
"type": "Microsoft.EventGrid/domains/topics"
}
],
"nextLink": "ytsvxheejixghlq"
"nextLink": "bsnseocnthfhflghcsxetfjwmfzfwz"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "kwidhgzjgfrtcbkneysacuj",
"domainName": "g",
"api-version": "2020-06-01"
},
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "bkdtcrhyufheul",
"domainName": "iyoyhhprsxzyijuggni",
"domainInfo": {
"location": "westus2",
"tags": {},
Expand All @@ -27,12 +27,12 @@
"id": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.Network/privateEndpoints/bmtpe5"
},
"groupIds": [
"egkunsjumrmebsehnmhskrthaquly"
"wmhxlcqttvejifmvzpsjszu"
],
"privateLinkServiceConnectionState": {
"status": "Pending",
"description": "mrphqeraeqrrbd",
"actionsRequired": "uyunjjoxnujgwkmttrsg"
"description": "zuhldssqj",
"actionsRequired": "irdplyedjbeyrbicoddfbyvnrd"
},
"provisioningState": "Creating"
}
Expand All @@ -42,25 +42,25 @@
"inputSchemaMapping": {
"properties": {
"id": {
"sourceField": "uwjxmdkwnjcnsahguodyeq"
"sourceField": "asu"
},
"topic": {
"sourceField": "uwjxmdkwnjcnsahguodyeq"
"sourceField": "asu"
},
"eventTime": {
"sourceField": "uwjxmdkwnjcnsahguodyeq"
"sourceField": "asu"
},
"eventType": {
"sourceField": "ezyvfkqyqfmnvfkxavjjyvcgkuvrxj",
"defaultValue": "cvgoovwmsinwmxnyfbzd"
"sourceField": "uhedjzgspkfjtgjxwtsnqbcut",
"defaultValue": "jirj"
},
"subject": {
"sourceField": "ezyvfkqyqfmnvfkxavjjyvcgkuvrxj",
"defaultValue": "cvgoovwmsinwmxnyfbzd"
"sourceField": "uhedjzgspkfjtgjxwtsnqbcut",
"defaultValue": "jirj"
},
"dataVersion": {
"sourceField": "ezyvfkqyqfmnvfkxavjjyvcgkuvrxj",
"defaultValue": "cvgoovwmsinwmxnyfbzd"
"sourceField": "uhedjzgspkfjtgjxwtsnqbcut",
"defaultValue": "jirj"
}
},
"inputSchemaMappingType": "Json"
Expand Down Expand Up @@ -96,18 +96,18 @@
"id": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.Network/privateEndpoints/bmtpe5"
},
"groupIds": [
"egkunsjumrmebsehnmhskrthaquly"
"wmhxlcqttvejifmvzpsjszu"
],
"privateLinkServiceConnectionState": {
"status": "Pending",
"description": "mrphqeraeqrrbd",
"actionsRequired": "uyunjjoxnujgwkmttrsg"
"description": "zuhldssqj",
"actionsRequired": "irdplyedjbeyrbicoddfbyvnrd"
},
"provisioningState": "Creating"
},
"id": "pyhmwq",
"name": "dsruunaacrewv",
"type": "naxqrkhejplkx"
"id": "emebaovepayslap",
"name": "dfehxwuxyelbhkhieyltmblqljdp",
"type": "dffzpaausa"
}
],
"provisioningState": "Succeeded",
Expand All @@ -116,30 +116,30 @@
"inputSchemaMapping": {
"properties": {
"id": {
"sourceField": "uwjxmdkwnjcnsahguodyeq"
"sourceField": "asu"
},
"topic": {
"sourceField": "uwjxmdkwnjcnsahguodyeq"
"sourceField": "asu"
},
"eventTime": {
"sourceField": "uwjxmdkwnjcnsahguodyeq"
"sourceField": "asu"
},
"eventType": {
"sourceField": "ezyvfkqyqfmnvfkxavjjyvcgkuvrxj",
"defaultValue": "cvgoovwmsinwmxnyfbzd"
"sourceField": "uhedjzgspkfjtgjxwtsnqbcut",
"defaultValue": "jirj"
},
"subject": {
"sourceField": "ezyvfkqyqfmnvfkxavjjyvcgkuvrxj",
"defaultValue": "cvgoovwmsinwmxnyfbzd"
"sourceField": "uhedjzgspkfjtgjxwtsnqbcut",
"defaultValue": "jirj"
},
"dataVersion": {
"sourceField": "ezyvfkqyqfmnvfkxavjjyvcgkuvrxj",
"defaultValue": "cvgoovwmsinwmxnyfbzd"
"sourceField": "uhedjzgspkfjtgjxwtsnqbcut",
"defaultValue": "jirj"
}
},
"inputSchemaMappingType": "Json"
},
"metricResourceId": "ulcweuvytjktvgihoeixr"
"metricResourceId": "qkjpozivazyhimqvedrlkkjkf"
},
"id": "/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourceGroups/examplerg/providers/Microsoft.EventGrid/domains/exampledomain2",
"name": "exampledomain2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parameters": {
"subscriptionId": "5b4b650e-28b9-4790-b3ab-ddbd88d727c4",
"resourceGroupName": "rgEventGrid",
"domainName": "zapuxjqccxbtlhmcsgupqpuxg",
"domainName": "x",
"api-version": "2020-06-01"
},
"responses": {
Expand Down
Loading

0 comments on commit 67d23ca

Please sign in to comment.