Skip to content

Commit

Permalink
Test for trailing characters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrloch committed Sep 28, 2021
1 parent a224692 commit b5debbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 13 additions & 0 deletions specs/gateway/Rules/UploadRules.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,18 @@ Upload a Rule with a NBTLS certificate of another country. There should be an er
* check that the response had an error
* check that Rule is not in Rulelist

## upload rule with trailing database

tags: negative_test

Upload a Rule with trailing data after the main payload. The API should reject the rule.

* create a valid <Ruletype> Rule
* upload Rule with extra data
* check that the response had an error
* check that the response had the status code "400" or None
* check that Rule is not in Rulelist


___
* delete all created rules
13 changes: 10 additions & 3 deletions step_impl/gateway/Rules/rule_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,26 @@ def add_rule_to_store(rule):
rules.append(rule)


def get_signed_rule():
def get_signed_rule(append_extra_data=False):
rule = data_store.scenario["rule"]

ruleJson = json.dumps(rule, cls=DateTimeEncoder)
if append_extra_data:
ruleJson = ruleJson + ruleJson

upload_cert = x509.load_pem_x509_certificate(
open(path.join(certificateFolder, "upload.pem"), "rb").read())
upload_key = serialization.load_pem_private_key(
open(path.join(certificateFolder, "key_upload.pem"), "rb").read(), None)
return create_cms(ruleJson.encode("utf-8"), upload_cert, upload_key)

@step("upload Rule with extra data")
def upload_rule_with_extra_data():
return upload_rule(append_extra_data=True)

@step("upload Rule")
def upload_rule():
data = get_signed_rule()
def upload_rule(append_extra_data=False):
data = get_signed_rule(append_extra_data)
cert_location = path.join(certificateFolder, "auth.pem")
key_location = path.join(certificateFolder, "key_auth.pem")
headers = {"Content-Type": "application/cms-text",
Expand Down

0 comments on commit b5debbd

Please sign in to comment.