2525from cryptography .hazmat .primitives .asymmetric .ec import EllipticCurvePrivateKey
2626from cryptography .x509 .oid import NameOID
2727
28- from test_env import CLOUD_ZONE , CLOUD_APIKEY , CLOUD_URL , RANDOM_DOMAIN
28+ from test_env import CLOUD_ZONE , CLOUD_APIKEY , CLOUD_URL , RANDOM_DOMAIN , VAAS_ZONE_ONLY_EC
2929from test_pm import get_policy_obj , get_defaults_obj
3030from test_utils import random_word , enroll , renew , renew_by_thumbprint , renew_without_key_reuse , simple_enroll , \
3131 get_vaas_zone
3232from vcert import CloudConnection , KeyType , CertificateRequest , CustomField , logger , CSR_ORIGIN_SERVICE
3333from vcert .policy import KeyPair , DefaultKeyPair , PolicySpecification
34+ from vcert .common import RetireRequest
3435
3536log = logger .get_child ("test-vaas" )
3637
3738
3839class TestVaaSMethods (unittest .TestCase ):
3940 def __init__ (self , * args , ** kwargs ):
4041 self .cloud_zone = CLOUD_ZONE
42+ self .vaas_zone_ec = VAAS_ZONE_ONLY_EC
4143 self .cloud_conn = CloudConnection (token = CLOUD_APIKEY , url = CLOUD_URL )
4244 super (TestVaaSMethods , self ).__init__ (* args , ** kwargs )
4345
@@ -170,29 +172,14 @@ def test_cloud_enroll_service_generated_csr(self):
170172 log .info (f"PKCS12 created successfully for certificate with CN: { cn } " )
171173
172174 def test_enroll_ec_key_certificate (self ):
173- policy = get_policy_obj ()
174- kp = KeyPair (
175- key_types = ['EC' ],
176- elliptic_curves = ['P521' , 'P384' ],
177- reuse_allowed = False )
178- policy .key_pair = kp
175+ zone = self .vaas_zone_ec
179176
180- defaults = get_defaults_obj ()
181- defaults .key_pair = DefaultKeyPair (
182- key_type = 'EC' ,
183- elliptic_curve = 'P521' )
184-
185- policy_spec = PolicySpecification ()
186- policy_spec .policy = policy
187- policy_spec .defaults = defaults
188-
189- zone = get_vaas_zone ()
190-
191- self .cloud_conn .set_policy (zone , policy_spec )
192177 password = 'FooBarPass123'
178+ random_name = f"{ random_word (10 )} .vfidev.com"
193179
194180 request = CertificateRequest (
195- common_name = f"{ random_word (10 )} .venafi.example" ,
181+ common_name = random_name ,
182+ san_dns = [random_name ],
196183 key_type = KeyType (
197184 key_type = "ec" ,
198185 option = "P384"
@@ -214,3 +201,15 @@ def test_enroll_ec_key_certificate(self):
214201 if p_key :
215202 self .assertIsInstance (p_key , EllipticCurvePrivateKey , "returned private key is not of type Elliptic Curve" )
216203 self .assertEqual (p_key .curve .key_size , 384 , f"Private Key expected curve: 384. Got: { p_key .curve .key_size } " )
204+
205+ def test_cloud_retire_by_thumbprint (self ):
206+ try :
207+ req , cert = simple_enroll (self .cloud_conn , self .cloud_zone )
208+ cert = x509 .load_pem_x509_certificate (cert .cert .encode (), default_backend ())
209+ fingerprint = binascii .hexlify (cert .fingerprint (hashes .SHA1 ())).decode ()
210+ time .sleep (1 )
211+ ret_request = RetireRequest (thumbprint = fingerprint )
212+ ret_data = self .cloud_conn .retire_cert (ret_request )
213+ assert ret_data is True
214+ except Exception as e :
215+ log .error (msg = f"Error retiring certificate by thumbprint: { e .message } " )
0 commit comments