diff --git a/pkgschema/schemas/definitions.json b/pkgschema/schemas/definitions.json index e93bb00..783feff 100644 --- a/pkgschema/schemas/definitions.json +++ b/pkgschema/schemas/definitions.json @@ -2,7 +2,7 @@ "mode": { "description": "Represents the install mode for the object data", "type": "string", - "enum": ["copy", "flash", "imxkobs", "raw", "tarball", "ubifs", "mender", "zephyr"] + "enum": ["copy", "flash", "imxkobs", "raw", "tarball", "ubifs", "uboot-env", "mender", "zephyr"] }, "filename": { "description": "file name used by client to rebuild the commit", diff --git a/pkgschema/schemas/metadata.json b/pkgschema/schemas/metadata.json index b9ac550..dc623a9 100644 --- a/pkgschema/schemas/metadata.json +++ b/pkgschema/schemas/metadata.json @@ -45,6 +45,7 @@ {"$ref": "raw-object.json"}, {"$ref": "tarball-object.json"}, {"$ref": "ubifs-object.json"}, + {"$ref": "uboot-env-object.json"}, {"$ref": "mender-object.json"}, {"$ref": "zephyr-object.json"} ] diff --git a/pkgschema/schemas/uboot-env-object.json b/pkgschema/schemas/uboot-env-object.json new file mode 100644 index 0000000..97a0902 --- /dev/null +++ b/pkgschema/schemas/uboot-env-object.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + + "title": "U-Boot Environment object", + "description": "Object specifications for U-Boot Environment mode", + + "type": "object", + + "properties": { + "mode": { + "$ref": "definitions.json#/mode" + }, + "filename": { + "$ref": "definitions.json#/filename" + }, + "size": { + "$ref": "definitions.json#/size" + }, + "sha256sum": { + "$ref": "definitions.json#/sha256sum" + } + }, + + "required": [ + "filename", + "mode", + "size", + "sha256sum" + ], + + "additionalProperties": false, + + "dependencies": { + "mode": { + "properties": { + "mode": { + "enum": ["uboot-env"] + } + } + } + } +} diff --git a/tests/pkgschema/fixture-metadata.json b/tests/pkgschema/fixture-metadata.json index 951b032..b8d5278 100644 --- a/tests/pkgschema/fixture-metadata.json +++ b/tests/pkgschema/fixture-metadata.json @@ -92,6 +92,12 @@ "filename": "artifact.bin", "size": 1024, "sha256sum": "cfe2be1c64b0387500853de0f48303e3de7b1c6f1508dc719eeafa0d41c36722" + }, + { + "mode": "uboot-env", + "filename": "updatehub.defenv", + "size": 1024, + "sha256sum": "cfe2be1c64b0387500853de0f48303e3de7b1c6f1508dc719eeafa0d41c36722" } ] ] diff --git a/tests/schemas/fixtures/uboot-env-object/full-document.json b/tests/schemas/fixtures/uboot-env-object/full-document.json new file mode 100644 index 0000000..55a160a --- /dev/null +++ b/tests/schemas/fixtures/uboot-env-object/full-document.json @@ -0,0 +1,6 @@ +{ + "mode": "uboot-env", + "filename": "updatehub.defenv", + "sha256sum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "size": 1024 +} diff --git a/tests/schemas/fixtures/uboot-env-object/minimal-document.json b/tests/schemas/fixtures/uboot-env-object/minimal-document.json new file mode 100644 index 0000000..55a160a --- /dev/null +++ b/tests/schemas/fixtures/uboot-env-object/minimal-document.json @@ -0,0 +1,6 @@ +{ + "mode": "uboot-env", + "filename": "updatehub.defenv", + "sha256sum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "size": 1024 +} diff --git a/tests/schemas/fixtures/uboot-env-object/without-filename-property.json b/tests/schemas/fixtures/uboot-env-object/without-filename-property.json new file mode 100644 index 0000000..619ea94 --- /dev/null +++ b/tests/schemas/fixtures/uboot-env-object/without-filename-property.json @@ -0,0 +1,5 @@ +{ + "mode": "uboot-env", + "sha256sum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "size": 1024 +} diff --git a/tests/schemas/fixtures/uboot-env-object/without-mode-property.json b/tests/schemas/fixtures/uboot-env-object/without-mode-property.json new file mode 100644 index 0000000..6d3cc62 --- /dev/null +++ b/tests/schemas/fixtures/uboot-env-object/without-mode-property.json @@ -0,0 +1,5 @@ +{ + "filename": "updatehub.defenv", + "sha256sum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "size": 1024 +} diff --git a/tests/schemas/fixtures/uboot-env-object/without-sha256sum-property.json b/tests/schemas/fixtures/uboot-env-object/without-sha256sum-property.json new file mode 100644 index 0000000..877f611 --- /dev/null +++ b/tests/schemas/fixtures/uboot-env-object/without-sha256sum-property.json @@ -0,0 +1,5 @@ +{ + "mode": "uboot-env", + "filename": "updatehub.defenv", + "size": 1024 +} diff --git a/tests/schemas/fixtures/uboot-env-object/without-size-property.json b/tests/schemas/fixtures/uboot-env-object/without-size-property.json new file mode 100644 index 0000000..12c8596 --- /dev/null +++ b/tests/schemas/fixtures/uboot-env-object/without-size-property.json @@ -0,0 +1,5 @@ +{ + "mode": "uboot-env", + "filename": "updatehub.defenv", + "sha256sum": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" +} diff --git a/tests/schemas/run.sh b/tests/schemas/run.sh index fa6d87d..401133b 100755 --- a/tests/schemas/run.sh +++ b/tests/schemas/run.sh @@ -933,6 +933,46 @@ runner "ubifs-object target property is required" \ "required: 'target' is a required property" +# SCHEMA: uboot-env-object.json +runner "uboot-env-object minimal document is valid" \ + uboot-env-object.json \ + uboot-env-object/minimal-document.json \ + VALID + +runner "uboot-env-object full document is valid" \ + uboot-env-object.json \ + uboot-env-object/full-document.json \ + VALID + +## PROPERTY: mode +runner "uboot-env-object mode property is required" \ + uboot-env-object.json \ + uboot-env-object/without-mode-property.json \ + INVALID \ + "required: 'mode' is a required property" + +## PROPERTY: filename +runner "uboot-env-object filename property is required" \ + uboot-env-object.json \ + uboot-env-object/without-filename-property.json \ + INVALID \ + "required: 'filename' is a required property" + +## PROPERTY: size +runner "uboot-env-object size property is required" \ + uboot-env-object.json \ + uboot-env-object/without-size-property.json \ + INVALID \ + "required: 'size' is a required property" + +## PROPERTY: sha256sum +runner "uboot-env-object sha256sum property is required" \ + uboot-env-object.json \ + uboot-env-object/without-sha256sum-property.json \ + INVALID \ + "required: 'sha256sum' is a required property" + + # SCHEMA: mender-object.json runner "mender-object expected document is valid" \ mender-object.json \