-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/mfa' of https://github.com/albertogeniola/Meros…
…sIot into development-0.4.X.X
- Loading branch information
Showing
5 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,9 @@ | |
from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop | ||
|
||
from meross_iot.http_api import MerossHttpClient | ||
from meross_iot.model.http.exception import BadLoginException, BadDomainException | ||
from tests import async_get_client, _TEST_EMAIL, _TEST_PASSWORD, _TEST_API_BASE_URL | ||
from meross_iot.model.http.error_codes import ErrorCodes | ||
from meross_iot.model.http.exception import BadLoginException, BadDomainException, HttpApiError, MissingMFA, WrongMFA | ||
from tests import async_get_client, _TEST_EMAIL, _TEST_PASSWORD, _TEST_API_BASE_URL, _TEST_EMAIL_MFA | ||
|
||
if os.name == 'nt': | ||
import asyncio | ||
|
@@ -48,9 +49,46 @@ async def test_subdevice_listing(self): | |
async def test_bad_login(self): | ||
with self.assertRaises(BadLoginException): | ||
return await MerossHttpClient.async_from_user_password(api_base_url=_TEST_API_BASE_URL, | ||
email="[email protected]", | ||
email=_TEST_EMAIL, | ||
password="thisIzWRONG!") | ||
|
||
@unittest_run_loop | ||
async def test_not_existing_email(self): | ||
with self.assertRaises(HttpApiError): | ||
try: | ||
return await MerossHttpClient.async_from_user_password(api_base_url=_TEST_API_BASE_URL, | ||
email="[email protected]", | ||
password="thisIzWRONG!") | ||
except HttpApiError as e: | ||
self.assertEqual(e.error_code, ErrorCodes.CODE_WRONG_EMAIL) | ||
raise e | ||
|
||
@unittest_run_loop | ||
async def test_bad_email(self): | ||
with self.assertRaises(HttpApiError): | ||
try: | ||
return await MerossHttpClient.async_from_user_password(api_base_url=_TEST_API_BASE_URL, | ||
email="invalidemail", | ||
password="somePassword") | ||
except HttpApiError as e: | ||
self.assertEqual(e.error_code, ErrorCodes.CODE_WRONG_EMAIL) | ||
raise e | ||
|
||
@unittest_run_loop | ||
async def test_missing_mfa(self): | ||
with self.assertRaises(MissingMFA): | ||
return await MerossHttpClient.async_from_user_password(api_base_url=_TEST_API_BASE_URL, | ||
email=_TEST_EMAIL_MFA, | ||
password=_TEST_PASSWORD) | ||
|
||
@unittest_run_loop | ||
async def test_wrong_mfa(self): | ||
with self.assertRaises(WrongMFA): | ||
return await MerossHttpClient.async_from_user_password(api_base_url=_TEST_API_BASE_URL, | ||
email=_TEST_EMAIL_MFA, | ||
password=_TEST_PASSWORD, | ||
mfa_code="invalid") | ||
|
||
@unittest_run_loop | ||
async def test_device_listing(self): | ||
devices = await self.meross_client.async_list_devices() | ||
|
@@ -61,7 +99,7 @@ async def test_device_listing(self): | |
@unittest_run_loop | ||
async def test_bad_domain(self): | ||
with self.assertRaises(BadDomainException): | ||
return await MerossHttpClient.async_from_user_password(api_base_url=_TEST_API_BASE_URL, email=_TEST_EMAIL, password=_TEST_PASSWORD, auto_retry_on_bad_domain=False) | ||
return await MerossHttpClient.async_from_user_password(api_base_url="iot.meross.com", email=_TEST_EMAIL, password=_TEST_PASSWORD, auto_retry_on_bad_domain=False) | ||
|
||
|
||
@unittest_run_loop | ||
|