Skip to content

Commit 95777f3

Browse files
authored
Merge pull request #372 from ASFHyP3/develop
Release v7.7.2
2 parents 68b671d + e3d8e60 commit 95777f3

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ updates:
1111
interval: weekly
1212
labels:
1313
- bumpless
14+
groups:
15+
pip-deps:
16+
patterns:
17+
- "*"
1418
- package-ecosystem: github-actions
1519
directory: /
1620
schedule:
1721
interval: weekly
1822
labels:
1923
- bumpless
24+
groups:
25+
github-actions-deps:
26+
patterns:
27+
- "*"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
77
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [7.7.2]
10+
11+
### Fixed
12+
* `HyP3.__init__` no longer attempts to update the domain of the `asf-urs` cookie for non-`.asf.alaska.edu` API URLs when the `token` parameter is given. Fixes https://github.com/ASFHyP3/hyp3-sdk/issues/369
13+
914
## [7.7.1]
1015

1116
### Changed

requirements-static.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ruff==0.11.13
2-
mypy==1.16.0
1+
ruff==0.12.5
2+
mypy==1.17.0

src/hyp3_sdk/hyp3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(
7070

7171
hostname = urlsplit(self.url).hostname
7272
assert hostname is not None
73-
if not hostname.endswith('.asf.alaska.edu'):
73+
if not hostname.endswith('.asf.alaska.edu') and 'asf-urs' in self.session.cookies:
7474
self.session.cookies.set('asf-urs', self.session.cookies['asf-urs'], domain=hostname)
7575

7676
def _get_endpoint_url(self, endpoint: str) -> str:

tests/conftest.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
@pytest.fixture(autouse=True)
1515
def get_mock_hyp3():
1616
def mock_get_authenticated_session(username, password, token):
17-
session = requests.Session()
18-
session.cookies.set('asf-urs', 'test-cookie', domain='.asf.alaska.edu')
19-
return session
17+
s = requests.Session()
2018

21-
def default_hyp3(api_url: str = 'https://dummy-api.asf.alaska.edu'):
19+
if token is not None:
20+
s.headers.update({'Authorization': f'Bearer {token}'})
21+
return s
22+
23+
s.cookies.set('asf-urs', 'test-cookie', domain='.asf.alaska.edu')
24+
return s
25+
26+
def mock_hyp3(api_url: str = 'https://dummy-api.asf.alaska.edu', token: str | None = None):
2227
with patch('hyp3_sdk.util.get_authenticated_session', mock_get_authenticated_session):
23-
return HyP3(api_url=api_url)
28+
return HyP3(api_url=api_url, token=token)
2429

25-
return default_hyp3
30+
return mock_hyp3
2631

2732

2833
@pytest.fixture(autouse=True)

tests/test_hyp3.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,11 @@ def test_update_cookie(get_mock_hyp3):
608608
assert api.session.cookies.get('asf-urs', domain='.asf.alaska.edu') == 'test-cookie'
609609
assert api.session.cookies.get('asf-urs', domain='foo.example.com') == 'test-cookie'
610610

611+
api = get_mock_hyp3(api_url='https://foo.example.com:8000/api', token='test-token')
612+
assert api.session.headers['Authorization'] == 'Bearer test-token'
613+
assert api.session.cookies.get('asf-urs', domain='.asf.alaska.edu') is None
614+
assert api.session.cookies.get('asf-urs', domain='foo.example.com') is None
615+
611616
api = get_mock_hyp3(api_url='https://foo.asf.alaska.edu:8000/api')
612617
assert api.session.cookies.get('asf-urs', domain='.asf.alaska.edu') == 'test-cookie'
613618
assert api.session.cookies.get('asf-urs', domain='foo.asf.alaska.edu') is None

0 commit comments

Comments
 (0)