diff --git a/src/aap_eda/core/validators.py b/src/aap_eda/core/validators.py index f603d6b85..44096d05f 100644 --- a/src/aap_eda/core/validators.py +++ b/src/aap_eda/core/validators.py @@ -102,8 +102,14 @@ def check_if_de_valid(image_url: str, eda_credential_id: int): % {"image_url": image_url} ) - split = path.split(":", 1) - name = split[0] + digest = False + if "@sha256" in path: + split = path.split("@", 1) + name = split[0] + digest = True + else: + split = path.split(":", 1) + name = split[0] # Get the tag sans any additional content. Any additional content # is passed without validation. tag = split[1] if (len(split) > 1) else None @@ -121,7 +127,7 @@ def check_if_de_valid(image_url: str, eda_credential_id: int): % {"image_url": image_url, "name": name} ) - if (tag is not None) and ( + if (not digest and tag is not None) and ( not re.fullmatch(r"[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}", tag) ): raise serializers.ValidationError( diff --git a/tests/integration/api/test_decision_environment.py b/tests/integration/api/test_decision_environment.py index 92d1c0f9d..7701ab6b0 100644 --- a/tests/integration/api/test_decision_environment.py +++ b/tests/integration/api/test_decision_environment.py @@ -345,6 +345,11 @@ def test_create_decision_environment_with_empty_credential( "registry.com/group/img1:latest", "", ), + ( + status.HTTP_201_CREATED, + "registry.com/group/img1@sha256:6e8985d6c50cf2eb577f17237ef9c05baa9c2f472a730f13784728cec1fdfab1", # noqa: E501 + "", + ), ( status.HTTP_400_BAD_REQUEST, "https://registry.com/group/img1:latest",