mailbox-org-api 2.0.1__tar.gz → 2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/PKG-INFO +2 -2
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api/APIClient.py +65 -12
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api.egg-info/PKG-INFO +2 -2
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/pyproject.toml +3 -3
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/setup.py +1 -1
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/tests/TestAPIClient.py +114 -22
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/LICENSE +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/README.md +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api/APIError.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api/Account.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api/Invoice.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api/Mail.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api/__init__.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api.egg-info/SOURCES.txt +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api.egg-info/dependency_links.txt +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/mailbox_org_api.egg-info/top_level.txt +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/setup.cfg +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/tests/TestAccount.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/tests/TestInvoice.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/tests/TestMail.py +0 -0
- {mailbox_org_api-2.0.1 → mailbox_org_api-2.2}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mailbox-org-api
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2
|
|
4
4
|
Summary: A library to access the mailbox.org Business API.
|
|
5
5
|
Author: Hendrik Schlange
|
|
6
6
|
Author-email: Hendrik Schlange <mail@heshsum.de>
|
|
@@ -9,7 +9,7 @@ Project-URL: Issues, https://github.com/heshsum/mailbox-org-api/issues
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Dynamic: author
|
|
@@ -3,9 +3,10 @@ Module for the mailbox Business API client
|
|
|
3
3
|
"""
|
|
4
4
|
import json
|
|
5
5
|
import requests
|
|
6
|
+
from requests.adapters import HTTPAdapter
|
|
7
|
+
from urllib3.util.retry import Retry
|
|
8
|
+
from requests.exceptions import RequestException
|
|
6
9
|
import typing_extensions
|
|
7
|
-
from requests import RequestException
|
|
8
|
-
|
|
9
10
|
from mailbox_org_api.APIError import APIError
|
|
10
11
|
from mailbox_org_api.Account import Account
|
|
11
12
|
from mailbox_org_api.Mail import Mail
|
|
@@ -19,8 +20,7 @@ class APIClient:
|
|
|
19
20
|
"""
|
|
20
21
|
Object for API Client
|
|
21
22
|
"""
|
|
22
|
-
|
|
23
|
-
def __init__(self, debug_output=False):
|
|
23
|
+
def __init__(self, debug_output=False, max_retries=5):
|
|
24
24
|
# URL of the API
|
|
25
25
|
self.url = "https://api.mailbox.org/v1/"
|
|
26
26
|
|
|
@@ -35,6 +35,27 @@ class APIClient:
|
|
|
35
35
|
|
|
36
36
|
self.debug_output = debug_output
|
|
37
37
|
|
|
38
|
+
# Initialize the session
|
|
39
|
+
self.session = requests.Session()
|
|
40
|
+
|
|
41
|
+
# Set default headers for the session
|
|
42
|
+
self.session.headers.update({
|
|
43
|
+
'Content-Type': 'application/json',
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
# Retry strategy
|
|
47
|
+
retry_strategy = Retry(
|
|
48
|
+
total=max_retries,
|
|
49
|
+
backoff_factor=0.5,
|
|
50
|
+
# Retry on these specific HTTP status codes
|
|
51
|
+
status_forcelist=[429, 500, 502, 503, 504],
|
|
52
|
+
# Allow retries for POST requests
|
|
53
|
+
allowed_methods=["HEAD", "GET", "OPTIONS", "POST"]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
adapter = HTTPAdapter(max_retries=retry_strategy)
|
|
57
|
+
self.session.mount('https://', adapter)
|
|
58
|
+
|
|
38
59
|
# Increment the request ID
|
|
39
60
|
def get_jsonrpc_id(self):
|
|
40
61
|
"""Method to create the JSON RPC request ID. """
|
|
@@ -73,8 +94,7 @@ class APIClient:
|
|
|
73
94
|
# Print the clean version of the request
|
|
74
95
|
print('API full request:\t', print_request)
|
|
75
96
|
|
|
76
|
-
api_response =
|
|
77
|
-
self.url, data=json.dumps(request), headers=headers)
|
|
97
|
+
api_response = self.session.post(self.url, data=json.dumps(request))
|
|
78
98
|
try:
|
|
79
99
|
api_response = api_response.json()
|
|
80
100
|
except RequestException as error:
|
|
@@ -115,7 +135,7 @@ class APIClient:
|
|
|
115
135
|
self.auth_id = str(api_response["session"])
|
|
116
136
|
print('Auth ID:', self.auth_id)
|
|
117
137
|
# The auth-header is added to the list of headers, as it has to be provided with each call
|
|
118
|
-
headers.update({"HPLS-AUTH": self.auth_id})
|
|
138
|
+
self.session.headers.update({"HPLS-AUTH": self.auth_id})
|
|
119
139
|
return api_response
|
|
120
140
|
|
|
121
141
|
def deauth(self) -> dict:
|
|
@@ -126,8 +146,9 @@ class APIClient:
|
|
|
126
146
|
api_response = self.api_request('deauth',{})
|
|
127
147
|
if api_response:
|
|
128
148
|
# The auth header is stripped
|
|
129
|
-
|
|
149
|
+
self.session.headers.pop("HPLS-AUTH")
|
|
130
150
|
self.auth_id = None
|
|
151
|
+
self.session.close()
|
|
131
152
|
return api_response
|
|
132
153
|
|
|
133
154
|
def hello_world(self):
|
|
@@ -431,7 +452,7 @@ class APIClient:
|
|
|
431
452
|
"""
|
|
432
453
|
return self.api_request('domain.validate.spf', {'domain':domain})
|
|
433
454
|
|
|
434
|
-
def mail_list(self, domain, details: bool = False, page_size: int = None, page: int = None, sort_field: str = None,
|
|
455
|
+
def mail_list(self, domain: str, details: bool = False, page_size: int = None, page: int = None, sort_field: str = None,
|
|
435
456
|
sort_order: str = None) -> dict:
|
|
436
457
|
"""
|
|
437
458
|
Function to list all mailboxes
|
|
@@ -543,7 +564,10 @@ class APIClient:
|
|
|
543
564
|
|
|
544
565
|
if 'password' in kwargs and 'password_hash' in kwargs:
|
|
545
566
|
raise KeyError('''Simultaneous usage of 'password' and 'password_hash' not allowed.''')
|
|
546
|
-
|
|
567
|
+
|
|
568
|
+
if 'additional_mail_quota' in kwargs or 'additional_cloud_quota' in kwargs and 'plan' not in kwargs:
|
|
569
|
+
raise KeyError('''If setting additional quota, 'plan' must be given.''')
|
|
570
|
+
|
|
547
571
|
# Check for each argument in kwargs if it is a valid function parameter.
|
|
548
572
|
# Check key and type of value. Raise errors if a check fails.
|
|
549
573
|
|
|
@@ -613,6 +637,27 @@ class APIClient:
|
|
|
613
637
|
"""
|
|
614
638
|
return self.api_request('mail.set', {'mail':mail, 'active':active})
|
|
615
639
|
|
|
640
|
+
def mail_set_additional_mail_quota(self, mail: str, quota: int) -> dict:
|
|
641
|
+
"""
|
|
642
|
+
Function to set additional mail quota for a given mail
|
|
643
|
+
:param mail: the mail to set the quota for
|
|
644
|
+
:param quota: the quota to set
|
|
645
|
+
:return: the response for the request
|
|
646
|
+
"""
|
|
647
|
+
plan = self.mail_get(mail)['plan']
|
|
648
|
+
return self.api_request('mail.set', {'mail': mail, 'plan':plan, 'additional_mail_quota':quota})
|
|
649
|
+
|
|
650
|
+
def mail_set_additional_cloud_quota(self, mail: str, quota: int) -> dict:
|
|
651
|
+
"""
|
|
652
|
+
Function to set additional cloud quota for a given mail
|
|
653
|
+
:param mail: the mail to set the quota for
|
|
654
|
+
:param quota: the quota to set
|
|
655
|
+
:return: the response for the request
|
|
656
|
+
"""
|
|
657
|
+
plan = self.mail_get(mail)['plan']
|
|
658
|
+
return self.api_request('mail.set', {'mail': mail, 'plan': plan,
|
|
659
|
+
'additional_cloud_quota': quota})
|
|
660
|
+
|
|
616
661
|
def mail_set_deletion_date(self, mail: str, deletion_date: str) -> dict:
|
|
617
662
|
"""
|
|
618
663
|
Function to delete an inbox at a given date.
|
|
@@ -933,14 +978,22 @@ class APIClient:
|
|
|
933
978
|
return self.api_request('mailinglist.set', {'mailinglist':mailinglist, 'account':account,
|
|
934
979
|
'password':password, 'adminmail':adminmail})
|
|
935
980
|
|
|
936
|
-
def
|
|
981
|
+
def mailinglist_del(self, mailinglist: str, account: str) -> dict:
|
|
937
982
|
"""
|
|
938
983
|
Function to delete a mailing list
|
|
939
984
|
:param mailinglist: the mailing list to delete
|
|
940
985
|
:param account: the account of the mailing list
|
|
941
986
|
:return: the mailbox API response for the request - True if the mailing list was deleted, error code otherwise
|
|
942
987
|
"""
|
|
943
|
-
return self.api_request('mailinglist.
|
|
988
|
+
return self.api_request('mailinglist.del', {'mailinglist':mailinglist, 'account':account})
|
|
989
|
+
|
|
990
|
+
def additionalmailaccount_list(self, parent_mail: str) -> dict:
|
|
991
|
+
"""
|
|
992
|
+
Function to list all additional mail accounts for a given parent mail
|
|
993
|
+
:param parent_mail: the parent mail to list additional mail accounts for
|
|
994
|
+
:return: a dict containing the parent mail account and a list of additional mail accounts
|
|
995
|
+
"""
|
|
996
|
+
return self.api_request('additionalmailaccount.list', {'parent_mail':parent_mail})
|
|
944
997
|
|
|
945
998
|
def additionalmailaccount_add(self, parent_mail: str, new_account_mail: str, new_account_password: str,
|
|
946
999
|
primary_address: str = None, mail_server: str = 'imap.mailbox.org',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mailbox-org-api
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2
|
|
4
4
|
Summary: A library to access the mailbox.org Business API.
|
|
5
5
|
Author: Hendrik Schlange
|
|
6
6
|
Author-email: Hendrik Schlange <mail@heshsum.de>
|
|
@@ -9,7 +9,7 @@ Project-URL: Issues, https://github.com/heshsum/mailbox-org-api/issues
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
|
-
Requires-Python: >=3.
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Dynamic: author
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mailbox-org-api"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.2"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name="Hendrik Schlange", email="mail@heshsum.de" },
|
|
6
6
|
]
|
|
7
7
|
description = "A library to access the mailbox.org Business API."
|
|
8
8
|
readme = "README.md"
|
|
9
|
-
requires-python = ">=3.
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
10
|
classifiers = [
|
|
11
11
|
"Programming Language :: Python :: 3",
|
|
12
12
|
"License :: OSI Approved :: MIT License",
|
|
@@ -18,7 +18,7 @@ Homepage = "https://github.com/heshsum/mailbox-org-api"
|
|
|
18
18
|
Issues = "https://github.com/heshsum/mailbox-org-api/issues"
|
|
19
19
|
|
|
20
20
|
[build-system]
|
|
21
|
-
requires = ["setuptools>=
|
|
21
|
+
requires = ["setuptools>=70.0"]
|
|
22
22
|
build-backend = "setuptools.build_meta"
|
|
23
23
|
|
|
24
24
|
[tool.pytest.ini_options]
|
|
@@ -3,7 +3,7 @@ from setuptools import find_packages, setup
|
|
|
3
3
|
setup(
|
|
4
4
|
name='mailbox_org_api',
|
|
5
5
|
packages=find_packages(),
|
|
6
|
-
version='2.
|
|
6
|
+
version='2.2',
|
|
7
7
|
description='A library to access the mailbox.org Business API',
|
|
8
8
|
author='Hendrik Schlange',
|
|
9
9
|
install_requires=['requests'],
|
|
@@ -15,9 +15,26 @@ def generate_id():
|
|
|
15
15
|
return str(int(time.time()))
|
|
16
16
|
|
|
17
17
|
def generate_pw():
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
# Length of password
|
|
19
|
+
length = 42
|
|
20
|
+
# Required character sets
|
|
21
|
+
upper = string.ascii_uppercase
|
|
22
|
+
lower = string.ascii_lowercase
|
|
23
|
+
digits = string.digits
|
|
24
|
+
special = '!$"%%&/()'
|
|
25
|
+
|
|
26
|
+
# Combine all allowed characters
|
|
27
|
+
all_chars = upper + lower + digits + special
|
|
28
|
+
while True:
|
|
29
|
+
# Generate a random string of the specified length
|
|
30
|
+
pw = ''.join(secrets.choice(all_chars) for _ in range(length))
|
|
31
|
+
|
|
32
|
+
# Ensure the password meets all criteria
|
|
33
|
+
if (any(c in upper for c in pw) and
|
|
34
|
+
any(c in lower for c in pw) and
|
|
35
|
+
any(c in digits for c in pw) and
|
|
36
|
+
any(c in special for c in pw)):
|
|
37
|
+
return pw
|
|
21
38
|
|
|
22
39
|
def get_domain():
|
|
23
40
|
api = APIClient.APIClient()
|
|
@@ -63,6 +80,14 @@ class TestAPIClient:
|
|
|
63
80
|
assert api.jsonrpc_id == 1
|
|
64
81
|
api.deauth()
|
|
65
82
|
|
|
83
|
+
def test_deauth(self):
|
|
84
|
+
api = APIClient.APIClient()
|
|
85
|
+
assert api.session.headers.get('HPLS-AUTH') is None
|
|
86
|
+
api.auth(api_test_user, api_test_pass)
|
|
87
|
+
assert api.session.headers.get('HPLS-AUTH') is not None
|
|
88
|
+
api.deauth()
|
|
89
|
+
assert api.session.headers.get('HPLS-AUTH') is None
|
|
90
|
+
|
|
66
91
|
def test_account_get(self):
|
|
67
92
|
api = APIClient.APIClient()
|
|
68
93
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -281,7 +306,7 @@ class TestAPIClient:
|
|
|
281
306
|
assert returned_mail['mail'] == mail
|
|
282
307
|
api.deauth()
|
|
283
308
|
|
|
284
|
-
@pytest.mark.depends(name=
|
|
309
|
+
@pytest.mark.depends(name='test_mail_add')
|
|
285
310
|
def test_mail_set(self):
|
|
286
311
|
api = APIClient.APIClient()
|
|
287
312
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -294,7 +319,7 @@ class TestAPIClient:
|
|
|
294
319
|
'memo': 'memo_string', 'active': True, 'title': 'Title', 'position': 'Job Position',
|
|
295
320
|
'department': 'Department', 'company': 'Company', 'street': 'Street 1',
|
|
296
321
|
'postal_code': '12345', 'city': 'City', 'phone':'+492345678', 'fax':'+492345678',
|
|
297
|
-
'cell_phone':'+492345678', 'uid_extern':
|
|
322
|
+
'cell_phone':'+492345678', 'uid_extern': 'external_uid_value', 'language': 'de_DE'}
|
|
298
323
|
|
|
299
324
|
# Adding parameters to call
|
|
300
325
|
params = {}
|
|
@@ -303,14 +328,23 @@ class TestAPIClient:
|
|
|
303
328
|
|
|
304
329
|
# Getting mail from API to act as the reference
|
|
305
330
|
check_mail = api.mail_get(mail)
|
|
306
|
-
|
|
331
|
+
print(check_mail)
|
|
307
332
|
# Compare values sent to values received
|
|
308
333
|
for k, v in mail_set_tests.items():
|
|
309
334
|
assert check_mail[k] == v
|
|
310
335
|
|
|
336
|
+
with pytest.raises(KeyError):
|
|
337
|
+
api.mail_set(mail, additional_mail_quota=5)
|
|
338
|
+
|
|
339
|
+
with pytest.raises(KeyError):
|
|
340
|
+
api.mail_set(mail, additional_cloud_quota=5)
|
|
341
|
+
|
|
342
|
+
with pytest.raises(KeyError):
|
|
343
|
+
api.mail_set(mail, additional_mail_quota = 5, additional_cloud_quota=5)
|
|
344
|
+
|
|
311
345
|
api.deauth()
|
|
312
346
|
|
|
313
|
-
@pytest.mark.depends(name=
|
|
347
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
314
348
|
def test_mail_capabilities_set(self):
|
|
315
349
|
capabilities = ['MAIL_SPAMPROTECTION', 'MAIL_BLACKLIST', 'MAIL_BACKUPRECOVER', 'MAIL_PASSWORDRESET_SMS']
|
|
316
350
|
|
|
@@ -344,22 +378,20 @@ class TestAPIClient:
|
|
|
344
378
|
api.auth(api_test_user, api_test_pass)
|
|
345
379
|
mails = api.mail_list(domain)
|
|
346
380
|
mail = mails[0]['mail']
|
|
347
|
-
plans = ['
|
|
381
|
+
plans = ['premium', 'light', 'standard']
|
|
348
382
|
for plan in plans:
|
|
349
383
|
api.mail_set_plan(mail, plan)
|
|
350
384
|
assert str(api.mail_get(mail)['plan']).lower() == plan
|
|
351
|
-
with pytest.raises(APIError):
|
|
352
|
-
api.mail_set_plan(mail, 'light')
|
|
353
385
|
api.deauth()
|
|
354
386
|
|
|
355
|
-
@pytest.mark.depends(name=
|
|
387
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
356
388
|
def test_mail_set_aliases(self):
|
|
357
389
|
api = APIClient.APIClient()
|
|
358
390
|
api.auth(api_test_user, api_test_pass)
|
|
359
391
|
mail = test_id + '@' + domain
|
|
360
392
|
aliases = []
|
|
361
393
|
api.mail_set_aliases(mail, aliases)
|
|
362
|
-
for i in range(0,
|
|
394
|
+
for i in range(0, 2):
|
|
363
395
|
address = test_id + '_alias_' + str(i) + '@' + domain
|
|
364
396
|
aliases.append(address)
|
|
365
397
|
api.mail_set_aliases(mail, aliases)
|
|
@@ -368,7 +400,7 @@ class TestAPIClient:
|
|
|
368
400
|
assert api.mail_get(mail)['aliases'] == []
|
|
369
401
|
api.deauth()
|
|
370
402
|
|
|
371
|
-
@pytest.mark.depends(name=
|
|
403
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
372
404
|
def test_mail_set_forwards(self):
|
|
373
405
|
api = APIClient.APIClient()
|
|
374
406
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -382,7 +414,7 @@ class TestAPIClient:
|
|
|
382
414
|
assert api.mail_get(mail)['forwards'] == forwards
|
|
383
415
|
api.deauth()
|
|
384
416
|
|
|
385
|
-
@pytest.mark.depends(name=
|
|
417
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
386
418
|
def test_mail_set_password(self):
|
|
387
419
|
api = APIClient.APIClient()
|
|
388
420
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -392,7 +424,7 @@ class TestAPIClient:
|
|
|
392
424
|
assert api.mail_set_password(mail, generate_pw()) == api.mail_get(mail)
|
|
393
425
|
api.deauth()
|
|
394
426
|
|
|
395
|
-
@pytest.mark.depends(name=
|
|
427
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
396
428
|
def test_mail_set_password_require_reset(self):
|
|
397
429
|
api = APIClient.APIClient()
|
|
398
430
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -402,7 +434,25 @@ class TestAPIClient:
|
|
|
402
434
|
assert api.mail_set_password_require_reset(mail, generate_pw()) == api.mail_get(mail)
|
|
403
435
|
api.deauth()
|
|
404
436
|
|
|
405
|
-
|
|
437
|
+
def test_mail_set_additional_mail_quota(self):
|
|
438
|
+
api = APIClient.APIClient()
|
|
439
|
+
api.auth(api_test_user, api_test_pass)
|
|
440
|
+
mail = test_id + '@' + domain
|
|
441
|
+
additional_mail_quota = 23
|
|
442
|
+
api.mail_set_additional_mail_quota(mail, additional_mail_quota)
|
|
443
|
+
assert additional_mail_quota == api.mail_get(mail)['additional_mail_quota']
|
|
444
|
+
api.deauth()
|
|
445
|
+
|
|
446
|
+
def test_mail_set_additional_cloud_quota(self):
|
|
447
|
+
api = APIClient.APIClient()
|
|
448
|
+
api.auth(api_test_user, api_test_pass)
|
|
449
|
+
mail = test_id + '@' + domain
|
|
450
|
+
additional_cloud_quota = 42
|
|
451
|
+
api.mail_set_additional_cloud_quota(mail, additional_cloud_quota)
|
|
452
|
+
assert additional_cloud_quota == api.mail_get(mail)['additional_cloud_quota']
|
|
453
|
+
api.deauth()
|
|
454
|
+
|
|
455
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
406
456
|
def test_mail_apppassword_add(self):
|
|
407
457
|
api = APIClient.APIClient()
|
|
408
458
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -412,7 +462,7 @@ class TestAPIClient:
|
|
|
412
462
|
assert len(api.mail_apppassword_list(mail)) == len_before + 1
|
|
413
463
|
api.deauth()
|
|
414
464
|
|
|
415
|
-
@pytest.mark.depends(name=
|
|
465
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
416
466
|
def test_mail_apppassword_list(self):
|
|
417
467
|
api = APIClient.APIClient()
|
|
418
468
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -420,9 +470,9 @@ class TestAPIClient:
|
|
|
420
470
|
assert len(api.mail_apppassword_list(mail)) > 0
|
|
421
471
|
api.deauth()
|
|
422
472
|
|
|
423
|
-
@pytest.mark.depends(name=
|
|
424
|
-
@pytest.mark.depends(name=
|
|
425
|
-
@pytest.mark.depends(name=
|
|
473
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
474
|
+
@pytest.mark.depends(name='test_mail_apppassword_add')
|
|
475
|
+
@pytest.mark.depends(name='test_mail_apppassword_list')
|
|
426
476
|
def test_mail_apppassword_del(self):
|
|
427
477
|
api = APIClient.APIClient()
|
|
428
478
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -437,8 +487,9 @@ class TestAPIClient:
|
|
|
437
487
|
|
|
438
488
|
# After deleting all app passwords, length should be 0
|
|
439
489
|
assert len(api.mail_apppassword_list(mail)) == 0
|
|
490
|
+
api.deauth()
|
|
440
491
|
|
|
441
|
-
@pytest.mark.depends(name=
|
|
492
|
+
@pytest.mark.depends(name='test_mail_add')
|
|
442
493
|
def test_mail_set_deletion_date(self):
|
|
443
494
|
api = APIClient.APIClient()
|
|
444
495
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -449,7 +500,47 @@ class TestAPIClient:
|
|
|
449
500
|
assert deletion_date in api.mail_get(mail)['deletion_date']
|
|
450
501
|
api.deauth()
|
|
451
502
|
|
|
452
|
-
|
|
503
|
+
def test_additionalmailaccount_list(self):
|
|
504
|
+
api = APIClient.APIClient()
|
|
505
|
+
api.auth(api_test_user, api_test_pass)
|
|
506
|
+
parent = 'parent@testbmboapi.internal'
|
|
507
|
+
sub = 'sub_mail@testbmboapi.internal'
|
|
508
|
+
assert sub in api.additionalmailaccount_list(parent)['additional_accounts']
|
|
509
|
+
api.deauth()
|
|
510
|
+
|
|
511
|
+
# Removed test as the API is too unrealiable.
|
|
512
|
+
# It oftentimes needs too much time to update and reply with the updated data for the test to work reliably
|
|
513
|
+
# def test_additionalmailaccount_add(self):
|
|
514
|
+
# api = APIClient.APIClient()
|
|
515
|
+
# api.auth(api_test_user, api_test_pass)
|
|
516
|
+
# parent_mail = test_id + '_parent@' + domain
|
|
517
|
+
# sub_mail = test_id + '_sub@' + domain
|
|
518
|
+
# pw = generate_pw()
|
|
519
|
+
# # Creating the accounts
|
|
520
|
+
# api.mail_add(parent_mail, pw, 'light', 'test parent', 'test_parent')
|
|
521
|
+
# api.mail_add(sub_mail, pw, 'light', 'test sub', 'test_sub' )
|
|
522
|
+
# # Adding it to the mail account
|
|
523
|
+
# assert api.additionalmailaccount_add(parent_mail, sub_mail, pw) == True
|
|
524
|
+
# # Before checking the result, wait for a bit
|
|
525
|
+
# # The mailbox API is sometimes slower than the test, resulting in failed tests
|
|
526
|
+
# time.sleep(5)
|
|
527
|
+
# # Checking that the sub account is listed as an additional account
|
|
528
|
+
# assert sub_mail in api.additionalmailaccount_list(parent_mail)['additional_accounts']
|
|
529
|
+
# api.deauth()
|
|
530
|
+
|
|
531
|
+
# @pytest.mark.depends(name='test_additionalmailaccount_add')
|
|
532
|
+
# def test_additionalmailaccount_delete(self):
|
|
533
|
+
# api = APIClient.APIClient()
|
|
534
|
+
# api.auth(api_test_user, api_test_pass)
|
|
535
|
+
# parent_mail = test_id + '_parent@' + domain
|
|
536
|
+
# sub_mail = test_id + '_sub@' + domain
|
|
537
|
+
# assert api.additionalmailaccount_delete(parent_mail, sub_mail) == True
|
|
538
|
+
# assert sub_mail not in api.additionalmailaccount_list(parent_mail)
|
|
539
|
+
# api.mail_del(parent_mail)
|
|
540
|
+
# api.mail_del(sub_mail)
|
|
541
|
+
# api.deauth()
|
|
542
|
+
|
|
543
|
+
@pytest.mark.depends(name='test_mail_add')
|
|
453
544
|
def test_search(self):
|
|
454
545
|
api = APIClient.APIClient()
|
|
455
546
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -457,6 +548,7 @@ class TestAPIClient:
|
|
|
457
548
|
assert mail in api.search(mail)['emails']
|
|
458
549
|
assert domain in api.search(domain)['domains']
|
|
459
550
|
assert api_test_user in api.search(api_test_user)['accounts']
|
|
551
|
+
api.deauth()
|
|
460
552
|
|
|
461
553
|
@pytest.mark.order('last')
|
|
462
554
|
def test_mail_del(self):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|