|
@@ -119,7 +119,33 @@ def test_get_aliases_v2(flask_client):
|
|
|
a1 = Alias.create_new(user, "prefix1")
|
|
|
db.session.commit()
|
|
|
|
|
|
- # add activity for a0
|
|
|
+ # << Aliases have no activity >>
|
|
|
+ r = flask_client.get(
|
|
|
+ url_for("api.get_aliases_v2", page_id=0),
|
|
|
+ headers={"Authentication": api_key.code},
|
|
|
+ )
|
|
|
+ assert r.status_code == 200
|
|
|
+
|
|
|
+ r0 = r.json["aliases"][0]
|
|
|
+ assert "name" in r0
|
|
|
+
|
|
|
+ # make sure a1 is returned before a0
|
|
|
+ assert r0["email"].startswith("prefix1")
|
|
|
+ assert "id" in r0["mailbox"]
|
|
|
+ assert "email" in r0["mailbox"]
|
|
|
+
|
|
|
+ assert r0["mailboxes"]
|
|
|
+ for mailbox in r0["mailboxes"]:
|
|
|
+ assert "id" in mailbox
|
|
|
+ assert "email" in mailbox
|
|
|
+
|
|
|
+ assert "support_pgp" in r0
|
|
|
+ assert not r0["support_pgp"]
|
|
|
+
|
|
|
+ assert "disable_pgp" in r0
|
|
|
+ assert not r0["disable_pgp"]
|
|
|
+
|
|
|
+ # << Alias has some activities >>
|
|
|
c0 = Contact.create(
|
|
|
user_id=user.id,
|
|
|
alias_id=a0.id,
|
|
@@ -148,36 +174,8 @@ def test_get_aliases_v2(flask_client):
|
|
|
)
|
|
|
assert r.status_code == 200
|
|
|
|
|
|
- # make sure a1 is returned before a0
|
|
|
r0 = r.json["aliases"][0]
|
|
|
- # r0 will have the following format
|
|
|
- # {
|
|
|
- # "creation_date": "2020-04-25 21:10:01+00:00",
|
|
|
- # "creation_timestamp": 1587849001,
|
|
|
- # "email": "prefix1.yeah@sl.local",
|
|
|
- # "enabled": true,
|
|
|
- # "id": 3,
|
|
|
- # "name": "Hey hey",
|
|
|
- # "latest_activity": {
|
|
|
- # "action": "forward",
|
|
|
- # "contact": {
|
|
|
- # "email": "c1@example.com",
|
|
|
- # "name": null,
|
|
|
- # "reverse_alias": "\"c1 at example.com\" <re1@SL>"
|
|
|
- # },
|
|
|
- # "timestamp": 1587849001
|
|
|
- # },
|
|
|
- # "mailbox": {
|
|
|
- # "email": "a@b.c",
|
|
|
- # "id": 1
|
|
|
- # },
|
|
|
- # "nb_block": 0,
|
|
|
- # "nb_forward": 1,
|
|
|
- # "nb_reply": 0,
|
|
|
- # "note": null
|
|
|
- # }
|
|
|
- assert "name" in r0
|
|
|
- assert r0["email"].startswith("prefix1")
|
|
|
+
|
|
|
assert r0["latest_activity"]["action"] == "forward"
|
|
|
assert "timestamp" in r0["latest_activity"]
|
|
|
|
|
@@ -185,20 +183,6 @@ def test_get_aliases_v2(flask_client):
|
|
|
assert "name" in r0["latest_activity"]["contact"]
|
|
|
assert "reverse_alias" in r0["latest_activity"]["contact"]
|
|
|
|
|
|
- assert "id" in r0["mailbox"]
|
|
|
- assert "email" in r0["mailbox"]
|
|
|
-
|
|
|
- assert r0["mailboxes"]
|
|
|
- for mailbox in r0["mailboxes"]:
|
|
|
- assert "id" in mailbox
|
|
|
- assert "email" in mailbox
|
|
|
-
|
|
|
- assert "support_pgp" in r0
|
|
|
- assert not r0["support_pgp"]
|
|
|
-
|
|
|
- assert "disable_pgp" in r0
|
|
|
- assert not r0["disable_pgp"]
|
|
|
-
|
|
|
|
|
|
def test_delete_alias(flask_client):
|
|
|
user = User.create(
|