Skip to content
Draft
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
2 changes: 0 additions & 2 deletions beanhub_cli/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def make_client(base_url: str) -> Client:
def make_auth_client(base_url: str, token: str) -> AuthenticatedClient:
return AuthenticatedClient(
base_url=base_url,
prefix="",
auth_header_name="access-token",
token=token,
headers=get_client_headers(),
)
6 changes: 3 additions & 3 deletions tests/connect/test_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_dump(
public_key=public_key,
output_accounts=output_accounts,
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/dumps/{dump_id}",
Expand All @@ -70,7 +70,7 @@ def test_dump(
id=str(dump_id),
state="PROCESSING",
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/dumps/{dump_id}",
Expand All @@ -87,7 +87,7 @@ def test_dump(
else {}
),
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=mock_download_url,
Expand Down
38 changes: 19 additions & 19 deletions tests/connect/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _mock_list_repo(
)
]
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)


Expand All @@ -76,7 +76,7 @@ def test_sync(
json=dict(
id=str(batch_id),
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches/{batch_id}",
Expand All @@ -103,7 +103,7 @@ def test_sync(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches/{batch_id}",
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_sync(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
cli_runner.mix_stderr = False
result = cli_runner.invoke(cli, ["connect", "sync"])
Expand All @@ -153,7 +153,7 @@ def test_sync_shows_sync_complete_items(
method="POST",
status_code=201,
json=dict(id=str(batch_id)),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches/{batch_id}",
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_sync_shows_sync_complete_items(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
cli_runner.mix_stderr = False
result = cli_runner.invoke(cli, ["connect", "sync"])
Expand Down Expand Up @@ -210,7 +210,7 @@ def test_sync_sends_cli_version_header(
status_code=201,
json=dict(id=str(batch_id)),
match_headers={
"access-token": mock_config.access_token.token,
"Authorization": f"Bearer {mock_config.access_token.token}",
CLIENT_VERSION_HEADER: cli_version,
},
)
Expand All @@ -234,7 +234,7 @@ def test_sync_sends_cli_version_header(
],
),
match_headers={
"access-token": mock_config.access_token.token,
"Authorization": f"Bearer {mock_config.access_token.token}",
CLIENT_VERSION_HEADER: cli_version,
},
)
Expand All @@ -256,7 +256,7 @@ def test_sync_with_skipped_state(
json=dict(
id=str(batch_id),
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches/{batch_id}",
Expand All @@ -283,7 +283,7 @@ def test_sync_with_skipped_state(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches/{batch_id}",
Expand Down Expand Up @@ -313,7 +313,7 @@ def test_sync_with_skipped_state(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
cli_runner.mix_stderr = False
result = cli_runner.invoke(cli, ["connect", "sync"])
Expand All @@ -335,7 +335,7 @@ def test_sync_with_import_and_commit(
json=dict(
id=str(batch_id),
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
match_json={"import_and_commit": True},
)
httpx_mock.add_response(
Expand All @@ -357,7 +357,7 @@ def test_sync_with_import_and_commit(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches/{batch_id}",
Expand All @@ -378,7 +378,7 @@ def test_sync_with_import_and_commit(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches/{batch_id}",
Expand All @@ -400,7 +400,7 @@ def test_sync_with_import_and_commit(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
cli_runner.mix_stderr = False
result = cli_runner.invoke(cli, ["connect", "sync", "-i"])
Expand All @@ -423,7 +423,7 @@ def test_sync_with_import_and_commit_failed(
json=dict(
id=str(batch_id),
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
match_json={"import_and_commit": True},
)
httpx_mock.add_response(
Expand Down Expand Up @@ -463,7 +463,7 @@ def test_sync_with_import_and_commit_failed(
),
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
cli_runner.mix_stderr = False
result = cli_runner.invoke(cli, ["connect", "sync", "-i"])
Expand Down Expand Up @@ -496,7 +496,7 @@ def test_sync_with_import_and_commit_rejected_by_api(
method="GET",
status_code=200,
json=dict(repositories=[]),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/connect/sync_batches",
Expand All @@ -509,7 +509,7 @@ def test_sync_with_import_and_commit_rejected_by_api(
"exporting data."
),
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
match_json={"import_and_commit": True},
)
cli_runner.mix_stderr = False
Expand Down
14 changes: 7 additions & 7 deletions tests/inbox/test_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_dump(
],
cursor="MOCK_CURSOR0",
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/inbox/emails?cursor=MOCK_CURSOR0",
Expand All @@ -164,7 +164,7 @@ def test_dump(
],
cursor="MOCK_CURSOR1",
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/inbox/emails?cursor=MOCK_CURSOR1",
Expand All @@ -173,7 +173,7 @@ def test_dump(
json=dict(
emails=[],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/inbox/dumps",
Expand All @@ -191,7 +191,7 @@ def test_dump(
emails[4].id,
],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/inbox/dumps/{dump_id}",
Expand All @@ -201,7 +201,7 @@ def test_dump(
id=str(dump_id),
state="PROCESSING",
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=f"https://api.beanhub.io/v1/repos/{mock_config.repo.default}/inbox/dumps/{dump_id}",
Expand All @@ -213,7 +213,7 @@ def test_dump(
download_url=mock_download_url,
encryption_key=encryption_key,
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)
httpx_mock.add_response(
url=mock_download_url,
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_dump_without_emails(
json=dict(
emails=[],
),
match_headers={"access-token": mock_config.access_token.token},
match_headers={"Authorization": f"Bearer {mock_config.access_token.token}"},
)

cli_runner.mix_stderr = False
Expand Down
4 changes: 2 additions & 2 deletions tests/test_git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_ensure_auth_config_uses_git_remote_when_active(
)
]
),
match_headers={"access-token": "test-token"},
match_headers={"Authorization": "Bearer test-token"},
)

with switch_cwd(repo_root):
Expand Down Expand Up @@ -187,7 +187,7 @@ def test_ensure_auth_config_falls_back_to_single_active_repo(
)
]
),
match_headers={"access-token": "test-token"},
match_headers={"Authorization": "Bearer test-token"},
)

with switch_cwd(repo_root):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_make_auth_client_includes_version_headers():
client = make_auth_client(base_url="https://api.beanhub.io", token="test-token")
with client:
httpx_client = client.get_httpx_client()
assert httpx_client.headers["access-token"] == "test-token"
assert httpx_client.headers["Authorization"] == "Bearer test-token"
assert httpx_client.headers["User-Agent"] == get_client_headers()["User-Agent"]
assert (
httpx_client.headers[CLIENT_VERSION_HEADER]
Expand Down