Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create_camunda_cloud_channel #514

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyzeebe/channel/camunda_cloud_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def _create_camunda_cloud_credentials(
) -> grpc.ChannelCredentials:
try:
access_token = _get_access_token(
"https://login.cloud.camunda.io/oauth/token",
client_id,
client_secret,
f"{cluster_id}.{region}.zeebe.camunda.io",
url="https://login.cloud.camunda.io/oauth/token",
client_id=client_id,
client_secret=client_secret,
audience="zeebe.camunda.io",
)
return _create_oauth_credentials(access_token)
except InvalidOAuthCredentialsError as oauth_error:
Expand Down
6 changes: 3 additions & 3 deletions pyzeebe/channel/oauth_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def create_camunda_cloud_channel(
client_secret: str,
cluster_id: str,
region: str = "bru-2",
scope: str = "Zeebe",
authorization_server: str = "https://login.cloud.camunda.io/oauth/token",
audience: str = "zeebe.camunda.io",
scope: str | None = None,
audience: str | None = "zeebe.camunda.io",
channel_credentials: grpc.ChannelCredentials | None = None,
channel_options: ChannelArgumentType | None = None,
leeway: int = 60,
Expand All @@ -96,10 +96,10 @@ def create_camunda_cloud_channel(
client_secret (str): The client secret.
cluster_id (str): The ID of the cluster to connect to.
region (Optional[str]): The region of the cluster. Defaults to "bru-2".
scope (Optional[str]): The scope of the access request. Defaults to "Zeebe".
authorization_server (Optional[str]): The authorization server issuing access tokens
to the client after successfully authenticating the client.
Defaults to "https://login.cloud.camunda.io/oauth/token".
scope (Optional[str]): The scope of the access request. Can be set to CAMUNDA_CLUSTER_ID. Defaults to None.
audience (Optional[str]): The audience for authentication. Defaults to "zeebe.camunda.io".

channel_credentials (grpc.ChannelCredentials): The gRPC channel credentials.
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/channel/camunda_cloud_channel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def test_gets_access_token_using_correct_parameters(
cluster_id: str,
region: str,
):
expected_request_body = (
f"client_id={client_id}&client_secret={client_secret}&audience={cluster_id}.{region}.zeebe.camunda.io"
)
expected_request_body = f"client_id={client_id}&client_secret={client_secret}&audience=zeebe.camunda.io"

create_camunda_cloud_channel(client_id, client_secret, cluster_id, region)

Expand Down
30 changes: 27 additions & 3 deletions tests/unit/channel/oauth_channel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,21 @@ def test_create_oauth2_client_credentials_channel(
client_id = "client_id"
client_secret = "client_secret"
authorization_server = "https://authorization.server"
channel = create_oauth2_client_credentials_channel(grpc_address, client_id, client_secret, authorization_server)
scope = "scope"
audience = "audience"

channel = create_oauth2_client_credentials_channel(
grpc_address=grpc_address,
client_id=client_id,
client_secret=client_secret,
authorization_server=authorization_server,
scope=scope,
audience=audience,
channel_credentials=None,
channel_options=None,
leeway=60,
expire_in=None,
)

assert isinstance(channel, grpc.aio.Channel)

Expand All @@ -35,12 +49,22 @@ def test_create_camunda_cloud_channel(
client_secret = "client_secret"
cluster_id = "cluster_id"
region = "bru-2"
scope = "Zeebe"
authorization_server = "https://login.cloud.camunda.io/oauth/token"
scope = None
audience = "zeebe.camunda.io"

channel = create_camunda_cloud_channel(
client_id, client_secret, cluster_id, region, scope, authorization_server, audience
client_id=client_id,
client_secret=client_secret,
cluster_id=cluster_id,
region=region,
authorization_server=authorization_server,
scope=scope,
audience=audience,
channel_credentials=None,
channel_options=None,
leeway=60,
expire_in=None,
)

assert isinstance(channel, grpc.aio.Channel)