mailbox-org-api 2.1__tar.gz → 2.3__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.1 → mailbox_org_api-2.3}/PKG-INFO +3 -3
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api/APIClient.py +85 -31
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api.egg-info/PKG-INFO +3 -3
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/pyproject.toml +4 -4
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/setup.py +2 -2
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/tests/TestAPIClient.py +106 -22
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/LICENSE +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/README.md +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api/APIError.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api/Account.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api/Invoice.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api/Mail.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api/__init__.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api.egg-info/SOURCES.txt +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api.egg-info/dependency_links.txt +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/mailbox_org_api.egg-info/top_level.txt +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/setup.cfg +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/tests/TestAccount.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/tests/TestInvoice.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/tests/TestMail.py +0 -0
- {mailbox_org_api-2.1 → mailbox_org_api-2.3}/tests/__init__.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mailbox-org-api
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: A library to access the mailbox
|
|
3
|
+
Version: 2.3
|
|
4
|
+
Summary: A library to access the mailbox Business API.
|
|
5
5
|
Author: Hendrik Schlange
|
|
6
6
|
Author-email: Hendrik Schlange <mail@heshsum.de>
|
|
7
7
|
Project-URL: Homepage, https://github.com/heshsum/mailbox-org-api
|
|
@@ -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
|
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
Module for the mailbox Business API client
|
|
3
3
|
"""
|
|
4
4
|
import json
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
5
7
|
import requests
|
|
8
|
+
import typing_extensions
|
|
6
9
|
from requests.adapters import HTTPAdapter
|
|
7
|
-
from urllib3.util.retry import Retry
|
|
8
10
|
from requests.exceptions import RequestException
|
|
9
|
-
import
|
|
11
|
+
from urllib3.util.retry import Retry
|
|
12
|
+
|
|
10
13
|
from mailbox_org_api.APIError import APIError
|
|
11
14
|
from mailbox_org_api.Account import Account
|
|
12
|
-
from mailbox_org_api.Mail import Mail
|
|
13
15
|
from mailbox_org_api.Invoice import Invoice
|
|
16
|
+
from mailbox_org_api.Mail import Mail
|
|
14
17
|
|
|
15
18
|
headers = {'content-type': 'application/json'}
|
|
16
19
|
|
|
@@ -62,7 +65,7 @@ class APIClient:
|
|
|
62
65
|
self.jsonrpc_id += 1
|
|
63
66
|
return str(self.jsonrpc_id)
|
|
64
67
|
|
|
65
|
-
def api_request(self, method: str, params: dict) -> dict:
|
|
68
|
+
def api_request(self, method: str, params: dict) -> dict | Any:
|
|
66
69
|
"""
|
|
67
70
|
Function to send API calls
|
|
68
71
|
:param method: the method to call
|
|
@@ -365,7 +368,7 @@ class APIClient:
|
|
|
365
368
|
# Take the Base64 encoded data (response['bin']), decode the Base 64, decompress the gz and return the bytes
|
|
366
369
|
return zlib.decompress(base64.b64decode(response['bin']))
|
|
367
370
|
|
|
368
|
-
def domain_list(self, account:
|
|
371
|
+
def domain_list(self, account:str, search_filter:str | None = None) -> dict:
|
|
369
372
|
"""
|
|
370
373
|
Function to list all domains
|
|
371
374
|
:param account: the account to list domains for
|
|
@@ -373,8 +376,8 @@ class APIClient:
|
|
|
373
376
|
:return: the API response
|
|
374
377
|
"""
|
|
375
378
|
params = {'account':account}
|
|
376
|
-
if
|
|
377
|
-
params.update({'filter':search_filter})
|
|
379
|
+
if isinstance(search_filter, str):
|
|
380
|
+
params.update({'filter':str(search_filter)})
|
|
378
381
|
return self.api_request('domain.list',params)
|
|
379
382
|
|
|
380
383
|
def domain_add(self, account: str, domain: str, password: str, **kwargs) -> dict:
|
|
@@ -452,8 +455,8 @@ class APIClient:
|
|
|
452
455
|
"""
|
|
453
456
|
return self.api_request('domain.validate.spf', {'domain':domain})
|
|
454
457
|
|
|
455
|
-
def mail_list(self, domain: str, details: bool = False, page_size: int = None, page: int
|
|
456
|
-
sort_order: str = None) -> dict:
|
|
458
|
+
def mail_list(self, domain: str, details: bool = False, page_size: int | None= None, page: int | None = None,
|
|
459
|
+
sort_field: str | None = None, sort_order: str | None = None) -> dict:
|
|
457
460
|
"""
|
|
458
461
|
Function to list all mailboxes
|
|
459
462
|
:param domain: the domain to list
|
|
@@ -488,7 +491,7 @@ class APIClient:
|
|
|
488
491
|
return self.api_request('mail.list', params)
|
|
489
492
|
|
|
490
493
|
def mail_add(self, mail:str, password: str, plan: str, first_name: str, last_name: str, inboxsave: bool = True,
|
|
491
|
-
forwards: list = None, **kwargs) -> dict:
|
|
494
|
+
forwards: list | None= None, **kwargs) -> dict:
|
|
492
495
|
"""
|
|
493
496
|
Function to add a mail
|
|
494
497
|
:param mail: the mail to add
|
|
@@ -564,7 +567,10 @@ class APIClient:
|
|
|
564
567
|
|
|
565
568
|
if 'password' in kwargs and 'password_hash' in kwargs:
|
|
566
569
|
raise KeyError('''Simultaneous usage of 'password' and 'password_hash' not allowed.''')
|
|
567
|
-
|
|
570
|
+
|
|
571
|
+
if 'additional_mail_quota' in kwargs or 'additional_cloud_quota' in kwargs and 'plan' not in kwargs:
|
|
572
|
+
raise KeyError('''If setting additional quota, 'plan' must be given.''')
|
|
573
|
+
|
|
568
574
|
# Check for each argument in kwargs if it is a valid function parameter.
|
|
569
575
|
# Check key and type of value. Raise errors if a check fails.
|
|
570
576
|
|
|
@@ -634,6 +640,27 @@ class APIClient:
|
|
|
634
640
|
"""
|
|
635
641
|
return self.api_request('mail.set', {'mail':mail, 'active':active})
|
|
636
642
|
|
|
643
|
+
def mail_set_additional_mail_quota(self, mail: str, quota: int) -> dict:
|
|
644
|
+
"""
|
|
645
|
+
Function to set additional mail quota for a given mail
|
|
646
|
+
:param mail: the mail to set the quota for
|
|
647
|
+
:param quota: the quota to set
|
|
648
|
+
:return: the response for the request
|
|
649
|
+
"""
|
|
650
|
+
plan = self.mail_get(mail)['plan']
|
|
651
|
+
return self.api_request('mail.set', {'mail': mail, 'plan':plan, 'additional_mail_quota':quota})
|
|
652
|
+
|
|
653
|
+
def mail_set_additional_cloud_quota(self, mail: str, quota: int) -> dict:
|
|
654
|
+
"""
|
|
655
|
+
Function to set additional cloud quota for a given mail
|
|
656
|
+
:param mail: the mail to set the quota for
|
|
657
|
+
:param quota: the quota to set
|
|
658
|
+
:return: the response for the request
|
|
659
|
+
"""
|
|
660
|
+
plan = self.mail_get(mail)['plan']
|
|
661
|
+
return self.api_request('mail.set', {'mail': mail, 'plan': plan,
|
|
662
|
+
'additional_cloud_quota': quota})
|
|
663
|
+
|
|
637
664
|
def mail_set_deletion_date(self, mail: str, deletion_date: str) -> dict:
|
|
638
665
|
"""
|
|
639
666
|
Function to delete an inbox at a given date.
|
|
@@ -794,7 +821,7 @@ class APIClient:
|
|
|
794
821
|
return self.api_request('mail.vacation.get', {'mail':mail})
|
|
795
822
|
|
|
796
823
|
def mail_vacation_set(self, mail: str, subject: str, body: str, start_date: str, end_date: str,
|
|
797
|
-
additional_mail_addresses: list = None) -> dict:
|
|
824
|
+
additional_mail_addresses: list | None = None) -> dict:
|
|
798
825
|
"""
|
|
799
826
|
Function to set the vacation notice for a given mail
|
|
800
827
|
:param mail: the mail to get the vacation notice for
|
|
@@ -814,57 +841,75 @@ class APIClient:
|
|
|
814
841
|
|
|
815
842
|
return self.api_request('mail.vacation.set', params)
|
|
816
843
|
|
|
817
|
-
def group_list(self) -> dict:
|
|
844
|
+
def group_list(self, account:str | None = None) -> dict:
|
|
818
845
|
"""
|
|
819
846
|
Function to list all groups for an account
|
|
847
|
+
:param account: optional parameter for the account to list the groups for
|
|
820
848
|
:return: mailbox API response - the list of groups
|
|
821
849
|
"""
|
|
822
|
-
|
|
850
|
+
params = {}
|
|
851
|
+
if account:
|
|
852
|
+
params['account'] = account
|
|
853
|
+
return self.api_request('group.list', params)
|
|
823
854
|
|
|
824
|
-
def group_get(self, group_id: int) -> dict:
|
|
855
|
+
def group_get(self, group_id: int, account: str | None = None) -> dict:
|
|
825
856
|
"""
|
|
826
857
|
Function to get a group from the account by the group id
|
|
827
858
|
:param group_id: the id of the group to get
|
|
859
|
+
:param account: optional parameter for the account to get the group for
|
|
828
860
|
:return: mailbox API response - the list of groups of the account
|
|
829
861
|
"""
|
|
830
|
-
|
|
862
|
+
params = {'group_id': group_id}
|
|
863
|
+
if account:
|
|
864
|
+
params['account'] = account
|
|
865
|
+
return self.api_request('group.get', params)
|
|
831
866
|
|
|
832
|
-
def group_del(self, group_id: int) -> dict:
|
|
867
|
+
def group_del(self, group_id: int, account: str | None = None) -> dict:
|
|
833
868
|
"""
|
|
834
869
|
Function to delete a group
|
|
835
870
|
:param group_id: the group's id of the group to delete
|
|
871
|
+
:param account: optional parameter for the account to delete the group for
|
|
836
872
|
:return: mailbox API response - True if the group was deleted, False otherwise
|
|
837
873
|
"""
|
|
838
|
-
|
|
874
|
+
params = {'group_id': group_id}
|
|
875
|
+
if account:
|
|
876
|
+
params['account'] = account
|
|
877
|
+
return self.api_request('group.del', params)
|
|
839
878
|
|
|
840
|
-
def group_add(self, name: str, display_name: str, mail_addresses_to_add: list) -> dict:
|
|
879
|
+
def group_add(self, name: str, display_name: str, mail_addresses_to_add: list, account: str | None = None) -> dict:
|
|
841
880
|
"""
|
|
842
881
|
Function to add a group
|
|
843
882
|
:param name: the group name
|
|
844
883
|
:param display_name: the group's display name
|
|
845
884
|
:param mail_addresses_to_add: a list of mail addresses to add
|
|
885
|
+
:param account: optional parameter for the account to add the group for
|
|
846
886
|
:return: mailbox API response - True if the group was added, False otherwise
|
|
847
887
|
"""
|
|
848
|
-
|
|
849
|
-
|
|
888
|
+
params = {'name':name, 'display_name':display_name, 'mail_addresses_to_add':mail_addresses_to_add}
|
|
889
|
+
if account:
|
|
890
|
+
params['account'] = account
|
|
891
|
+
return self.api_request('group.add', params)
|
|
850
892
|
|
|
851
|
-
def group_set(self, group_id: int, display_name: str, mail_addresses_to_add: list = None,
|
|
852
|
-
mail_addresses_to_remove: list = None) -> dict:
|
|
893
|
+
def group_set(self, group_id: int, display_name: str, mail_addresses_to_add: list | None = None,
|
|
894
|
+
mail_addresses_to_remove: list | None = None, account: str | None= None) -> dict:
|
|
853
895
|
"""
|
|
854
896
|
Function to modify a group. Either mail_addresses_to_add or mail_addresses_to_remove have to be specified.
|
|
855
897
|
:param group_id: the group's id of the group to modify
|
|
856
898
|
:param display_name: the group's display name
|
|
857
899
|
:param mail_addresses_to_add: a list of mail addresses to add. Defaults to None
|
|
858
900
|
:param mail_addresses_to_remove: a list of mail addresses to remove. Defaults to None
|
|
901
|
+
:param account: optional parameter for the account to set the group for
|
|
859
902
|
:return: mailbox API response - True if the group was edited, False otherwise
|
|
860
903
|
"""
|
|
861
904
|
# If mail_addresses_to_add and mail_addresses_to_remove are both empty, raise error
|
|
862
905
|
if mail_addresses_to_add is None and mail_addresses_to_remove is None:
|
|
863
906
|
raise ValueError('mail_addresses_to_add or mail_addresses_to_remove are required')
|
|
864
907
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
908
|
+
params = {'group_id':group_id, 'display_name':display_name, 'mail_addresses_to_add':mail_addresses_to_add,
|
|
909
|
+
'mail_addresses_to_remove':mail_addresses_to_remove}
|
|
910
|
+
if account:
|
|
911
|
+
params['account'] = account
|
|
912
|
+
return self.api_request('group.set', params)
|
|
868
913
|
|
|
869
914
|
def mail_passwordreset_listmethods(self, mail: str) -> dict:
|
|
870
915
|
"""
|
|
@@ -921,7 +966,7 @@ class APIClient:
|
|
|
921
966
|
"""
|
|
922
967
|
return self.api_request('mailinglist.list', {'account':account})
|
|
923
968
|
|
|
924
|
-
def mailinglist_add(self, mailinglist: str, password: str, account: str, adminmail: str = None) -> dict:
|
|
969
|
+
def mailinglist_add(self, mailinglist: str, password: str, account: str, adminmail: str | None = None) -> dict:
|
|
925
970
|
"""
|
|
926
971
|
Function to add a mailing list
|
|
927
972
|
:param mailinglist: the mailing list to add
|
|
@@ -942,7 +987,8 @@ class APIClient:
|
|
|
942
987
|
"""
|
|
943
988
|
return self.api_request('mailinglist.get', {'mailinglist':mailinglist, 'account':account})
|
|
944
989
|
|
|
945
|
-
def mailinglist_set(self, mailinglist: str, account: str, password: str
|
|
990
|
+
def mailinglist_set(self, mailinglist: str, account: str, password: str | None = None,
|
|
991
|
+
adminmail: str | None = None) -> dict:
|
|
946
992
|
"""
|
|
947
993
|
Function to change a mailing list
|
|
948
994
|
:param mailinglist: the mailing list to change
|
|
@@ -954,17 +1000,25 @@ class APIClient:
|
|
|
954
1000
|
return self.api_request('mailinglist.set', {'mailinglist':mailinglist, 'account':account,
|
|
955
1001
|
'password':password, 'adminmail':adminmail})
|
|
956
1002
|
|
|
957
|
-
def
|
|
1003
|
+
def mailinglist_del(self, mailinglist: str, account: str) -> dict:
|
|
958
1004
|
"""
|
|
959
1005
|
Function to delete a mailing list
|
|
960
1006
|
:param mailinglist: the mailing list to delete
|
|
961
1007
|
:param account: the account of the mailing list
|
|
962
1008
|
:return: the mailbox API response for the request - True if the mailing list was deleted, error code otherwise
|
|
963
1009
|
"""
|
|
964
|
-
return self.api_request('mailinglist.
|
|
1010
|
+
return self.api_request('mailinglist.del', {'mailinglist':mailinglist, 'account':account})
|
|
1011
|
+
|
|
1012
|
+
def additionalmailaccount_list(self, parent_mail: str) -> dict:
|
|
1013
|
+
"""
|
|
1014
|
+
Function to list all additional mail accounts for a given parent mail
|
|
1015
|
+
:param parent_mail: the parent mail to list additional mail accounts for
|
|
1016
|
+
:return: a dict containing the parent mail account and a list of additional mail accounts
|
|
1017
|
+
"""
|
|
1018
|
+
return self.api_request('additionalmailaccount.list', {'parent_mail':parent_mail})
|
|
965
1019
|
|
|
966
1020
|
def additionalmailaccount_add(self, parent_mail: str, new_account_mail: str, new_account_password: str,
|
|
967
|
-
primary_address: str = None, mail_server: str = 'imap.mailbox.org',
|
|
1021
|
+
primary_address: str | None = None, mail_server: str = 'imap.mailbox.org',
|
|
968
1022
|
mail_port: int = 993, mail_secure: bool = True, mail_starttls: bool = False,
|
|
969
1023
|
transport_server: str = 'smtp.mailbox.org', transport_port: int = 465,
|
|
970
1024
|
transport_secure: bool = True, transport_starttls: bool = False,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mailbox-org-api
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: A library to access the mailbox
|
|
3
|
+
Version: 2.3
|
|
4
|
+
Summary: A library to access the mailbox Business API.
|
|
5
5
|
Author: Hendrik Schlange
|
|
6
6
|
Author-email: Hendrik Schlange <mail@heshsum.de>
|
|
7
7
|
Project-URL: Homepage, https://github.com/heshsum/mailbox-org-api
|
|
@@ -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.3"
|
|
4
4
|
authors = [
|
|
5
5
|
{ name="Hendrik Schlange", email="mail@heshsum.de" },
|
|
6
6
|
]
|
|
7
|
-
description = "A library to access the mailbox
|
|
7
|
+
description = "A library to access the mailbox 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,8 +3,8 @@ from setuptools import find_packages, setup
|
|
|
3
3
|
setup(
|
|
4
4
|
name='mailbox_org_api',
|
|
5
5
|
packages=find_packages(),
|
|
6
|
-
version='2.
|
|
7
|
-
description='A library to access the mailbox
|
|
6
|
+
version='2.3',
|
|
7
|
+
description='A library to access the mailbox Business API',
|
|
8
8
|
author='Hendrik Schlange',
|
|
9
9
|
install_requires=['requests'],
|
|
10
10
|
tests_require=['pytest'],
|
|
@@ -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()
|
|
@@ -289,7 +306,7 @@ class TestAPIClient:
|
|
|
289
306
|
assert returned_mail['mail'] == mail
|
|
290
307
|
api.deauth()
|
|
291
308
|
|
|
292
|
-
@pytest.mark.depends(name=
|
|
309
|
+
@pytest.mark.depends(name='test_mail_add')
|
|
293
310
|
def test_mail_set(self):
|
|
294
311
|
api = APIClient.APIClient()
|
|
295
312
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -302,7 +319,7 @@ class TestAPIClient:
|
|
|
302
319
|
'memo': 'memo_string', 'active': True, 'title': 'Title', 'position': 'Job Position',
|
|
303
320
|
'department': 'Department', 'company': 'Company', 'street': 'Street 1',
|
|
304
321
|
'postal_code': '12345', 'city': 'City', 'phone':'+492345678', 'fax':'+492345678',
|
|
305
|
-
'cell_phone':'+492345678', 'uid_extern':
|
|
322
|
+
'cell_phone':'+492345678', 'uid_extern': 'external_uid_value', 'language': 'de_DE'}
|
|
306
323
|
|
|
307
324
|
# Adding parameters to call
|
|
308
325
|
params = {}
|
|
@@ -311,14 +328,23 @@ class TestAPIClient:
|
|
|
311
328
|
|
|
312
329
|
# Getting mail from API to act as the reference
|
|
313
330
|
check_mail = api.mail_get(mail)
|
|
314
|
-
|
|
331
|
+
print(check_mail)
|
|
315
332
|
# Compare values sent to values received
|
|
316
333
|
for k, v in mail_set_tests.items():
|
|
317
334
|
assert check_mail[k] == v
|
|
318
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
|
+
|
|
319
345
|
api.deauth()
|
|
320
346
|
|
|
321
|
-
@pytest.mark.depends(name=
|
|
347
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
322
348
|
def test_mail_capabilities_set(self):
|
|
323
349
|
capabilities = ['MAIL_SPAMPROTECTION', 'MAIL_BLACKLIST', 'MAIL_BACKUPRECOVER', 'MAIL_PASSWORDRESET_SMS']
|
|
324
350
|
|
|
@@ -352,22 +378,20 @@ class TestAPIClient:
|
|
|
352
378
|
api.auth(api_test_user, api_test_pass)
|
|
353
379
|
mails = api.mail_list(domain)
|
|
354
380
|
mail = mails[0]['mail']
|
|
355
|
-
plans = ['
|
|
381
|
+
plans = ['premium', 'light', 'standard']
|
|
356
382
|
for plan in plans:
|
|
357
383
|
api.mail_set_plan(mail, plan)
|
|
358
384
|
assert str(api.mail_get(mail)['plan']).lower() == plan
|
|
359
|
-
with pytest.raises(APIError):
|
|
360
|
-
api.mail_set_plan(mail, 'light')
|
|
361
385
|
api.deauth()
|
|
362
386
|
|
|
363
|
-
@pytest.mark.depends(name=
|
|
387
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
364
388
|
def test_mail_set_aliases(self):
|
|
365
389
|
api = APIClient.APIClient()
|
|
366
390
|
api.auth(api_test_user, api_test_pass)
|
|
367
391
|
mail = test_id + '@' + domain
|
|
368
392
|
aliases = []
|
|
369
393
|
api.mail_set_aliases(mail, aliases)
|
|
370
|
-
for i in range(0,
|
|
394
|
+
for i in range(0, 2):
|
|
371
395
|
address = test_id + '_alias_' + str(i) + '@' + domain
|
|
372
396
|
aliases.append(address)
|
|
373
397
|
api.mail_set_aliases(mail, aliases)
|
|
@@ -376,7 +400,7 @@ class TestAPIClient:
|
|
|
376
400
|
assert api.mail_get(mail)['aliases'] == []
|
|
377
401
|
api.deauth()
|
|
378
402
|
|
|
379
|
-
@pytest.mark.depends(name=
|
|
403
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
380
404
|
def test_mail_set_forwards(self):
|
|
381
405
|
api = APIClient.APIClient()
|
|
382
406
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -390,7 +414,7 @@ class TestAPIClient:
|
|
|
390
414
|
assert api.mail_get(mail)['forwards'] == forwards
|
|
391
415
|
api.deauth()
|
|
392
416
|
|
|
393
|
-
@pytest.mark.depends(name=
|
|
417
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
394
418
|
def test_mail_set_password(self):
|
|
395
419
|
api = APIClient.APIClient()
|
|
396
420
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -400,7 +424,7 @@ class TestAPIClient:
|
|
|
400
424
|
assert api.mail_set_password(mail, generate_pw()) == api.mail_get(mail)
|
|
401
425
|
api.deauth()
|
|
402
426
|
|
|
403
|
-
@pytest.mark.depends(name=
|
|
427
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
404
428
|
def test_mail_set_password_require_reset(self):
|
|
405
429
|
api = APIClient.APIClient()
|
|
406
430
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -410,7 +434,25 @@ class TestAPIClient:
|
|
|
410
434
|
assert api.mail_set_password_require_reset(mail, generate_pw()) == api.mail_get(mail)
|
|
411
435
|
api.deauth()
|
|
412
436
|
|
|
413
|
-
|
|
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")
|
|
414
456
|
def test_mail_apppassword_add(self):
|
|
415
457
|
api = APIClient.APIClient()
|
|
416
458
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -420,7 +462,7 @@ class TestAPIClient:
|
|
|
420
462
|
assert len(api.mail_apppassword_list(mail)) == len_before + 1
|
|
421
463
|
api.deauth()
|
|
422
464
|
|
|
423
|
-
@pytest.mark.depends(name=
|
|
465
|
+
@pytest.mark.depends(name="test_mail_add")
|
|
424
466
|
def test_mail_apppassword_list(self):
|
|
425
467
|
api = APIClient.APIClient()
|
|
426
468
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -428,9 +470,9 @@ class TestAPIClient:
|
|
|
428
470
|
assert len(api.mail_apppassword_list(mail)) > 0
|
|
429
471
|
api.deauth()
|
|
430
472
|
|
|
431
|
-
@pytest.mark.depends(name=
|
|
432
|
-
@pytest.mark.depends(name=
|
|
433
|
-
@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')
|
|
434
476
|
def test_mail_apppassword_del(self):
|
|
435
477
|
api = APIClient.APIClient()
|
|
436
478
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -445,8 +487,9 @@ class TestAPIClient:
|
|
|
445
487
|
|
|
446
488
|
# After deleting all app passwords, length should be 0
|
|
447
489
|
assert len(api.mail_apppassword_list(mail)) == 0
|
|
490
|
+
api.deauth()
|
|
448
491
|
|
|
449
|
-
@pytest.mark.depends(name=
|
|
492
|
+
@pytest.mark.depends(name='test_mail_add')
|
|
450
493
|
def test_mail_set_deletion_date(self):
|
|
451
494
|
api = APIClient.APIClient()
|
|
452
495
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -457,7 +500,47 @@ class TestAPIClient:
|
|
|
457
500
|
assert deletion_date in api.mail_get(mail)['deletion_date']
|
|
458
501
|
api.deauth()
|
|
459
502
|
|
|
460
|
-
|
|
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')
|
|
461
544
|
def test_search(self):
|
|
462
545
|
api = APIClient.APIClient()
|
|
463
546
|
api.auth(api_test_user, api_test_pass)
|
|
@@ -465,6 +548,7 @@ class TestAPIClient:
|
|
|
465
548
|
assert mail in api.search(mail)['emails']
|
|
466
549
|
assert domain in api.search(domain)['domains']
|
|
467
550
|
assert api_test_user in api.search(api_test_user)['accounts']
|
|
551
|
+
api.deauth()
|
|
468
552
|
|
|
469
553
|
@pytest.mark.order('last')
|
|
470
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
|