fix proton partner error when self host (#1255)
* fix proton partner error when self host * fix test * fix test * remove a@b.c
This commit is contained in:
parent
72256d935c
commit
f69c9583fb
|
@ -1,17 +1,17 @@
|
|||
import base64
|
||||
from io import BytesIO
|
||||
from typing import Optional
|
||||
|
||||
from flask import jsonify, g, request, make_response
|
||||
from flask_login import logout_user
|
||||
from typing import Optional
|
||||
|
||||
from app import s3
|
||||
from app import s3, config
|
||||
from app.api.base import api_bp, require_api_auth
|
||||
from app.config import SESSION_COOKIE_NAME
|
||||
from app.db import Session
|
||||
from app.models import ApiKey, File, PartnerUser, User
|
||||
from app.utils import random_string
|
||||
from app.proton.utils import get_proton_partner
|
||||
from app.utils import random_string
|
||||
|
||||
|
||||
def get_connected_proton_address(user: User) -> Optional[str]:
|
||||
|
@ -29,9 +29,12 @@ def user_to_dict(user: User) -> dict:
|
|||
"email": user.email,
|
||||
"in_trial": user.in_trial(),
|
||||
"max_alias_free_plan": user.max_alias_for_free_account(),
|
||||
"connected_proton_address": get_connected_proton_address(user),
|
||||
"connected_proton_address": None,
|
||||
}
|
||||
|
||||
if config.CONNECT_WITH_PROTON:
|
||||
ret["connected_proton_address"] = get_connected_proton_address(user)
|
||||
|
||||
if user.profile_picture_id:
|
||||
ret["profile_picture_url"] = user.profile_picture.get_url()
|
||||
else:
|
||||
|
|
|
@ -1,27 +1,17 @@
|
|||
from flask import url_for
|
||||
import arrow
|
||||
from flask import url_for
|
||||
|
||||
# Need to import directly from config to allow modification from the tests
|
||||
from app import config
|
||||
from app.db import Session
|
||||
from app.email_utils import is_reverse_alias
|
||||
from app.models import User, ApiKey, Alias, Contact, EmailLog, Mailbox
|
||||
from app.models import User, Alias, Contact, EmailLog, Mailbox
|
||||
from tests.api.utils import get_new_user_and_api_key
|
||||
from tests.utils import login, random_domain
|
||||
|
||||
|
||||
def test_get_aliases_error_without_pagination(flask_client):
|
||||
user = User.create(
|
||||
email="a@b.c",
|
||||
password="password",
|
||||
name="Test User",
|
||||
activated=True,
|
||||
commit=True,
|
||||
)
|
||||
|
||||
# create api_key
|
||||
api_key = ApiKey.create(user.id, "for test")
|
||||
Session.commit()
|
||||
user, api_key = get_new_user_and_api_key()
|
||||
|
||||
r = flask_client.get(
|
||||
url_for("api.get_aliases"), headers={"Authentication": api_key.code}
|
||||
|
@ -32,17 +22,7 @@ def test_get_aliases_error_without_pagination(flask_client):
|
|||
|
||||
|
||||
def test_get_aliases_with_pagination(flask_client):
|
||||
user = User.create(
|
||||
email="a@b.c",
|
||||
password="password",
|
||||
name="Test User",
|
||||
activated=True,
|
||||
commit=True,
|
||||
)
|
||||
|
||||
# create api_key
|
||||
api_key = ApiKey.create(user.id, "for test")
|
||||
Session.commit()
|
||||
user, api_key = get_new_user_and_api_key()
|
||||
|
||||
# create more aliases than config.PAGE_LIMIT
|
||||
for _ in range(config.PAGE_LIMIT + 1):
|
||||
|
@ -79,14 +59,7 @@ def test_get_aliases_with_pagination(flask_client):
|
|||
|
||||
|
||||
def test_get_aliases_query(flask_client):
|
||||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
)
|
||||
Session.commit()
|
||||
|
||||
# create api_key
|
||||
api_key = ApiKey.create(user.id, "for test")
|
||||
Session.commit()
|
||||
user, api_key = get_new_user_and_api_key()
|
||||
|
||||
# create more aliases than config.PAGE_LIMIT
|
||||
Alias.create_new(user, "prefix1")
|
||||
|
@ -491,14 +464,7 @@ def test_alias_contacts(flask_client):
|
|||
|
||||
|
||||
def test_create_contact_route(flask_client):
|
||||
user = User.create(
|
||||
email="a@b.c", password="password", name="Test User", activated=True
|
||||
)
|
||||
Session.commit()
|
||||
|
||||
# create api_key
|
||||
api_key = ApiKey.create(user.id, "for test")
|
||||
Session.commit()
|
||||
user, api_key = get_new_user_and_api_key()
|
||||
|
||||
alias = Alias.create_new_random(user)
|
||||
Session.commit()
|
||||
|
|
|
@ -27,6 +27,7 @@ def test_user_in_trial(flask_client):
|
|||
|
||||
|
||||
def test_user_linked_to_proton(flask_client):
|
||||
config.CONNECT_WITH_PROTON = True
|
||||
user, api_key = get_new_user_and_api_key()
|
||||
partner = get_proton_partner()
|
||||
partner_email = random_email()
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import random
|
||||
from email.message import Message
|
||||
|
||||
import pytest
|
||||
|
@ -36,7 +37,7 @@ def prepare_complaint(
|
|||
contact = Contact.create(
|
||||
user_id=alias.user.id,
|
||||
alias_id=alias.id,
|
||||
website_email="a@b.c",
|
||||
website_email=f"contact{random.random()}@mailbox.test",
|
||||
reply_email="d@e.f",
|
||||
commit=True,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue