Skip to content

Commit 5d6d3ab

Browse files
authored
test: add security unit tests for CTv1 execution (#1114)
* test: add security unit tests for CTv1 execution
1 parent 043c02f commit 5d6d3ab

File tree

14 files changed

+145
-15
lines changed

14 files changed

+145
-15
lines changed

src/rpdk/core/boto_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def inject_confused_deputy_headers(params, **kwargs):
5454

5555
sts_client.meta.events.register("before-call", inject_confused_deputy_headers)
5656
if role_arn:
57-
session_name = f"CloudFormationContractTest-{datetime.now():%Y%m%d%H%M%S}"
57+
session_name = (
58+
f"CloudFormationContractTest-{datetime.now():%Y%m%d%H%M%S}" # noqa: E231
59+
)
5860
try:
5961
response = sts_client.assume_role(
6062
RoleArn=role_arn,

src/rpdk/core/contract/resource_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint: disable=import-outside-toplevel
22
# pylint: disable=R0904
3+
# pylint: disable=import-error
34
import copy
45
import json
56
import logging
@@ -295,7 +296,7 @@ def assert_write_only_property_does_not_exist(self, resource_model):
295296
assertion_error_message = (
296297
"The model MUST NOT return properties defined as writeOnlyProperties"
297298
" in the resource schema \n Write only properties in resource model :"
298-
f" {error_list} \n Output Resource Model : {resource_model} \n"
299+
f" {error_list} \n Output Resource Model : {resource_model} \n" # noqa: E203
299300
)
300301
assert not any(error_list), assertion_error_message
301302

@@ -461,7 +462,7 @@ def compare_model(self, inputs, outputs, path=()):
461462
"All properties specified in the request MUST be present in the model"
462463
" returned, and they MUST match exactly, with the exception of properties"
463464
" defined as writeOnlyProperties in the resource schema \n Request Model :"
464-
f" {inputs} \n Returned Model : {outputs} \n"
465+
f" {inputs} \n Returned Model : {outputs} \n" # noqa: E203
465466
)
466467
try:
467468
if isinstance(inputs, dict):

src/rpdk/core/contract/resource_generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=import-error
12
import logging
23
import re
34
from collections.abc import Sequence

src/rpdk/core/contract/suite/resource/handler_commons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def error_test_model_in_list(resource_client, current_resource_model, message):
120120
f"{message} \n Resource Model primary identifier"
121121
f" {resource_model_primary_identifier[0]} does not match with Current"
122122
" Resource Model primary identifier"
123-
f" {current_model_primary_identifier[0]} \n Resource Model :"
124-
f" {resource_model} \n Currrent Model : {current_resource_model} "
123+
f" {current_model_primary_identifier[0]} \n Resource Model :" # noqa: E203,E231
124+
f" {resource_model} \n Currrent Model : {current_resource_model} " # noqa: E203
125125
)
126126
return assertion_error_message
127127
return assertion_error_message

src/rpdk/core/jsonutils/flattener.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def _flatten_ref_type(self, ref_path):
7878
ref_parts = fragment_decode(ref_path)
7979
except ValueError as e:
8080
# pylint: disable=W0707
81-
raise FlatteningError(f"Invalid ref at path '{ref_path}': { str(e)}")
81+
raise FlatteningError(
82+
f"Invalid ref at path '{ref_path}': { str(e)}" # noqa: E201
83+
)
8284

8385
ref_schema, ref_parts, _ref_parent = self._find_subschema_by_ref(ref_parts)
8486
return self._walk(ref_schema, ref_parts)

src/rpdk/core/jsonutils/inliner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=import-error
12
import logging
23
from collections.abc import Iterable, Mapping
34

src/rpdk/core/jsonutils/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=import-error
12
import hashlib
23
import json
34
import logging

src/rpdk/core/type_schema_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=import-error
12
import collections.abc
23
import json
34
import logging

src/rpdk/core/upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def upload(self, file_prefix, fileobj):
173173

174174
LOG.debug("Upload complete")
175175

176-
return f"s3://{self.bucket_name}/{key}"
176+
return f"s3://{self.bucket_name}/{key}" # noqa: E231
177177

178178
def get_log_delivery_role_arn(self):
179179
return self.log_delivery_role_arn

tests/jsonutils/test_inliner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_refinliner_remote_refs_on_filesystem_are_inlined(tmpdir):
113113
filename = tmpdir.mkdir("bar").join("remote.json")
114114
with filename.open("w", encoding="utf-8") as f:
115115
json.dump(remote, f)
116-
base_uri = f"file://{tmpdir.strpath}/foo/"
116+
base_uri = f"file://{tmpdir.strpath}/foo/" # noqa: E231
117117
ref = "../bar/remote.json#/nested/bar"
118118
inliner = make_inliner(
119119
{"type": "object", "properties": {"foo": {"$ref": ref}}}, base_uri=base_uri

0 commit comments

Comments
 (0)