def test_validate_ota_image_simple_valid(): image = OTAImage() image.subelements = [ create_subelement(ElementTagId.UPGRADE_IMAGE, VALID_EBL_IMAGE), ] assert validators.validate_ota_image(image) == ValidationResult.VALID
def test_validate_ota_image_mixed_valid(): image = OTAImage() image.subelements = [ create_subelement(ElementTagId.UPGRADE_IMAGE, b"unknown1"), create_subelement(ElementTagId.UPGRADE_IMAGE, VALID_EBL_IMAGE), ] assert validators.validate_ota_image(image) == ValidationResult.UNKNOWN
def test_validate_ota_image_invalid(): image = OTAImage() image.subelements = [ create_subelement(ElementTagId.UPGRADE_IMAGE, VALID_EBL_IMAGE[:-1]), ] with pytest.raises(ValidationError): validators.validate_ota_image(image)
def test_validate_ota_image_complex_valid(): image = OTAImage() image.subelements = [ create_subelement(ElementTagId.ECDSA_SIGNATURE, b"asd"), create_subelement(ElementTagId.UPGRADE_IMAGE, VALID_EBL_IMAGE), create_subelement(ElementTagId.UPGRADE_IMAGE, VALID_GBL_IMAGE), create_subelement(ElementTagId.ECDSA_SIGNING_CERTIFICATE, b"foo"), ] assert validators.validate_ota_image(image) == ValidationResult.VALID
def test_validate_ota_image_empty(): image = OTAImage() image.subelements = [] assert validators.validate_ota_image(image) == ValidationResult.UNKNOWN