mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-07 17:26:32 +00:00
Bugfix Add-on validate correct image url (#810)
* Bugfix Add-on validate correct image path * Add tests for different add-on image urls
This commit is contained in:
parent
e23f6f6998
commit
b8818788c9
@ -160,7 +160,7 @@ SCHEMA_ADDON_CONFIG = vol.Schema({
|
||||
}))
|
||||
}), False),
|
||||
vol.Optional(ATTR_IMAGE):
|
||||
vol.Match(r"^([a-zA-Z.:\d{}]+/)*?([\w{}]+)/([\-\w{}]+)$"),
|
||||
vol.Match(r"^([a-zA-Z\-\.:\d{}]+/)*?([\-\w{}]+)/([\-\w{}]+)$"),
|
||||
vol.Optional(ATTR_TIMEOUT, default=10):
|
||||
vol.All(vol.Coerce(int), vol.Range(min=10, max=120)),
|
||||
}, extra=vol.REMOVE_EXTRA)
|
||||
|
@ -29,13 +29,26 @@ def test_basic_config():
|
||||
|
||||
|
||||
def test_invalid_repository():
|
||||
"""Validate basic config with invalid repository."""
|
||||
"""Validate basic config with invalid repositories."""
|
||||
config = load_json_fixture("basic-addon-config.json")
|
||||
|
||||
config['image'] = "home-assistant/no-valid-repo"
|
||||
config['image'] = "something"
|
||||
with pytest.raises(vol.Invalid):
|
||||
vd.SCHEMA_ADDON_CONFIG(config)
|
||||
|
||||
config['image'] = "homeassistant/no-valid-repo:no-tag-allow"
|
||||
with pytest.raises(vol.Invalid):
|
||||
vd.SCHEMA_ADDON_CONFIG(config)
|
||||
|
||||
config['image'] = "registry.gitlab.com/company/add-ons/test-example/text-example:no-tag-allow"
|
||||
with pytest.raises(vol.Invalid):
|
||||
vd.SCHEMA_ADDON_CONFIG(config)
|
||||
|
||||
def test_valid_repository():
|
||||
"""Validate basic config with different valid repositories"""
|
||||
config = load_json_fixture("basic-addon-config.json")
|
||||
|
||||
custom_registry = "registry.gitlab.com/company/add-ons/core/test-example"
|
||||
config['image'] = custom_registry
|
||||
valid_config = vd.SCHEMA_ADDON_CONFIG(config)
|
||||
assert valid_config['image'] == custom_registry
|
||||
|
Loading…
x
Reference in New Issue
Block a user