Skip to content

Commit 430759a

Browse files
committed
increasing test coverage
1 parent 759596d commit 430759a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/scrapy_settings_log/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def spider_closed(self, spider):
5454
if spider.settings.getbool("MASKED_SENSITIVE_SETTINGS_ENABLED", True):
5555
default_regexes = [
5656
".*(?i)(api[\W_]*key).*", # apikey and possible variations e.g: shub_apikey or SC_APIKEY
57-
".*(?i)(AWS[\W_]*(SECRET[\W_]*)?ACCESS[\W_]*KEY).*", # AWS_SECRET_ACCESS_KEY and possible variations
57+
".*(?i)(AWS[\W_]*(SECRET[\W_]*)?(ACCESS)?[\W_]*(KEY|ACCESS[\W_]*KEY))", # AWS_SECRET_ACCESS_KEY and possible variations
5858
".*(?i)([\W_]*password[\W_]*).*" # password word
5959
]
6060
regex_list = spider.settings.getlist("MASKED_SENSITIVE_SETTINGS_REGEX_LIST", default_regexes)

tests/test_code.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ def test_log_all_should_not_return_aws_secret_key_value_by_default(caplog):
145145
"AWS_SECRET_ACCESS_KEY": 'secret_value1',
146146
"aws_secret_access_key": 'secret_value2',
147147
"aws_access_key": 'secret_value2',
148+
"AWS_SECRET_KEY": 'secret_value2',
149+
"aws_secret_key": 'secret_value2',
148150
}
149151

150152
spider = MockSpider(settings)
@@ -155,6 +157,8 @@ def test_log_all_should_not_return_aws_secret_key_value_by_default(caplog):
155157
assert '"AWS_SECRET_ACCESS_KEY": "**********"' in caplog.text
156158
assert '"aws_secret_access_key": "**********"' in caplog.text
157159
assert '"aws_access_key": "**********"' in caplog.text
160+
assert '"AWS_SECRET_KEY": "**********"' in caplog.text
161+
assert '"aws_secret_key": "**********"' in caplog.text
158162
assert 'secret_value' not in caplog.text
159163

160164

0 commit comments

Comments
 (0)