Skip to content

Commit

Permalink
Strengthen the schema w/r/t format, required fields (#397)
Browse files Browse the repository at this point in the history
This change adds regexs on the new fields, and tests for failure.
  • Loading branch information
johnrandolph committed Jul 28, 2022
1 parent 7a6fed5 commit acc8dc7
Show file tree
Hide file tree
Showing 12 changed files with 182 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .gencode_hash.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
83cf5112955016827f7db491348459ac602bbd46ac29bb885dccaf513b5b3df6 gencode/docs/config.html
3cd595a2ef2e148e6b1a4e7e12a52c4da8b6ecf1222826ca5656ace77be82d05 gencode/docs/config.html
e2944b13db5ff06be9caea51d03bca48f2cb093a8bb583dca14051255d34ea6b gencode/docs/envelope.html
04b55d0e207495a1c471423a5e89347342241bbd3c845de3e8355209692eb70a gencode/docs/event_discovery.html
8133e380e40f27c56accbffc665b2eeb56ec84a4da3b52ba7aa5e439c9c40572 gencode/docs/event_pointset.html
Expand All @@ -11,7 +11,7 @@ a82821e72af6d0ee35800e6262eb9bb05256309b98aed2dad1a368fd2d6882bb gencode/docs/i
43019239edfdad71647c40d254b9b3aec68f3deb0c808ba636530c1cf9985fe0 gencode/docs/state.html
d39d7fe37a41c74a40080af7b0a429d201ab1fdff7444428c4b98eb7b38c332b gencode/java/udmi/schema/Asset.java
0825a5cec83003bb0a6488c4ed7010a04ae0d3848ef36fe01bb4e6718ba7b96d gencode/java/udmi/schema/Aux.java
773223fd813648a9fb1eb890287f45fa127ef19a553186395f05a1a47d818716 gencode/java/udmi/schema/BlobBlobsetConfig.java
d5adb804697243f97cdd8589750401654f3fab075a9aeac4f2851e46695ef11d gencode/java/udmi/schema/BlobBlobsetConfig.java
2c03651cb2ecda072b1418222eebb5560185669f8ffdd03021ad5ad8ff7ba3b0 gencode/java/udmi/schema/BlobBlobsetState.java
d2c5b5aae8db27b68104fc83a1f38de0a3f1b5d683f2b13599adf24e96c7d124 gencode/java/udmi/schema/BlobsetConfig.java
fcbed49f1af8b791d8c52bcbe18f65521a79d9ac3eb33ec3afd9b342ab2bfc56 gencode/java/udmi/schema/BlobsetState.java
Expand Down
119 changes: 116 additions & 3 deletions gencode/docs/config.html

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

3 changes: 2 additions & 1 deletion gencode/java/udmi/schema/BlobBlobsetConfig.java

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

15 changes: 11 additions & 4 deletions schema/config_blobset_blob.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@
"type": "string"
},
"base64": {
"type": "string"
"type": "string",
"pattern": "^[0-9A-Za-z=+/]{4,}$"
},
"url": {
"type": "string"
"type": "string",
"format": "uri"
},
"sha256": {
"type": "string"
"type": "string",
"pattern": "^[0-9a-f]{64}$"
}
}
},
"oneOf": [
{ "required": ["content_type", "base64"] },
{ "required": ["url", "sha256"] }
]
}
23 changes: 23 additions & 0 deletions tests/config.tests/blobset_applied.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 1,
"blobset": {
"blobs": {
"arbitrary_manufacturer_id": {
"phase": "applied",
"content_type": "application/zip",
"base64": "UEsDBAoAAAAAAAZZ3VSU7ZiuBQAAAAUAAAAIABwAYm9vdC5pbWdVVAkAA9xqvGLcarxidXgLAAEEFjQAAARTXwEAYm9vdApQSwMECgAAAAAAB1ndVK9osDMDAAAAAwAAAAYAHABmdy5pbWdVVAkAA95qvGLearxidXgLAAEEFjQAAARTXwEAZncKUEsBAh4DCgAAAAAABlndVJTtmK4FAAAABQAAAAgAGAAAAAAAAQAAAKSBAAAAAGJvb3QuaW1nVVQFAAPcarxidXgLAAEEFjQAAARTXwEAUEsBAh4DCgAAAAAAB1ndVK9osDMDAAAAAwAAAAYAGAAAAAAAAQAAAKSBRwAAAGZ3LmltZ1VUBQAD3mq8YnV4CwABBBY0AAAEU18BAFBLBQYAAAAAAgACAJoAAACKAAAAAAA="
},
"_firmware_update": {
"phase": "applied",
"url": "https://manuf.com/path/file.zip",
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"_endpoint_redirect": {
"phase": "applied",
"content_type": "application/json",
"base64": "e30="
}
}
},
"timestamp": "2022-07-13T12:00:00.000Z"
}
File renamed without changes.
12 changes: 12 additions & 0 deletions tests/config.tests/blobset_applied_incomplete_payload.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"blobset": {
"blobs": {
"arbitrary_manufacturer_id": {
"phase": "applied",
"base64": "UEsDBAoAAAAAAAZZ3VSU7ZiuBQAAAAUAAAAIABwAYm9vdC5pbWdVVAkAA9xqvGLcarxidXgLAAEEFjQAAARTXwEAYm9vdApQSwMECgAAAAAAB1ndVK9osDMDAAAAAwAAAAYAHABmdy5pbWdVVAkAA95qvGLearxidXgLAAEEFjQAAARTXwEAZncKUEsBAh4DCgAAAAAABlndVJTtmK4FAAAABQAAAAgAGAAAAAAAAQAAAKSBAAAAAGJvb3QuaW1nVVQFAAPcarxidXgLAAEEFjQAAARTXwEAUEsBAh4DCgAAAAAAB1ndVK9osDMDAAAAAwAAAAYAGAAAAAAAAQAAAKSBRwAAAGZ3LmltZ1VUBQAD3mq8YnV4CwABBBY0AAAEU18BAFBLBQYAAAAAAgACAJoAAACKAAAAAAA="
}
}
},
"timestamp": "2022-07-13T12:00:00.000Z"
}
2 changes: 2 additions & 0 deletions tests/config.tests/blobset_applied_incomplete_payload.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 schema violations found
instance failed to match exactly one schema (matched 0 out of 2)
12 changes: 12 additions & 0 deletions tests/config.tests/blobset_applied_incomplete_url.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"blobset": {
"blobs": {
"_firmware_update": {
"phase": "applied",
"url": "https://manuf.com/path/file.zip"
}
}
},
"timestamp": "2022-07-13T12:00:00.000Z"
}
2 changes: 2 additions & 0 deletions tests/config.tests/blobset_applied_incomplete_url.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 schema violations found
instance failed to match exactly one schema (matched 0 out of 2)
12 changes: 0 additions & 12 deletions tests/config.tests/steady.json

This file was deleted.

Empty file removed tests/config.tests/steady.out
Empty file.

0 comments on commit acc8dc7

Please sign in to comment.