linkifiers: Add an API to support the editing of linkifier.

This commit adds an API to `zproject/urls.py` to edit/update
the realm linkifier. Its helper function to update the
database is added in `zerver/lib/actions.py`.

`zulip.yaml` is documented accordingly as well, clearly
stating that this API updates one linkifier at a time.

The tests are added for the API and helper function which
updates the realm linkifier.

Fixes #10830.
This commit is contained in:
akshatdalton
2021-04-15 17:51:36 +00:00
committed by Tim Abbott
parent c180cd5fa1
commit 6509c4f8f4
11 changed files with 187 additions and 5 deletions

View File

@@ -372,6 +372,25 @@ def add_realm_filter(client: Client) -> None:
validate_against_openapi_schema(result, "/realm/filters", "post", "200")
@openapi_test_function("/realm/filters/{filter_id}:patch")
def update_realm_filter(client: Client) -> None:
# {code_example|start}
# Update the linkifier (realm_filter) with ID 1
filter_id = 1
request = {
"pattern": "#(?P<id>[0-9]+)",
"url_format_string": "https://github.com/zulip/zulip/issues/%(id)s",
}
result = client.call_endpoint(
url=f"/realm/filters/{filter_id}", method="PATCH", request=request
)
# {code_example|end}
validate_against_openapi_schema(result, "/realm/filters/{filter_id}", "patch", "200")
@openapi_test_function("/realm/filters/{filter_id}:delete")
def remove_realm_filter(client: Client) -> None:
@@ -1464,6 +1483,7 @@ def test_server_organizations(client: Client) -> None:
get_realm_linkifiers(client)
add_realm_filter(client)
update_realm_filter(client)
add_realm_playground(client)
get_server_settings(client)
remove_realm_filter(client)