diff --git a/app/api/views/custom_domain.py b/app/api/views/custom_domain.py index 95497392..c89f2282 100644 --- a/app/api/views/custom_domain.py +++ b/app/api/views/custom_domain.py @@ -8,9 +8,14 @@ from app.models import CustomDomain, DomainDeletedAlias def custom_domain_to_dict(custom_domain: CustomDomain): return { "id": custom_domain.id, - "domain": custom_domain.domain, - "verified": custom_domain.verified, + "domain_name": custom_domain.domain, + "is_verified": custom_domain.verified, "nb_alias": custom_domain.nb_alias(), + "creation_date": custom_domain.created_at.format(), + "creation_timestamp": custom_domain.created_at.timestamp, + "catch_all": custom_domain.catch_all, + "name": custom_domain.name, + "random_prefix_generation": custom_domain.random_prefix_generation, } diff --git a/docs/api.md b/docs/api.md index 2db34520..463ff940 100644 --- a/docs/api.md +++ b/docs/api.md @@ -633,16 +633,26 @@ List of custom domains. { "custom_domains": [ { - "domain": "test1.org", + "catch_all": false, + "creation_date": "2021-03-06 19:42:33+00:00", + "creation_timestamp": 1615059753, + "domain_name": "test1.org", "id": 1, + "is_verified": true, + "name": null, "nb_alias": 0, - "verified": true + "random_prefix_generation": false }, { - "domain": "test2.org", + "catch_all": false, + "creation_date": "2021-03-06 19:42:33+00:00", + "creation_timestamp": 1615059753, + "domain_name": "test2.org", "id": 2, + "is_verified": false, + "name": null, "nb_alias": 0, - "verified": false + "random_prefix_generation": false } ] } diff --git a/tests/api/test_custom_domain.py b/tests/api/test_custom_domain.py index e14f5623..84e0e03f 100644 --- a/tests/api/test_custom_domain.py +++ b/tests/api/test_custom_domain.py @@ -16,12 +16,18 @@ def test_get_custom_domains(flask_client): ) assert r.status_code == 200 - assert r.json == { - "custom_domains": [ - {"domain": "test1.org", "id": 1, "nb_alias": 0, "verified": True}, - {"domain": "test2.org", "id": 2, "nb_alias": 0, "verified": False}, - ] - } + assert len(r.json["custom_domains"]) == 2 + for domain in r.json["custom_domains"]: + assert domain["domain_name"] + assert domain["id"] + assert domain["nb_alias"] == 0 + assert "is_verified" in domain + assert "catch_all" in domain + assert "name" in domain + assert "random_prefix_generation" in domain + assert domain["creation_date"] + assert domain["creation_timestamp"] + def test_get_custom_domain_trash(flask_client):