Skip to content

Commit

Permalink
strip whitespace around conn str
Browse files Browse the repository at this point in the history
  • Loading branch information
swathipil committed Feb 4, 2021
1 parent 05236dc commit 638c2a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _parse_conn_str(conn_str, check_case=False):
shared_access_signature_expiry = None # type: Optional[int]

# split connection string into properties
conn_properties = [s.split("=", 1) for s in conn_str.rstrip(";").split(";")]
conn_properties = [s.split("=", 1) for s in conn_str.strip().rstrip(";").split(";")]
if any(len(tup) != 2 for tup in conn_properties):
raise ValueError("Connection string is either blank or malformed.")
conn_settings = dict(conn_properties) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def test_sb_parse_conn_str_sas(self, **kwargs):
assert parse_result.shared_access_signature == 'THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX='
assert parse_result.shared_access_key_name == None

def test_sb_parse_conn_str_whitespace_trailing_semicolon(self, **kwargs):
conn_str = ' Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=; '
parse_result = parse_connection_string(conn_str)
assert parse_result.endpoint == 'sb://resourcename.servicebus.windows.net/'
assert parse_result.fully_qualified_namespace == 'resourcename.servicebus.windows.net'
assert parse_result.shared_access_signature == 'THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX='
assert parse_result.shared_access_key_name == None

def test_sb_parse_conn_str_sas_trailing_semicolon(self, **kwargs):
conn_str = 'Endpoint=sb://resourcename.servicebus.windows.net/;SharedAccessSignature=THISISATESTKEYXXXXXXXXXXXXXXXXXXXXXXXXXXXX=;'
parse_result = parse_connection_string(conn_str)
Expand Down

0 comments on commit 638c2a9

Please sign in to comment.