Skip to content

Commit aea1959

Browse files
authored
Merge pull request #1 from bsgip/removedcreaterequest
Removed CreateEndpointRequest
2 parents d97d338 + 243fe00 commit aea1959

4 files changed

Lines changed: 4 additions & 22 deletions

File tree

src/cactus_client_notifications/schema/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@
2626
URI_ENDPOINT = "/webhook/{endpoint_id}"
2727

2828

29-
@dataclass(frozen=True)
30-
class CreateEndpointRequest(JSONWizard):
31-
"""Used for requesting the generation of a new testing endpoint"""
32-
33-
test_id: str # Purely informational
34-
35-
3629
@dataclass(frozen=True)
3730
class CreateEndpointResponse(JSONWizard):
3831
"""Used in response to a CreateEndpointRequest"""

src/cactus_client_notifications/server/handler.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
URI_ENDPOINT,
88
CollectEndpointResponse,
99
ConfigureEndpointRequest,
10-
CreateEndpointRequest,
1110
CreateEndpointResponse,
1211
)
1312
from cactus_client_notifications.server.endpoint_store import (
@@ -64,7 +63,7 @@ def generate_public_uri(server_settings: ServerSettings, endpoint_id: str) -> st
6463

6564

6665
async def post_manage_endpoint_list(request: web.Request) -> web.Response:
67-
"""Expects a CreateEndpointResponse to be included in the POST body. Creates a new endpoint
66+
"""Expects an empty POST body. Creates a new endpoint
6867
6968
Args:
7069
request: An aiohttp.web.Request instance.
@@ -75,16 +74,8 @@ async def post_manage_endpoint_list(request: web.Request) -> web.Response:
7574
a 201 (CREATED) on success
7675
a 507 (INSUFFICIENT_STORAGE) if the webserver has too many notification endpoints at this moment
7776
"""
78-
try:
79-
raw_json = await request.text()
80-
except ContentTypeError:
81-
return web.Response(status=http.HTTPStatus.BAD_REQUEST, text="Missing JSON body")
82-
83-
create_request = CreateEndpointRequest.from_json(raw_json)
84-
if isinstance(create_request, list):
85-
return web.Response(status=http.HTTPStatus.BAD_REQUEST, text="Singular CreateEndpointRequest is required.")
8677

87-
logger.info(f"Creating endpoint for Test ID {create_request.test_id} for {request.remote}")
78+
logger.info(f"Creating endpoint for {request.remote}")
8879

8980
try:
9081
endpoint_id = await request.app[APPKEY_NOTIFICATION_STORE].create_endpoint()

tests/integration/test_endpoints.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
from cactus_client_notifications.schema import (
88
CollectEndpointResponse,
99
ConfigureEndpointRequest,
10-
CreateEndpointRequest,
1110
CreateEndpointResponse,
1211
)
1312

1413

1514
async def create_endpoint(client_session: ClientSession, endpoint: str) -> CreateEndpointResponse:
16-
result = await client_session.post(endpoint, json=CreateEndpointRequest("abc-123").to_dict())
15+
result = await client_session.post(endpoint)
1716
assert result.status == HTTPStatus.CREATED
1817
assert result.content_type == "application/json"
1918
response = CreateEndpointResponse.from_json(await result.text())
@@ -129,7 +128,7 @@ async def test_max_endpoint_limits(client_session: ClientSession):
129128
await create_endpoint(client_session, "/manage/endpoint")
130129

131130
# Can't create more unless we delete first
132-
result = await client_session.post("/manage/endpoint", json=CreateEndpointRequest("abc-123").to_dict())
131+
result = await client_session.post("/manage/endpoint")
133132
assert result.status == HTTPStatus.INSUFFICIENT_STORAGE
134133
await delete_endpoint(client_session, f"/manage/endpoint/{endpoint2.endpoint_id}")
135134
await create_endpoint(client_session, "/manage/endpoint")

tests/unit/schema/test_models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
schema.CollectedNotification,
1414
schema.CollectEndpointResponse,
1515
schema.ConfigureEndpointRequest,
16-
schema.CreateEndpointRequest,
1716
schema.CreateEndpointResponse,
1817
],
1918
)

0 commit comments

Comments
 (0)