From 0806f9243edc75a051644529bd532b2bf64ecc49 Mon Sep 17 00:00:00 2001 From: Son Date: Sun, 16 Jan 2022 17:26:11 +0100 Subject: [PATCH] return custom domain json in patch --- app/api/views/custom_domain.py | 4 +++- docs/api.md | 2 +- tests/api/test_custom_domain.py | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/api/views/custom_domain.py b/app/api/views/custom_domain.py index 9e08d9ef..b42c957e 100644 --- a/app/api/views/custom_domain.py +++ b/app/api/views/custom_domain.py @@ -121,4 +121,6 @@ def update_custom_domain(custom_domain_id): if changed: Session.commit() - return jsonify(ok=True), 200 + # refresh + custom_domain = CustomDomain.get(custom_domain_id) + return jsonify(custom_domain=custom_domain_to_dict(custom_domain)), 200 diff --git a/docs/api.md b/docs/api.md index a78b1c0f..45f82efd 100644 --- a/docs/api.md +++ b/docs/api.md @@ -741,7 +741,7 @@ Input: - (optional) `mailbox_ids`: array of mailbox id, in request body Output: -If success, return 200 +If success, return 200 along with updated custom domain #### GET /api/custom_domains/:custom_domain_id/trash diff --git a/tests/api/test_custom_domain.py b/tests/api/test_custom_domain.py index 382f2039..991387e6 100644 --- a/tests/api/test_custom_domain.py +++ b/tests/api/test_custom_domain.py @@ -47,6 +47,23 @@ def test_update_custom_domains(flask_client): assert r.status_code == 200 assert d1.catch_all is True + # make sure the full domain json is returned + cd_json = r.json["custom_domain"] + assert cd_json["domain_name"] + assert cd_json["id"] == d1.id + assert cd_json["nb_alias"] == 0 + assert "is_verified" in cd_json + assert "catch_all" in cd_json + assert "name" in cd_json + assert "random_prefix_generation" in cd_json + assert cd_json["creation_date"] + assert cd_json["creation_timestamp"] + + assert cd_json["mailboxes"] + for mailbox in cd_json["mailboxes"]: + assert "id" in mailbox + assert "email" in mailbox + # test update random_prefix_generation assert d1.random_prefix_generation is False r = flask_client.patch(