diff --git a/app/api/views/alias_options.py b/app/api/views/alias_options.py index 1dc40d20..9f998258 100644 --- a/app/api/views/alias_options.py +++ b/app/api/views/alias_options.py @@ -90,7 +90,9 @@ def options_v5(): suffixes: [ { suffix: "suffix", - signed_suffix: "signed_suffix" + signed_suffix: "signed_suffix", + is_custom: true, + is_premium: false } ] prefix_suggestion: str @@ -141,7 +143,12 @@ def options_v5(): # custom domain should be put first ret["suffixes"] = [ - {"suffix": suffix.suffix, "signed_suffix": suffix.signed_suffix} + { + "suffix": suffix.suffix, + "signed_suffix": suffix.signed_suffix, + "is_custom": suffix.is_custom, + "is_premium": suffix.is_premium, + } for suffix in suffixes ] diff --git a/docs/api.md b/docs/api.md index 4588a54a..a5332a83 100644 --- a/docs/api.md +++ b/docs/api.md @@ -231,7 +231,8 @@ Input: Output: a json with the following field: - can_create: boolean. Whether user can create new alias -- suffixes: list of dictionary with `suffix` and `signed-suffix`. List of alias `suffix` that user can use. +- suffixes: list of alias suffix that user can use. + Each item is a dictionary with `suffix`, `signed-suffix`, `is_custom`, `is_premium` as keys. The `signed-suffix` is necessary to avoid request tampering. - prefix_suggestion: string. Suggestion for the `alias prefix`. Usually this is the website name extracted from `hostname`. If no `hostname`, then the `prefix_suggestion` is empty. @@ -248,15 +249,21 @@ For ex: "suffixes": [ { "signed_suffix": ".cat@d1.test.X6_7OQ.0e9NbZHE_bQvuAapT6NdBml9m6Q", - "suffix": ".cat@d1.test" + "suffix": ".cat@d1.test", + "is_custom": true, + "is_premium": false }, { "signed_suffix": ".chat@d2.test.X6_7OQ.TTgCrfqPj7UmlY723YsDTHhkess", - "suffix": ".chat@d2.test" + "suffix": ".chat@d2.test", + "is_custom": false, + "is_premium": false }, { "signed_suffix": ".yeah@sl.local.X6_7OQ.i8XL4xsMsn7dxDEWU8eF-Zap0qo", - "suffix": ".yeah@sl.local" + "suffix": ".yeah@sl.local", + "is_custom": true, + "is_premium": false } ] } diff --git a/tests/api/test_alias_options.py b/tests/api/test_alias_options.py index f5e32525..6bd3c037 100644 --- a/tests/api/test_alias_options.py +++ b/tests/api/test_alias_options.py @@ -124,6 +124,8 @@ def test_different_scenarios_v5(flask_client): suffix_payload["signed_suffix"], ) assert signed_suffix.startswith(suffix) + assert "is_custom" in suffix_payload + assert "is_premium" in suffix_payload # <<< with hostname >>> r = flask_client.get( diff --git a/tests/test.env b/tests/test.env index ae3dff84..5f6fc935 100644 --- a/tests/test.env +++ b/tests/test.env @@ -25,9 +25,9 @@ AWS_ACCESS_KEY_ID=to_fill AWS_SECRET_ACCESS_KEY=to_fill # Paddle -PADDLE_VENDOR_ID = 1 -PADDLE_MONTHLY_PRODUCT_ID = 2 -PADDLE_YEARLY_PRODUCT_ID = 3 +PADDLE_VENDOR_ID=1 +PADDLE_MONTHLY_PRODUCT_ID=2 +PADDLE_YEARLY_PRODUCT_ID=3 PADDLE_PUBLIC_KEY_PATH=local_data/paddle.key.pub # OpenId key