Skip to content

Fix calling ReadOne indefinitely for invalid Certificate specs #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions pkg/resource/certificate/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
if err = validatePublicValidationOptions(desired); err != nil {
ackcondition.SetTerminal(
desired,
corev1.ConditionTrue,
&domainValidationOptionsExceededMsg,
nil,
)
return desired, nil
return nil, ackerr.NewTerminalError(err)
}
18 changes: 18 additions & 0 deletions test/e2e/resources/certificate_public_invalid.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: acm.services.k8s.aws/v1alpha1
kind: Certificate
metadata:
name: $CERTIFICATE_NAME
spec:
domainName: $DOMAIN_NAME
certificateAuthorityARN: invalid
domainValidationOptions:
- domainName: $DOMAIN_NAME
- domainName: $DOMAIN_NAME
- domainName: $DOMAIN_NAME
- domainName: $DOMAIN_NAME
- domainName: $DOMAIN_NAME
- domainName: $DOMAIN_NAME
- domainName: $DOMAIN_NAME
tags:
- key: environment
value: dev
25 changes: 21 additions & 4 deletions test/e2e/tests/test_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import pytest

from acktest.k8s import resource as k8s
from acktest.k8s import resource as k8s, condition
from acktest.resources import random_suffix_name
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_resource
from e2e.replacement_values import REPLACEMENT_VALUES
Expand All @@ -38,7 +38,7 @@
MAX_WAIT_FOR_SYNCED_MINUTES = 1

@pytest.fixture
def certificate_public():
def certificate_public(request):
certificate_name = random_suffix_name("certificate", 20)
domain_name = "example.com"

Expand All @@ -47,7 +47,7 @@ def certificate_public():
replacements['DOMAIN_NAME'] = domain_name

resource_data = load_resource(
"certificate_public",
request.param,
additional_replacements=replacements,
)

Expand Down Expand Up @@ -78,6 +78,7 @@ def certificate_public():
@service_marker
@pytest.mark.canary
class TestCertificate:
@pytest.mark.parametrize('certificate_public', ['certificate_public'], indirect=True)
def test_crud_public(
self,
certificate_public,
Expand Down Expand Up @@ -172,4 +173,20 @@ def test_crud_public(

k8s.delete_custom_resource(ref)
time.sleep(DELETE_WAIT_AFTER_SECONDS)
certificate.wait_until_deleted(certificate_arn)
certificate.wait_until_deleted(certificate_arn)

@pytest.mark.parametrize('certificate_public', ['certificate_public_invalid'], indirect=True)
def test_invalid(
self,
certificate_public,
):
(ref, cr) = certificate_public
assert 'status' in cr

cond = k8s.get_resource_condition(ref, condition.CONDITION_TYPE_TERMINAL)
assert cond is not None
assert cond == {
'message': 'Too many domain validation errors',
'status': 'True',
'type': condition.CONDITION_TYPE_TERMINAL,
}