Skip to content

Commit

Permalink
Accept reverse proxy rejection
Browse files Browse the repository at this point in the history
as sign for unauthorized request
  • Loading branch information
chrloch committed Sep 14, 2021
1 parent af5d85d commit da7d5c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
3 changes: 1 addition & 2 deletions specs/gateway/CreateCertificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all tests for uploading DSCs

## upload DSC

tags:
tags:

Upload a DSC for a country

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion specs/gateway/DeleteCertificates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion step_impl/gateway/dsc_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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():
Expand Down Expand Up @@ -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


Expand Down
13 changes: 11 additions & 2 deletions step_impl/gateway/dsc_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"]
Expand Down Expand Up @@ -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

0 comments on commit da7d5c8

Please sign in to comment.