Skip to content

Commit

Permalink
Client: Fix public client tests (#12474)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: fdba9ac8226bb19d0f50e1b405cd0e641baaf02b
  • Loading branch information
stephencpope authored and Descartes Labs Build committed Mar 2, 2024
1 parent 2e5c5a1 commit d0248a3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 18 additions & 6 deletions descarteslabs/core/client/auth/cli/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@

REFRESH = {
"id": "some id",
"client_id": "ZOBAi4UROl5gKZIpxxlwOEfx8KpqXf2c",
"client_id": "some_client_id",
"name": "API token",
"revoke_url": "https://iam.descarteslabs.com/auth/credentials/revoke/revoke.me",
"client_secret": os.environ.get(
"CLIENT_SECRET", os.environ.get("DESCARTESLABS_CLIENT_SECRET")
),
"client_secret": "some_client_secret",
}
REFRESH_TOKEN = base64.urlsafe_b64encode(
json.dumps(REFRESH, separators=(",", ":")).encode("utf-8")
Expand All @@ -45,10 +43,10 @@
"email_verified": True,
"iss": "https://descarteslabs.auth0.com/",
"sub": "google-oauth2|202801449858648638555",
"aud": "ZOBAi4UROl5gKZIpxxlwOEfx8KpqXf2c",
"aud": "some_client_id",
"exp": 1610770917,
"iat": 1610734917,
"azp": "ZOBAi4UROl5gKZIpxxlwOEfx8KpqXf2c",
"azp": "some_client_id",
}
PAYLOAD_JSON = json.dumps(PAYLOAD, separators=(",", ":"))

Expand Down Expand Up @@ -104,6 +102,13 @@ def setUp(self):

@responses.activate
@patch("builtins.open", Open(PAYLOAD_JSON))
@patch.dict(
os.environ,
{
"DESCARTESLABS_CLIENT_ID": "some_client_id",
"DESCARTESLABS_CLIENT_SECRET": "some_client_secret",
},
)
def test_login(self, *mocks):
payload = base64.urlsafe_b64encode(PAYLOAD_JSON.encode("utf-8")).decode("utf-8")
responses.add(
Expand All @@ -120,6 +125,13 @@ def test_login(self, *mocks):

@responses.activate
@patch("builtins.open", Open(PAYLOAD_JSON))
@patch.dict(
os.environ,
{
"DESCARTESLABS_CLIENT_ID": "some_client_id",
"DESCARTESLABS_CLIENT_SECRET": "some_client_secret",
},
)
def test_payload(self, *mocks):
payload = base64.urlsafe_b64encode(PAYLOAD_JSON.encode("utf-8")).decode("utf-8")
responses.add(
Expand Down
2 changes: 1 addition & 1 deletion descarteslabs/core/client/tests/test_clear_client_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from .. import clear_client_state
from ...auth import Auth
from descarteslabs.auth import Auth
from ..services.raster import Raster


Expand Down

0 comments on commit d0248a3

Please sign in to comment.