mirror of
https://github.com/simple-login/app.git
synced 2024-10-31 19:11:01 +01:00
remove new_random_alias related test
This commit is contained in:
parent
6414cdaccf
commit
565d406227
@ -1 +1 @@
|
||||
from .views import index, alias_options, new_custom_alias, new_random_alias
|
||||
from .views import index, alias_options, new_custom_alias
|
||||
|
@ -23,7 +23,6 @@ def options():
|
||||
optional recommendation:
|
||||
optional custom
|
||||
can_create_custom: boolean
|
||||
can_create_random: boolean
|
||||
existing: array of existing aliases
|
||||
|
||||
"""
|
||||
|
@ -25,7 +25,6 @@ Response: a json with following structure. ? means optional field.
|
||||
suffix: [@my_domain.com, .abcde@simplelogin.co]
|
||||
|
||||
can_create_custom: true
|
||||
can_create_random: true # obsolete now
|
||||
|
||||
existing:
|
||||
[email1, email2, ...]
|
||||
|
@ -21,13 +21,11 @@ def test_different_scenarios(flask_client):
|
||||
|
||||
# {
|
||||
# "can_create_custom": True,
|
||||
# "can_create_random": True,
|
||||
# "custom": {"suffixes": ["azdwbw@sl.local"], "suggestion": ""},
|
||||
# "existing": ["cat_cat_cat@sl.local"],
|
||||
# }
|
||||
assert r.status_code == 200
|
||||
assert r.json["can_create_custom"]
|
||||
assert r.json["can_create_random"]
|
||||
assert len(r.json["existing"]) == 1
|
||||
assert r.json["custom"]["suffixes"]
|
||||
assert r.json["custom"]["suggestion"] == "" # no hostname => no suggestion
|
||||
|
@ -1,50 +0,0 @@
|
||||
from flask import url_for
|
||||
|
||||
from app.config import EMAIL_DOMAIN
|
||||
from app.extensions import db
|
||||
from app.models import User, ApiKey, GenEmail
|
||||
|
||||
|
||||
def test_success(flask_client):
|
||||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
# create api_key
|
||||
api_key = ApiKey.create(user.id, "for test")
|
||||
db.session.commit()
|
||||
|
||||
r = flask_client.post(
|
||||
url_for("api.new_random_alias", hostname="www.test.com"),
|
||||
headers={"Authentication": api_key.code},
|
||||
)
|
||||
|
||||
assert r.status_code == 201
|
||||
assert r.json["alias"].endswith(EMAIL_DOMAIN)
|
||||
|
||||
|
||||
def test_out_of_quota(flask_client):
|
||||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
# create api_key
|
||||
api_key = ApiKey.create(user.id, "for test")
|
||||
db.session.commit()
|
||||
|
||||
# create 3 random alias to run out of quota
|
||||
GenEmail.create_new_gen_email(user.id)
|
||||
GenEmail.create_new_gen_email(user.id)
|
||||
GenEmail.create_new_gen_email(user.id)
|
||||
|
||||
r = flask_client.post(
|
||||
url_for("api.new_random_alias", hostname="www.test.com"),
|
||||
headers={"Authentication": api_key.code},
|
||||
)
|
||||
|
||||
assert r.status_code == 400
|
||||
assert r.json == {
|
||||
"error": "You have created 3 random aliases, please upgrade to create more"
|
||||
}
|
Loading…
Reference in New Issue
Block a user