BTHLABS-50: Safari Web Extension: Reloaded

Turns out, getting this thing out into the wild isn't as simple as I thought :D
Co-authored-by: Tomek Wójcik <labs@tomekwojcik.pl>
Co-committed-by: Tomek Wójcik <labs@tomekwojcik.pl>
This commit is contained in:
2025-09-11 15:57:11 +00:00
committed by Tomek Wójcik
parent 67138c7035
commit dcebccf947
15 changed files with 456 additions and 55 deletions

View File

@@ -14,29 +14,16 @@ from hotpocket_backend_testing.services.accounts import (
)
@pytest.fixture
def origin():
return f'safari-web-extension://{uuid.uuid4()}'
@pytest.fixture
def auth_key():
return str(uuid.uuid4())
@pytest.fixture
def meta():
return {
'platform': 'MacIntel',
'version': '1987.10.03',
}
@pytest.fixture
def call(rpc_call_factory, auth_key, meta):
def call(rpc_call_factory, auth_key, safari_extension_meta):
return rpc_call_factory(
'accounts.access_tokens.create',
[auth_key, meta],
[auth_key, safari_extension_meta],
)
@@ -44,9 +31,9 @@ def call(rpc_call_factory, auth_key, meta):
def test_ok(authenticated_client: Client,
auth_key,
call,
origin,
safari_extension_origin,
account,
meta,
safari_extension_meta,
):
# Given
session = authenticated_client.session
@@ -59,7 +46,7 @@ def test_ok(authenticated_client: Client,
data=call,
content_type='application/json',
headers={
'Origin': origin,
'Origin': safari_extension_origin,
},
)
@@ -72,8 +59,8 @@ def test_ok(authenticated_client: Client,
AccessTokensTestingService().assert_created(
key=call_result['result'],
account_uuid=account.pk,
origin=origin,
meta=meta,
origin=safari_extension_origin,
meta=safari_extension_meta,
)
assert 'extension_auth_key' not in authenticated_client.session
@@ -82,7 +69,7 @@ def test_ok(authenticated_client: Client,
@pytest.mark.django_db
def test_auth_key_missing(authenticated_client: Client,
call,
origin,
safari_extension_origin,
):
# When
result = authenticated_client.post(
@@ -90,7 +77,7 @@ def test_auth_key_missing(authenticated_client: Client,
data=call,
content_type='application/json',
headers={
'Origin': origin,
'Origin': safari_extension_origin,
},
)
@@ -105,7 +92,7 @@ def test_auth_key_missing(authenticated_client: Client,
@pytest.mark.django_db
def test_auth_key_mismatch(authenticated_client: Client,
call,
origin,
safari_extension_origin,
):
# Given
session = authenticated_client.session
@@ -118,7 +105,7 @@ def test_auth_key_mismatch(authenticated_client: Client,
data=call,
content_type='application/json',
headers={
'Origin': origin,
'Origin': safari_extension_origin,
},
)