Skip to content

Commit b556979

Browse files
authored
Add CA immutable fields test (#59)
Description of changes: 1. Adding test case to check that the CA resource recovers after immutable fields are updated By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 83bfb6b commit b556979

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

test/e2e/tests/test_ca.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_ca_crud(self, acmpca_client, simple_certificate_authority):
164164
expected=tags_dict,
165165
actual=observed_tags,
166166
)
167-
167+
168168
# Update RevocationConfiguration
169169
updates = {
170170
"spec": {
@@ -181,4 +181,54 @@ def test_ca_crud(self, acmpca_client, simple_certificate_authority):
181181

182182
# Check RevocationConfiguration
183183
ca = acmpca_validator.assert_certificate_authority(ca_resource_arn, "PENDING_CERTIFICATE")
184-
assert ca["RevocationConfiguration"]["OcspConfiguration"]["Enabled"] == True
184+
assert ca["RevocationConfiguration"]["OcspConfiguration"]["Enabled"] == True
185+
186+
def test_immutable_fields(self, acmpca_client, simple_certificate_authority):
187+
188+
(ca_cr, ca_ref, ca_resource_arn) = simple_certificate_authority
189+
190+
updates = {
191+
"spec": {
192+
'certificateAuthorityConfiguration': {
193+
'subject': {
194+
'commonName': 'string',
195+
'country': 'US',
196+
'locality': 'string',
197+
'organization': 'string',
198+
'state': 'string'
199+
}
200+
},
201+
'type' : 'SUBORDINATE'
202+
}
203+
}
204+
205+
ca_cr = k8s.patch_custom_resource(ca_ref, updates)
206+
logging.info(ca_cr)
207+
time.sleep(UPDATE_WAIT_AFTER_SECONDS)
208+
209+
ca_cr = k8s.patch_custom_resource(ca_ref, {})
210+
logging.info(ca_cr)
211+
time.sleep(UPDATE_WAIT_AFTER_SECONDS)
212+
213+
terminal_condition = {'message': 'Immutable Spec fields have been modified: CertificateAuthorityConfiguration,Type', 'status': 'True', 'type': 'ACK.Terminal'}
214+
assert 'status' in ca_cr
215+
assert 'conditions' in ca_cr['status']
216+
assert terminal_condition in ca_cr['status']['conditions']
217+
218+
ca_cr = k8s.patch_custom_resource(ca_ref, {})
219+
logging.info(ca_cr)
220+
time.sleep(UPDATE_WAIT_AFTER_SECONDS)
221+
222+
synced_condition = {'status': 'True', 'type': 'ACK.ResourceSynced'}
223+
assert 'status' in ca_cr
224+
assert 'conditions' in ca_cr['status']
225+
assert synced_condition in ca_cr['status']['conditions']
226+
227+
acmpca_validator = ACMPCAValidator(acmpca_client)
228+
ca = acmpca_validator.assert_certificate_authority(ca_resource_arn, "PENDING_CERTIFICATE")
229+
assert ca["Type"] == "ROOT"
230+
assert re.search("^www[.]example.{10}[.]com$", ca["CertificateAuthorityConfiguration"]["Subject"]["CommonName"])
231+
assert ca["CertificateAuthorityConfiguration"]["Subject"]["Country"] == "US"
232+
assert ca["CertificateAuthorityConfiguration"]["Subject"]["Locality"] == "Arlington"
233+
assert re.search("^Example Organization .{10}$", ca["CertificateAuthorityConfiguration"]["Subject"]["Organization"])
234+
assert ca["CertificateAuthorityConfiguration"]["Subject"]["State"] == "Virginia"

0 commit comments

Comments
 (0)