Skip to content

Commit 030b37d

Browse files
uriofferupmdolinin
andauthored
bugfix(args): normalize empty credentials (#198)
* bugfix(args): normalize empty credentials * test(args): add test for bugfix * bugfix(args): also check for empty session_token and security_token --------- Co-authored-by: mdolinin <mike.dolinin@offerup.com>
1 parent 618f9df commit 030b37d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

awscurl/awscurl.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,17 @@ def load_aws_config(access_key, secret_key, security_token, credentials_path, pr
433433
return access_key, secret_key, security_token
434434

435435

436+
def normalize_args(args):
437+
if args.access_key == "":
438+
args.access_key = None
439+
if args.secret_key == "":
440+
args.secret_key = None
441+
if args.security_token == "":
442+
args.security_token = None
443+
if args.session_token == "":
444+
args.session_token = None
445+
446+
436447
def inner_main(argv):
437448
"""
438449
Awscurl CLI main entry point
@@ -479,6 +490,7 @@ def inner_main(argv):
479490
parser.add_argument('uri')
480491

481492
args = parser.parse_args(argv)
493+
normalize_args(args)
482494
# pylint: disable=global-statement
483495
global IS_VERBOSE
484496
IS_VERBOSE = args.verbose

tests/integration_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,13 @@ def test_exit_code(self, *args, **kwargs):
125125
inner_main(['--verbose', '--service', 's3', 'https://awscurl-sample-bucket.s3.amazonaws.com']),
126126
1
127127
)
128+
129+
class TestInnerMainMethodEmptyCredentials(TestCase):
130+
maxDiff = None
131+
132+
def test_exit_code(self, *args, **kwargs):
133+
self.assertEqual(
134+
inner_main(['--verbose', '--access_key', '', '--secret_key', '', '--session_token', '', '--service', 's3',
135+
'https://awscurl-sample-bucket.s3.amazonaws.com']),
136+
1
137+
)

0 commit comments

Comments
 (0)