return whether a domain is custom or primary in GET /api/v5/alias/options

This commit is contained in:
Son 2022-04-14 17:28:40 +02:00
parent a957cbb3c0
commit debed67c68
4 changed files with 25 additions and 9 deletions

View File

@ -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
]

View File

@ -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
}
]
}

View File

@ -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(

View File

@ -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