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 1 commit
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
11 changes: 7 additions & 4 deletions argilla-server/src/argilla_server/api/schemas/v1/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
from typing import List, Optional
from uuid import UUID

from argilla_server.webhooks.v1.enums import WebhookEvent
from argilla_server.api.schemas.v1.commons import UpdateSchema
from argilla_server.pydantic_v1 import BaseModel, Field, HttpUrl
from argilla_server.pydantic_v1 import BaseModel, Field, HttpUrl, AnyHttpUrl
from argilla_server.settings import settings
from argilla_server.webhooks.v1.enums import WebhookEvent

WEBHOOK_EVENTS_MIN_ITEMS = 1
WEBHOOK_DESCRIPTION_MIN_LENGTH = 1
WEBHOOK_DESCRIPTION_MAX_LENGTH = 1000

WebhookUrl = HttpUrl if settings.webhook_enable_required_top_level_domain else AnyHttpUrl
frascuchon marked this conversation as resolved.
Show resolved Hide resolved


class Webhook(BaseModel):
id: UUID
Expand All @@ -44,7 +47,7 @@ class Webhooks(BaseModel):


class WebhookCreate(BaseModel):
url: HttpUrl
url: WebhookUrl
events: List[WebhookEvent] = Field(
min_items=WEBHOOK_EVENTS_MIN_ITEMS,
unique_items=True,
Expand All @@ -56,7 +59,7 @@ class WebhookCreate(BaseModel):


class WebhookUpdate(UpdateSchema):
url: Optional[HttpUrl]
url: Optional[WebhookUrl]
events: Optional[List[WebhookEvent]] = Field(
min_items=WEBHOOK_EVENTS_MIN_ITEMS,
unique_items=True,
Expand Down
7 changes: 7 additions & 0 deletions argilla-server/src/argilla_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ class Settings(BaseSettings):
default=True, description="The telemetry configuration for Hugging Face hub telemetry. "
)

# Webhook settings
frascuchon marked this conversation as resolved.
Show resolved Hide resolved
webhook_enable_required_top_level_domain: bool = Field(
frascuchon marked this conversation as resolved.
Show resolved Hide resolved
default=True,
description="If True, the webhook URL must have a top-level domain. "
"If False, the webhook URL can be an IP address. This is useful for local development.",
)

# See also the telemetry.py module
@validator("enable_telemetry", pre=True, always=True)
def set_enable_telemetry(cls, enable_telemetry: bool) -> bool:
Expand Down