Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add tests using IP address when creating or updating webhooks #5511

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ async def test_create_webhook(self, db: AsyncSession, async_client: AsyncClient,
"updated_at": webhook.updated_at.isoformat(),
}

async def test_create_webhook_with_ip_address_url(
self, db: AsyncSession, async_client: AsyncClient, owner_auth_header: dict
):
response = await async_client.post(
self.url(),
headers=owner_auth_header,
json={
"url": "http://1.1.1.1/webhook",
"events": [WebhookEvent.response_created],
"description": "Test webhook",
},
)

assert response.status_code == 201

assert (await db.execute(select(func.count(Webhook.id)))).scalar() == 1
webhook = (await db.execute(select(Webhook))).scalar_one()

assert response.json()["url"] == "http://1.1.1.1/webhook"

async def test_create_webhook_as_admin(self, db: AsyncSession, async_client: AsyncClient):
admin = await AdminFactory.create()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ async def test_update_webhook_with_url(self, async_client: AsyncClient, owner_au

assert webhook.url == "https://example.com/webhook"

async def test_update_webhook_with_ip_address_url(self, async_client: AsyncClient, owner_auth_header: dict):
webhook = await WebhookFactory.create()

response = await async_client.patch(
self.url(webhook.id),
headers=owner_auth_header,
json={
"url": "https://1.1.1.1:9999/webhook",
},
)

assert response.status_code == 200
assert response.json()["url"] == "https://1.1.1.1:9999/webhook"

async def test_update_webhook_with_events(self, async_client: AsyncClient, owner_auth_header: dict):
webhook = await WebhookFactory.create()

Expand Down
Loading