Apply the latest version of yasway and add the error code of SECRET_PROPERTY (#456)

This commit is contained in:
Renhe Li 2019-10-12 16:41:58 +08:00 коммит произвёл GitHub
Родитель 26cb277199
Коммит a4b3f87b39
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 293 добавлений и 13 удалений

Просмотреть файл

@ -54,6 +54,7 @@ const errorConstants = {
docUrl: ""
},
UNRESOLVABLE_REFERENCE: { severity: Severity.Critical, docUrl: "" },
SECRET_PROPERTY: { severity: Severity.Critical, docUrl: "" },
OBJECT_PROPERTIES_MINIMUM: {
severity: Severity.Critical,
docUrl: ""

Просмотреть файл

@ -38,7 +38,8 @@ export class ValidateResponse {
OBJECT_MISSING_REQUIRED_PROPERTY: "M6013",
OBJECT_MISSING_REQUIRED_PROPERTY_DEFINITION: "M6014",
ENUM_MISMATCH: "M6015",
ENUM_CASE_MISMATCH: "M6016"
ENUM_CASE_MISMATCH: "M6016",
SECRET_PROPERTY: "M6017"
}
public constructErrors(

47
package-lock.json сгенерированный
Просмотреть файл

@ -4190,12 +4190,12 @@
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
},
"json-schema-faker": {
"version": "0.5.0-rc17",
"resolved": "https://registry.npmjs.org/json-schema-faker/-/json-schema-faker-0.5.0-rc17.tgz",
"integrity": "sha512-ZQSLPpnsGiMBuPOHi09cAzhsiIeOcs5im2GAQ2P6XKyWOuetO8eYdYCP/kW7VVU891Ucan0/dl8GYbRA6pf9gw==",
"version": "0.5.0-rc19",
"resolved": "https://registry.npmjs.org/json-schema-faker/-/json-schema-faker-0.5.0-rc19.tgz",
"integrity": "sha512-yJLDodgoc/BOONGFmyuKoj3bSRXZ55FWIp1WjN0yC76kfoIz+lI5ttjUtU8NxgNULGFppJzpUM0ydyAWH3qp7A==",
"requires": {
"json-schema-ref-parser": "^6.0.2",
"jsonpath": "^1.0.1",
"json-schema-ref-parser": "^6.1.0",
"jsonpath-plus": "^1.0.0",
"randexp": "^0.5.3"
}
},
@ -4245,6 +4245,11 @@
}
}
},
"jsonpath-plus": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-1.1.0.tgz",
"integrity": "sha512-ydqTBOuLcFCUr9e7AxJlKCFgxzEQ03HjnIim0hJSdk2NxD8MOsaMOrRgP6XWEm5q3VuDY5+cRT1DM9vLlGo/qA=="
},
"jsonschema": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.4.tgz",
@ -6578,12 +6583,13 @@
}
},
"yasway": {
"version": "1.8.4",
"resolved": "https://registry.npmjs.org/yasway/-/yasway-1.8.4.tgz",
"integrity": "sha512-Oo6dFvmazhQU6ceazUm59BVraptSXTDhvpW2K14DcpgeyTAyUUpJjuE7HJ4qyF+Ci6blIaQq9mOVHj8pCFhEjQ==",
"version": "1.8.5",
"resolved": "https://registry.npmjs.org/yasway/-/yasway-1.8.5.tgz",
"integrity": "sha512-aa1qTc/LZna6fO/hEIqEhLKBaZ7PkCUDT9Zp75DtB9DeX+htS37Zr9kah0uzwoh0E9XoLhk42aQWBnUFJnLH9Q==",
"requires": {
"@ts-common/json": "^0.3.0",
"@ts-common/string-map": "^0.3.0",
"@ts-common/z-schema": "^4.1.2",
"debug": "^4.1.1",
"faker": "^4.1.0",
"istanbul": "^0.4.5",
@ -6595,10 +6601,26 @@
"native-promise-only": "^0.8.1",
"path-to-regexp": "^1.7.0",
"swagger-methods": "^1.0.8",
"swagger-schema-official": "2.0.0-bab6bed",
"z-schema": "^4.1.0"
"swagger-schema-official": "2.0.0-bab6bed"
},
"dependencies": {
"@ts-common/z-schema": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@ts-common/z-schema/-/z-schema-4.1.2.tgz",
"integrity": "sha512-PDMAza1jpnCpUUSSVf3LBtTyeo5s9xLQlD68gvW3B0j+RbnxYK9CHHCeLOZxBoKviBgr8+tps6ZVmUCcMSmiFw==",
"requires": {
"commander": "^2.7.1",
"core-js": "^3.2.1",
"lodash.get": "^4.4.2",
"lodash.isequal": "^4.5.0",
"validator": "^11.0.0"
}
},
"core-js": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.1.tgz",
"integrity": "sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw=="
},
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
@ -6611,6 +6633,11 @@
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"validator": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/validator/-/validator-11.1.0.tgz",
"integrity": "sha512-qiQ5ktdO7CD6C/5/mYV4jku/7qnqzjrxb3C/Q5wR3vGGinHTgJZN/TdFT3ZX4vXhX2R1PXx42fB1cn5W+uJ4lg=="
}
}
},

Просмотреть файл

@ -37,7 +37,7 @@
"vscode-jsonrpc": "^3.6.2",
"winston": "^3.2.1",
"yargs": "^6.6.0",
"yasway": "^1.8.4",
"yasway": "^1.8.5",
"yuml2svg": "^4.2.1",
"z-schema": "^4.1.0"
},

Просмотреть файл

@ -640,3 +640,53 @@ Object {
},
}
`;
exports[`Live validator snapshot validation should return the expected error requestResponse validation for SECRET_PROPERTY 1`] = `
Object {
"requestValidationResult": Object {
"errors": Array [],
"isSuccessful": true,
"operationInfo": Object {
"apiVersion": "2018-01-01",
"operationId": "SecretUser_Get",
},
"runtimeException": undefined,
},
"responseValidationResult": Object {
"errors": Array [
Object {
"code": "SECRET_PROPERTY",
"documentationUrl": "",
"inner": undefined,
"jsonPathsInPayload": Array [
"$.properties.password",
],
"message": "Secret property \`\\"password\\": \\"aaaaaa\\"\`, cannot be sent in the response.",
"params": Array [
"password",
"aaaaaa",
],
"pathsInPayload": Array [
"properties/password",
],
"schemaPath": "",
"severity": 0,
"source": Object {
"jsonRef": "#/definitions/SecretUserContractProperties/properties/password",
"position": Object {
"column": 21,
"line": 134,
},
"url": "specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2018-01-01/apimusersecret.json",
},
},
],
"isSuccessful": false,
"operationInfo": Object {
"apiVersion": "2018-01-01",
"operationId": "SecretUser_Get",
},
"runtimeException": undefined,
},
}
`;

Просмотреть файл

@ -0,0 +1,35 @@
{
"liveRequest": {
"headers": {
"strict-Transport-Security": "max-age=31536000; includeSubDomains",
"x-ms-request-id": "8e3485b6-c8a7-45c2-a9f5-59b826e42880",
"date": "Tue, 11 Sep 2018 18:45:41 GMT",
"eTag": "\"AAAAAAAAjAIAAAAAAACL/A==\"",
"server": "Microsoft-HTTPAPI/2.0",
"Content-Type": "application/json"
},
"method": "GET",
"url": "/subscriptions/randomSub/resourceGroups/randomRG/providers/Microsoft.ApiManagement/service/randomService/secretusers/randomUsers?api-version=2018-01-01",
"query": {
"api-version": "2018-01-01"
}
},
"liveResponse": {
"statusCode": "200",
"headers": {
"x-ms-request-id": "8e3485b6-c8a7-45c2-a9f5-59b826e42880",
"date": "Tue, 11 Sep 2018 18:45:41 GMT",
"eTag": "\"AAAAAAAAjAIAAAAAAACL/A==\"",
"server": "Microsoft-HTTPAPI/2.0",
"Content-Type": "application/json"
},
"body": {
"properties": {
"firstName": "aaaaa",
"lastName": "aaaaa",
"email": "aaaaaaaaaaaaaaaaaaaaa",
"password": "aaaaaa"
}
}
}
}

Просмотреть файл

@ -0,0 +1,165 @@
{
"swagger": "2.0",
"info": {
"title": "ApiManagementClient",
"description": "Use these REST APIs for performing operations on User entity in Azure API Management deployment. The User entity in API Management represents the developers that call the APIs of the products to which they are subscribed.",
"version": "2018-01-01"
},
"host": "management.azure.com",
"schemes": ["https"],
"consumes": ["application/json"],
"produces": ["application/json"],
"security": [
{
"azure_auth": ["user_impersonation"]
}
],
"securityDefinitions": {
"azure_auth": {
"type": "oauth2",
"authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize",
"flow": "implicit",
"description": "Azure Active Directory OAuth2 Flow.",
"scopes": {
"user_impersonation": "impersonate your user account"
}
}
},
"paths": {
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/secretusers/{uid}": {
"head": {
"tags": ["SecretUsers"],
"operationId": "SecretUser_GetEntityTag",
"description": "Gets the entity state (Etag) version of the user specified by its identifier.",
"parameters": [
{
"$ref": "./apimanagement.json#/parameters/ResourceGroupNameParameter"
},
{
"$ref": "./apimanagement.json#/parameters/ServiceNameParameter"
},
{
"$ref": "#/parameters/SecretUserIdParameter"
},
{
"$ref": "./apimanagement.json#/parameters/ApiVersionParameter"
},
{
"$ref": "./apimanagement.json#/parameters/SubscriptionIdParameter"
}
],
"responses": {
"200": {
"description": "Specified user entity exists and current entity state version is present in the ETag header.",
"headers": {
"ETag": {
"description": "Current entity state version. Should be treated as opaque and used to make conditional HTTP requests.",
"type": "string"
}
}
},
"default": {
"description": "Error response describing why the operation failed.",
"schema": {
"$ref": "./apimanagement.json#/definitions/ErrorResponse"
}
}
}
},
"get": {
"tags": ["Users"],
"operationId": "SecretUser_Get",
"description": "Gets the details of the user specified by its identifier.",
"parameters": [
{
"$ref": "./apimanagement.json#/parameters/ResourceGroupNameParameter"
},
{
"$ref": "./apimanagement.json#/parameters/ServiceNameParameter"
},
{
"$ref": "#/parameters/SecretUserIdParameter"
},
{
"$ref": "./apimanagement.json#/parameters/ApiVersionParameter"
},
{
"$ref": "./apimanagement.json#/parameters/SubscriptionIdParameter"
}
],
"responses": {
"200": {
"description": "Gets the specified user entity.",
"schema": {
"$ref": "#/definitions/SecretUserContract"
},
"headers": {
"ETag": {
"description": "Current entity state version. Should be treated as opaque and used to make conditional HTTP requests.",
"type": "string"
}
}
},
"default": {
"description": "Error response describing why the operation failed.",
"schema": {
"$ref": "./apimanagement.json#/definitions/ErrorResponse"
}
}
}
}
}
},
"definitions": {
"SecretUserContract": {
"properties": {
"properties": {
"x-ms-client-flatten": true,
"$ref": "#/definitions/SecretUserContractProperties",
"description": "User entity contract properties."
}
},
"description": "User details."
},
"SecretUserContractProperties": {
"properties": {
"firstName": {
"type": "string",
"description": "First name."
},
"lastName": {
"type": "string",
"description": "Last name."
},
"password": {
"type": "string",
"description": "password.",
"x-ms-secret": ["password"]
},
"email": {
"type": "string",
"description": "Email address."
},
"registrationDate": {
"type": "string",
"format": "date-time",
"description": "Date of user registration. The date conforms to the following format: `yyyy-MM-ddTHH:mm:ssZ` as specified by the ISO 8601 standard.\n"
}
},
"description": "User profile."
}
},
"parameters": {
"SecretUserIdParameter": {
"name": "uid",
"in": "path",
"required": true,
"type": "string",
"description": "User identifier. Must be unique in the current API Management service instance.",
"minLength": 1,
"maxLength": 80,
"pattern": "(^[\\w]+$)|(^[\\w][\\w\\-]+[\\w]$)",
"x-ms-parameter-location": "method"
}
}
}

Просмотреть файл

@ -488,7 +488,8 @@ describe("Live validator snapshot validation", () => {
"INVALID_FORMAT",
"INVALID_TYPE",
"ENUM_MISMATCH",
"ENUM_CASE_MISMATCH"
"ENUM_CASE_MISMATCH",
"SECRET_PROPERTY"
]
beforeAll(async () => {
const options = {