Skip to content

Commit 195a295

Browse files
committed
cli - prevent multiple interaction methods or multiple authentication methods
1 parent 27db1f0 commit 195a295

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

rsocket/cli/command.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def build_composite_metadata(auth_simple: Optional[str],
9797
if route_value is not None:
9898
composite_items.append(route(route_value))
9999

100+
if auth_simple is not None and auth_bearer is not None:
101+
raise click.UsageError('Multiple authentication methods specified.')
102+
100103
if auth_simple is not None:
101104
composite_items.append(authenticate_simple(*auth_simple.split(':')))
102105

@@ -130,7 +133,12 @@ def get_request_type(request: bool,
130133
fnf: bool,
131134
metadata_push: bool,
132135
channel: bool,
133-
interaction_model: str) -> RequestType:
136+
interaction_model: Optional[str]) -> RequestType:
137+
interaction_options = list(filter(lambda _: _ is True, [request, stream, fnf, channel, metadata_push]))
138+
139+
if len(interaction_options) >= 2 or (len(interaction_options) >= 1 and interaction_model is not None):
140+
raise click.UsageError('Multiple interaction methods specified.')
141+
134142
if interaction_model is not None:
135143
return RequestType(interaction_model.upper())
136144
if request:

0 commit comments

Comments
 (0)