Support disable_pgp in update alias endpoint
This commit is contained in:
parent
95213b6d85
commit
b167297808
|
@ -1043,6 +1043,7 @@ Input:
|
||||||
- (optional) `mailbox_id` in request body
|
- (optional) `mailbox_id` in request body
|
||||||
- (optional) `name` in request body
|
- (optional) `name` in request body
|
||||||
- (optional) `mailbox_ids` in request body: array of mailbox_id
|
- (optional) `mailbox_ids` in request body: array of mailbox_id
|
||||||
|
- (optional) `disable_pgp` in request body: boolean
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
If success, return 200
|
If success, return 200
|
||||||
|
|
|
@ -257,6 +257,7 @@ def update_alias(alias_id):
|
||||||
note (optional): in body
|
note (optional): in body
|
||||||
name (optional): in body
|
name (optional): in body
|
||||||
mailbox_id (optional): in body
|
mailbox_id (optional): in body
|
||||||
|
disable_pgp (optional): in body
|
||||||
Output:
|
Output:
|
||||||
200
|
200
|
||||||
"""
|
"""
|
||||||
|
@ -319,6 +320,10 @@ def update_alias(alias_id):
|
||||||
alias.name = new_name
|
alias.name = new_name
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
if "disable_pgp" in data:
|
||||||
|
alias.disable_pgp = data.get("disable_pgp")
|
||||||
|
changed = True
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
|
@ -399,6 +399,31 @@ def test_update_alias_mailboxes(flask_client):
|
||||||
assert r.status_code == 400
|
assert r.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_disable_pgp(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()
|
||||||
|
|
||||||
|
alias = Alias.create_new_random(user)
|
||||||
|
db.session.commit()
|
||||||
|
assert not alias.disable_pgp
|
||||||
|
|
||||||
|
r = flask_client.put(
|
||||||
|
url_for("api.update_alias", alias_id=alias.id),
|
||||||
|
headers={"Authentication": api_key.code},
|
||||||
|
json={"disable_pgp": True},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert r.status_code == 200
|
||||||
|
alias = Alias.get(alias.id)
|
||||||
|
assert alias.disable_pgp
|
||||||
|
|
||||||
|
|
||||||
def test_alias_contacts(flask_client):
|
def test_alias_contacts(flask_client):
|
||||||
user = User.create(
|
user = User.create(
|
||||||
email="a@b.c", password="password", name="Test User", activated=True
|
email="a@b.c", password="password", name="Test User", activated=True
|
||||||
|
|
Loading…
Reference in a new issue