Skip to content

Commit 3d6afe6

Browse files
authored
feat: Update access token to api token (#61)
* chore: update package * chore: update package * fix: testing async ... loop issues * test: update datatype by lowerbound and upperbound tests * fix: testing
1 parent a034680 commit 3d6afe6

File tree

13 files changed

+424
-433
lines changed

13 files changed

+424
-433
lines changed

eventsourcingdb/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class Client(AbstractBaseClient):
2727
def __init__(
2828
self,
2929
base_url: str,
30-
access_token: str,
30+
api_token: str,
3131
options: ClientOptions = ClientOptions()
3232
):
3333
configuration = ClientConfiguration(
3434
base_url=base_url,
3535
timeout_seconds=options.timeout_seconds,
36-
access_token=access_token,
36+
api_token=api_token,
3737
protocol_version=options.protocol_version,
3838
max_tries=options.max_tries
3939
)

eventsourcingdb/client_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
class ClientConfiguration:
66
base_url: str
77
timeout_seconds: int
8-
access_token: str
8+
api_token: str
99
protocol_version: str
1010
max_tries: int

eventsourcingdb/handlers/ping.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ async def ping(client: AbstractBaseClient) -> None:
2929
except json.JSONDecodeError as exc:
3030
raise ServerError(f"Received unexpected response: {response_body}") from exc
3131

32-
# Check if it's a JSON with status field
33-
if isinstance(response_json, dict) and response_json.get("status") == STATUS_OK:
34-
return
35-
3632
# Check if it's a CloudEvent format (has specversion, type fields)
3733
if (
3834
isinstance(response_json, dict)

eventsourcingdb/handlers/read_events/read_events_options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
class ReadEventsOptions:
1313
recursive: bool
1414
order: Order | None = None
15-
lower_bound: LowerBound | None = None # Changed from str to LowerBound
16-
upper_bound: UpperBound | None = None # Changed from str to UpperBound
15+
lower_bound: LowerBound | None = None
16+
upper_bound: UpperBound | None = None
1717
from_latest_event: ReadFromLatestEvent | None = None
1818

1919
def validate(self) -> None:

eventsourcingdb/http_client/http_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ async def __validate_response(
115115
def __get_post_request_headers(self) -> dict[str, str]:
116116
headers = {
117117
'X-EventSourcingDB-Protocol-Version': self.__client_configuration.protocol_version,
118-
'Authorization': f'Bearer {self.__client_configuration.access_token}',
118+
'Authorization': f'Bearer {self.__client_configuration.api_token}',
119119
'Content-Type': 'application/json'
120120
}
121121

@@ -155,7 +155,7 @@ def __get_get_request_headers(self, with_authorization: bool) -> dict[str, str]:
155155
}
156156

157157
if with_authorization:
158-
headers['Authorization'] = f'Bearer {self.__client_configuration.access_token}'
158+
headers['Authorization'] = f'Bearer {self.__client_configuration.api_token}'
159159

160160
return headers
161161

poetry.lock

Lines changed: 394 additions & 389 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ packages = [{include = "eventsourcingdb"}]
1515

1616
[tool.poetry.dependencies]
1717
python = "^3.13"
18-
aiohttp = "3.11.13"
18+
aiohttp = "3.11.16"
1919

2020
[tool.poetry.group.dev.dependencies]
2121
pytest = "8.3.5"

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[pytest]
22
timeout = 20
3+
asyncio_default_fixture_loop_scope = function

tests/shared/containerized_testing_database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ async def create(
2626
cls,
2727
image: Image,
2828
command: [str],
29-
access_token: str,
29+
api_token: str,
3030
options: ClientOptions = ClientOptions(),
3131
) -> 'ContainerizedTestingDatabase':
3232
command.extend(['--http-enabled', '--https-enabled=false'])
3333
container = image.run(command, True, True)
3434
exposed_port = container.get_exposed_port(3_000)
3535
base_url = f'http://127.0.0.1:{exposed_port}'
36-
client = Client(base_url, access_token=access_token, options=options)
36+
client = Client(base_url, api_token=api_token, options=options)
3737
await client.initialize()
3838

3939
await client.ping()

tests/shared/database.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ def __init__(
2727
async def create(cls) -> 'Database':
2828
image = Image('eventsourcingdb', 'latest')
2929

30-
access_token = str(uuid.uuid4())
30+
api_token = str(uuid.uuid4())
3131
with_authorization = await ContainerizedTestingDatabase.create(
3232
image,
33-
['run', '--api-token', f'{access_token}', '--data-directory-temporary'],
34-
access_token,
33+
['run', '--api-token', f'{api_token}', '--data-directory-temporary'],
34+
api_token,
3535
ClientOptions()
3636
)
3737

3838
with_invalid_url_client = Client(
39-
base_url='http://localhost.invalid', access_token=access_token
39+
base_url='http://localhost.invalid', api_token=api_token
4040
)
4141
await with_invalid_url_client.initialize()
4242
with_invalid_url = TestingDatabase(

0 commit comments

Comments
 (0)