Skip to content

Commit

Permalink
Client: Fix auth and compute tests (#12426)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: c95fa429afe61e93769296ce8bb0110dbffacbe1
  • Loading branch information
stephencpope authored and Descartes Labs Build committed Jan 30, 2024
1 parent ddea28a commit f52fc46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/public-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
DESCARTESLABS_ENV: testing
run: |
mkdir tempdir
pytest -rfExXP --assert=plain --ignore-glob="*/smoke_tests" --ignore-glob="*/e2e" --ignore="descarteslabs/core/third_party" --ignore="descarteslabs/core/client/services/metadata" descarteslabs
pytest -rfExXP --assert=plain --ignore-glob="*/smoke_tests" --ignore-glob="*/e2e" --ignore="descarteslabs/core/third_party" descarteslabs
rm -r tempdir
slack:
Expand Down
2 changes: 1 addition & 1 deletion descarteslabs/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def __init__(
and self.refresh_token == token_info.get(self.KEY_REFRESH_TOKEN)
):
self._token = token_info.get(self.KEY_JWT_TOKEN)
elif self.refresh_token:
elif self.refresh_token and self.token_info_path is not None:
# Make the saved JWT token file unique to the refresh token
token = self.refresh_token
token_sha1 = sha1(token.encode("utf-8")).hexdigest()
Expand Down
15 changes: 14 additions & 1 deletion descarteslabs/core/compute/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import json
import json as jsonlib
import os
import time
import urllib.parse
import uuid
Expand All @@ -24,6 +25,18 @@ class BaseTestCase(TestCase):
compute_url = "https://platform.dev.aws.descarteslabs.com/compute/v1"

def setUp(self):
# make sure all of these are gone, so our Auth is only a JWT
for envvar in (
"CLIENT_ID",
"DESCARTESLABS_CLIENT_ID",
"CLIENT_SECRET",
"DESCARTESLABS_CLIENT_SECRET",
"DESCARTESLABS_REFRESH_TOKEN",
"DESCARTESLABS_TOKEN",
):
if envvar in os.environ:
del os.environ[envvar]

responses.mock.assert_all_requests_are_fired = True
self.now = datetime.utcnow()

Expand All @@ -47,7 +60,7 @@ def tearDown(self):
responses.mock.assert_all_requests_are_fired = False

def mock_credentials(self):
responses.add(responses.POST, f"{self.compute_url}/credentials")
responses.add(responses.GET, f"{self.compute_url}/credentials")

def mock_response(self, method, uri, json=None, status=200, **kwargs):
if json is not None:
Expand Down

0 comments on commit f52fc46

Please sign in to comment.