diff --git a/specs/gateway/CreateCertificate.md b/specs/gateway/CreateCertificate.md index 0be8df3..f49d23e 100644 --- a/specs/gateway/CreateCertificate.md +++ b/specs/gateway/CreateCertificate.md @@ -6,7 +6,7 @@ all tests for uploading DSCs ## upload DSC -tags: +tags: Upload a DSC for a country @@ -27,7 +27,6 @@ Upload a DSC of a country with an unauthorized client certificate. The response * create custom authentication certificate * upload DSC with custom client certificate * check that the response had an error -* check that the response had the status code "401" ## upload DSC with mismatched certificate diff --git a/specs/gateway/DeleteCertificates.md b/specs/gateway/DeleteCertificates.md index d94e2e9..3e4767b 100644 --- a/specs/gateway/DeleteCertificates.md +++ b/specs/gateway/DeleteCertificates.md @@ -45,7 +45,6 @@ Delete a DSC of a country with an unauthorized client certificate. * create custom authentication certificate * delete random DSC with custom client certificate * check that the response had an error -* check that the response had the status code "401" ## delete a DSC with client certificate of another country diff --git a/step_impl/gateway/dsc_creation.py b/step_impl/gateway/dsc_creation.py index 45672d2..0e33fe8 100644 --- a/step_impl/gateway/dsc_creation.py +++ b/step_impl/gateway/dsc_creation.py @@ -25,6 +25,7 @@ from getgauge.python import data_store, step from step_impl.gateway.dsc_deletion import delete_dsc from step_impl.util import authCerts, baseurl, certificateFolder +from requests.exceptions import SSLError from step_impl.util.certificates import (create_certificate, create_cms_with_certificate, create_dsc) @@ -38,6 +39,10 @@ def add_dsc_to_store(dsc: str): data_store.spec["created_dscs"] = dscs dscs.append(dsc) +class FailedResponse: + ok = False + status_code = None + text = None @step("create a valid DSC") def create_valid_dsc(): @@ -133,8 +138,12 @@ def upload_dsc_with_custom_client_certificate(): key_location = path.join(certificateFolder, "custom_key_auth.pem") headers = {"Content-Type": "application/cms", "Content-Transfer-Encoding": "base64"} - response = requests.post(url=baseurl + "/signerCertificate", + try: + response = requests.post(url=baseurl + "/signerCertificate", data=signedDsc, headers=headers, cert=(cert_location, key_location)) + except SSLError: + response = FailedResponse() + data_store.scenario["response"] = response diff --git a/step_impl/gateway/dsc_deletion.py b/step_impl/gateway/dsc_deletion.py index ed542a8..0ea5e3c 100644 --- a/step_impl/gateway/dsc_deletion.py +++ b/step_impl/gateway/dsc_deletion.py @@ -21,7 +21,7 @@ from getgauge.python import data_store, step from requests import Response from step_impl.util import authCerts, baseurl, certificateFolder - +from requests.exceptions import SSLError def delete_dsc(signedDsc: str, authCerts: (str, str)): headers = {"Content-Type": "application/cms", @@ -31,6 +31,11 @@ def delete_dsc(signedDsc: str, authCerts: (str, str)): return response +class FailedResponse: + ok = False + status_code = None + text = None + @step("delete DSC created") def delete_dsc_created(): signedDsc = data_store.scenario["signed_dsc"] @@ -71,5 +76,9 @@ def revoke_random_dsc_of_trustlist_with_unauthorized_authentication_certificate( format=serialization.PrivateFormat.TraditionalOpenSSL, encryption_algorithm=serialization.NoEncryption(), )) - response = delete_dsc(dscToDelete, (cert_location, key_location)) + try: + response = delete_dsc(dscToDelete, (cert_location, key_location)) + except SSLError: + response = FailedResponse() + data_store.scenario["response"] = response