Unverified Commit 1ff6f48a authored by Dan Jones's avatar Dan Jones
Browse files

test: test validate method

Add test to check that the mock schema is valid
If the mock schema is not valid then invalid messages
can be marked as valid which makes the tests ineffective
parent 8b0e7ce8
{
"message_type": "VehicleStatus",
"headers": {
"metadata": {
"source": "ae",
"destination": "soar.po.ecosub.eco1",
"delivery_type": "publish",
......@@ -12,7 +12,7 @@
"latitude": 57.234,
"longitude": -8.432,
"depth": 50,
"projection": "EPSG:4326"
"projection": 4326
},
"battery_percentage": 64
}
{
"swagger": "2.0",
"basePath": "/soar",
"openapi": "3.0.3",
"info": {
"title": "soar",
"version": "1.3.1",
"version": "1.0",
"description": "SoAR message schemas"
},
"produces": ["application/json"],
"consumes": ["application/json"],
"definitions": {
"Message": {
"discriminator": {
"propertyName": "message_type",
"mapping": {
"VehicleStatus": "#/definitions/VehicleStatus",
"VehicleMission": "#/definitions/VehicleMission",
"AreaOfInterest": "#/definitions/AreaOfInterest"
}
},
"oneOf": [
{
"$ref": "#/definitions/VehicleStatus"
},
{
"$ref": "#/definitions/VehicleMission"
},
{
"$ref": "#/definitions/AreaOfInterest"
}
]
},
"Metadata": {
"properties": {
"source": {
"type": "string",
"description": "The sender.",
"example": "autonomy-engine"
},
"destination": {
"type": "string",
"description": "Publisher topic.",
"example": "soar.noc.autosub.ah1.status"
},
"delivery_type": {
"type": "string",
"description": "Published or broadcast",
"enum": ["broadcast", "publish"],
"example": "2.0.0"
"paths": {},
"components": {
"schemas": {
"Message": {
"properties": {
"metadata": {
"$ref": "#/components/schemas/Metadata"
},
"payload": {
"$ref": "#/components/schemas/Payload"
}
},
"message_id": {
"type": "string",
"description": "An identifier for the type of message received.",
"example": "VehicleStatus"
}
"required": ["metadata", "payload"]
},
"type": "object"
},
"Coordinates": {
"properties": {
"latitude": {
"type": "number",
"description": "Latitude in decimal degrees.",
"example": 54.234
},
"longitude": {
"type": "number",
"description": "Longitude in decimal degrees.",
"example": -1.432
},
"depth": {
"type": "number",
"description": "Target depth",
"default": 0,
"example": 50
},
"altitude": {
"type": "number",
"description": "Target altitude above bottom",
"default": 0,
"example": 50
},
"projection": {
"type": "integer",
"description": "EPSG Projection Code",
"example": 4326,
"default": 4326
}
}
},
"VehicleStatus": {
"properties": {
"message_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "VehicleStatus",
"enum": ["VehicleStatus"]
},
"metadata": {
"$ref": "#/definitions/Metadata"
},
"operator_id": {
"type": "string",
"description": "An identifier for the operator.",
"example": "noc"
},
"vehicle_id": {
"type": "string",
"description": "An identifier for the vehicle.",
"example": "noc_ah1"
},
"coordinates": {
"$ref": "#/definitions/Coordinates"
},
"battery_percentage": {
"type": "number",
"description": "The remaining battery capacity.",
"example": 64
}
}
},
"VehicleMission": {
"properties": {
"message_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "VehicleMission",
"enum": ["VehicleMission"]
},
"metadata": {
"$ref": "#/definitions/Metadata"
"Payload": {
"discriminator": {
"propertyName": "message_type",
"mapping": {
"VehicleStatus": "#/components/schemas/VehicleStatus",
"VehicleMission": "#/components/schemas/VehicleMission",
"AreaOfInterest": "#/components/schemas/AreaOfInterest"
}
},
"operator_id": {
"type": "string",
"description": "An identifier for the operator.",
"example": "noc"
"oneOf": [
{
"$ref": "#/components/schemas/VehicleStatus"
},
{
"$ref": "#/components/schemas/VehicleMission"
},
{
"$ref": "#/components/schemas/AreaOfInterest"
}
]
},
"Metadata": {
"properties": {
"source": {
"type": "string",
"description": "The sender.",
"example": "autonomy-engine"
},
"destination": {
"type": "string",
"description": "Publisher topic.",
"example": "soar.noc.autosub.ah1.status"
},
"delivery_type": {
"type": "string",
"description": "Published or broadcast",
"enum": ["broadcast", "publish"],
"example": "2.0.0"
},
"message_id": {
"type": "string",
"description": "An identifier for the type of message received.",
"example": "VehicleStatus"
}
},
"vehicle_id": {
"type": "string",
"description": "An identifier for the vehicle.",
"example": "noc_ah1"
"required": ["source","destination","message_id"],
"type": "object"
},
"Coordinates": {
"properties": {
"latitude": {
"type": "number",
"description": "Latitude in decimal degrees.",
"example": 54.234
},
"longitude": {
"type": "number",
"description": "Longitude in decimal degrees.",
"example": -1.432
},
"depth": {
"type": "number",
"description": "Target depth",
"default": 0,
"example": 50
},
"altitude": {
"type": "number",
"description": "Target altitude above bottom",
"default": 0,
"example": 50
},
"projection": {
"type": "integer",
"description": "EPSG Projection Code",
"example": 4326,
"default": 4326
}
},
"coordinates": {
"$ref": "#/definitions/Coordinates"
"required": ["latitude", "longitude"],
"type": "object"
},
"VehicleStatus": {
"properties": {
"message_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "VehicleStatus",
"enum": ["VehicleStatus"]
},
"operator_id": {
"type": "string",
"description": "An identifier for the operator.",
"example": "noc"
},
"vehicle_id": {
"type": "string",
"description": "An identifier for the vehicle.",
"example": "noc_ah1"
},
"coordinates": {
"$ref": "#/components/schemas/Coordinates"
},
"battery_percentage": {
"type": "number",
"description": "The remaining battery capacity.",
"example": 64
}
},
"actions": {
"type": "array",
"items": {
"discriminator": {
"propertyName": "action_type",
"mapping": {
"GoToWaypoint": "#/definitions/GoToWaypoint",
"DescendToAltitude": "#/definitions/DescendToAltitude",
"AscendToSurface": "#/definitions/AscendToSurface"
}
},
"oneOf": [
{
"$ref": "#/definitions/VehicleStatus"
},
{
"$ref": "#/definitions/VehicleMission"
"required": ["message_type", "operator_id", "vehicle_id", "coordinates", "battery_percentage"],
"type": "object"
},
"VehicleMission": {
"properties": {
"message_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "VehicleMission",
"enum": ["VehicleMission"]
},
"operator_id": {
"type": "string",
"description": "An identifier for the operator.",
"example": "noc"
},
"vehicle_id": {
"type": "string",
"description": "An identifier for the vehicle.",
"example": "noc_ah1"
},
"coordinates": {
"$ref": "#/components/schemas/Coordinates"
},
"actions": {
"type": "array",
"items": {
"discriminator": {
"propertyName": "action_type",
"mapping": {
"GoToWaypoint": "#/components/schemas/GoToWaypoint",
"DescendToAltitude": "#/components/schemas/DescendToAltitude",
"AscendToSurface": "#/components/schemas/AscendToSurface"
}
},
{
"$ref": "#/definitions/AreaOfInterest"
}
]
"oneOf": [
{
"$ref": "#/components/schemas/VehicleStatus"
},
{
"$ref": "#/components/schemas/VehicleMission"
},
{
"$ref": "#/components/schemas/AreaOfInterest"
}
]
}
}
}
}
},
"AreaOfInterest": {
"properties": {
"message_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "AreaOfInterest",
"enum": ["AreaOfInterest"]
},
"metadata": {
"$ref": "#/definitions/Metadata"
},
"operator_id": {
"type": "string",
"description": "An identifier for the operator.",
"example": "noc"
},
"vehicle_id": {
"type": "string",
"description": "An identifier for the vehicle.",
"example": "noc_ah1"
"required": ["message_type", "operator_id", "vehicle_id", "coordinates", "actions"],
"type": "object"
},
"AreaOfInterest": {
"properties": {
"message_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "AreaOfInterest",
"enum": ["AreaOfInterest"]
},
"operator_id": {
"type": "string",
"description": "An identifier for the operator.",
"example": "noc"
},
"vehicle_id": {
"type": "string",
"description": "An identifier for the vehicle.",
"example": "noc_ah1"
},
"coordinates": {
"$ref": "#/components/schemas/Coordinates"
}
},
"coordinates": {
"$ref": "#/definitions/Coordinates"
}
}
},
"GoToWaypoint": {
"properties": {
"action_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "GoToWaypoint",
"enum": ["GoToWaypoint"]
"required": ["message_type", "operator_id", "vehicle_id", "coordinates"],
"type": "object"
},
"GoToWaypoint": {
"properties": {
"action_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "GoToWaypoint",
"enum": ["GoToWaypoint"]
},
"coordinates": {
"$ref": "#/components/schemas/Coordinates"
}
},
"coordinates": {
"$ref": "#/definitions/Coordinates"
}
}
},
"DescendToAltitude": {
"properties": {
"action_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "DescendToAltitude",
"enum": ["DescendToAltitude"]
"type": "object"
},
"DescendToAltitude": {
"properties": {
"action_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "DescendToAltitude",
"enum": ["DescendToAltitude"]
},
"coordinates": {
"$ref": "#/components/schemas/Coordinates"
}
},
"coordinates": {
"$ref": "#/definitions/Coordinates"
}
}
},
"AscendToSurface": {
"properties": {
"action_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "AscendToSurface",
"enum": ["AscendToSurface"]
"type": "object"
},
"AscendToSurface": {
"properties": {
"action_type": {
"type": "string",
"description": "An identifier for the payload type.",
"example": "AscendToSurface",
"enum": ["AscendToSurface"]
},
"coordinates": {
"$ref": "#/components/schemas/Coordinates"
}
},
"coordinates": {
"$ref": "#/definitions/Coordinates"
}
"type": "object"
}
}
}
......
......@@ -1081,6 +1081,13 @@ aggregate-error@^3.0.0:
clean-stack "^2.0.0"
indent-string "^4.0.0"
ajv-formats@^2.0.2:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520"
integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==
dependencies:
ajv "^8.0.0"
ajv@^6.10.0, ajv@^6.12.4:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
......@@ -1091,6 +1098,16 @@ ajv@^6.10.0, ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
ajv@^8.0.0, ajv@^8.1.0:
version "8.12.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1"
integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==
dependencies:
fast-deep-equal "^3.1.1"
json-schema-traverse "^1.0.0"
require-from-string "^2.0.2"
uri-js "^4.2.2"
ansi-escapes@^4.2.1, ansi-escapes@^4.3.0:
version "4.3.2"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e"
......@@ -2951,6 +2968,11 @@ json-schema-traverse@^0.4.1:
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
json-schema-traverse@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2"
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
......@@ -3086,7 +3108,7 @@ lodash.isequal@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==
lodash.merge@^4.6.2:
lodash.merge@^4.6.1, lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
......@@ -3337,6 +3359,21 @@ onetime@^5.1.0, onetime@^5.1.2:
dependencies:
mimic-fn "^2.1.0"
openapi-schema-validator@^12.1.0:
version "12.1.0"
resolved "https://registry.yarnpkg.com/openapi-schema-validator/-/openapi-schema-validator-12.1.0.tgz#8ab5c7fd57189551126589426e5d71d8190eb80f"
integrity sha512-gr9mZCHu5QmADePYNhizaSAsB0HdY/DespPue10NQID1jB+56Jf+dfnJcnMOVKsG4ZAedVY5oyLFGI1Gk0wm7w==
dependencies:
ajv "^8.1.0"
ajv-formats "^2.0.2"
lodash.merge "^4.6.1"
openapi-types "^12.1.0"
openapi-types@^12.1.0:
version "12.1.0"
resolved "https://registry.yarnpkg.com/openapi-types/-/openapi-types-12.1.0.tgz#bd01acc937b73c9f6db2ac2031bf0231e21ebff0"
integrity sha512-XpeCy01X6L5EpP+6Hc3jWN7rMZJ+/k1lwki/kTmWzbVhdPie3jd5O2ZtedEx8Yp58icJ0osVldLMrTB/zslQXA==
optionator@^0.8.1:
version "0.8.3"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
......@@ -3644,6 +3681,11 @@ require-directory@^2.1.1:
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==
require-from-string@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909"
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==
requires-port@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment