stage/ovf: mac address pattern

Adds a pattern for the mac address, without delimiters; as this is the
direct input for the virtualbox mac address property.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-07-01 11:23:05 +02:00 committed by Simon de Vlieger
parent 02537089d8
commit 54ac04e001
2 changed files with 5 additions and 2 deletions

View file

@ -40,7 +40,8 @@
"default": "OtherLinux_64" "default": "OtherLinux_64"
}, },
"mac_address": { "mac_address": {
"type": "string" "type": "string",
"pattern": "^[a-fA-F0-9]{12}$"
} }
} }
} }

View file

@ -15,6 +15,8 @@ STAGE_NAME = "org.osbuild.ovf"
({"vmdk": "imagename"}, "'imagename' does not match '[a-zA-Z0-9+_.-]+.vmdk'"), ({"vmdk": "imagename"}, "'imagename' does not match '[a-zA-Z0-9+_.-]+.vmdk'"),
({"vmdk": "imagename.vmdk", "vmware": {"os_type": 1}}, "is not of type 'string'"), ({"vmdk": "imagename.vmdk", "vmware": {"os_type": 1}}, "is not of type 'string'"),
({"vmdk": "imagename.vmdk", "virtualbox": {"os_type": 1}}, "is not of type 'string'"), ({"vmdk": "imagename.vmdk", "virtualbox": {"os_type": 1}}, "is not of type 'string'"),
({"vmdk": "imagename.vmdk", "virtualbox": {"mac_address": 1}}, "is not of type 'string'"),
({"vmdk": "imagename.vmdk", "virtualbox": {"mac_address": "1"}}, "'1' does not match '^[a-fA-F0-9]{12}$'"),
# Good API parameters # Good API parameters
({"vmdk": "imagename.vmdk"}, ""), ({"vmdk": "imagename.vmdk"}, ""),
({"vmdk": "imagename.vmdk", "vmware": {"os_type": "OtherGuest"}, "virtualbox": {"os_type": "OtherGuest"}}, ""), ({"vmdk": "imagename.vmdk", "vmware": {"os_type": "OtherGuest"}, "virtualbox": {"os_type": "OtherGuest"}}, ""),
@ -46,7 +48,7 @@ def test_schema_validation_ovf(stage_schema, test_data, expected_err):
# Replacements # Replacements
({"vmware": {"os_type": "my-vmware-os-type"}}, ["my-vmware-os-type"],), ({"vmware": {"os_type": "my-vmware-os-type"}}, ["my-vmware-os-type"],),
({"virtualbox": {"os_type": "my-vbox-os-type"}}, ["my-vbox-os-type"],), ({"virtualbox": {"os_type": "my-vbox-os-type"}}, ["my-vbox-os-type"],),
({"virtualbox": {"mac_address": "my-mac-address"}}, ["my-mac-address"],), ({"virtualbox": {"mac_address": "000000000000"}}, ["000000000000"],),
]) ])
def test_ovf_default_template(tmp_path, stage_module, test_opts, expected_substrings): def test_ovf_default_template(tmp_path, stage_module, test_opts, expected_substrings):
faked_vmdk_path = tmp_path / "some-image.vmdk" faked_vmdk_path = tmp_path / "some-image.vmdk"