-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,398 additions
and
1,344 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[pytest] | ||
pythonpath = src | ||
pythonpath = src test |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# pylint: disable=missing-module-docstring | ||
TEST_DATA = "test_data.json" |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# pylint: disable=missing-module-docstring, missing-class-docstring, missing-function-docstring | ||
import json | ||
import random | ||
|
||
import pytest | ||
import random_info | ||
from config import TEST_DATA | ||
from epg.authenticator import Authenticator, AuthMethod | ||
from epg.credential import Credential | ||
from epg.utils import EvaluateTools, reverse | ||
|
||
|
||
def test_reverse(): | ||
with pytest.raises(TypeError) as excinfo: | ||
reverse("", "", AuthMethod.SALTED_MD5) | ||
assert "missing required positional argument: 'salt'" in str(excinfo.value) | ||
with pytest.raises(ValueError) as excinfo: | ||
reverse("", "", -1) | ||
assert "Invalid auth method" in str(excinfo.value) | ||
with open(TEST_DATA, "r", encoding="utf-8") as file: | ||
for authenticator_set in json.loads(file.read()): | ||
_credential = authenticator_set["credential"] | ||
credential = Credential( | ||
_credential["token"], | ||
_credential["user_id"], | ||
_credential["password"], | ||
_credential["ip"], | ||
_credential["mac"], | ||
_credential["product_id"], | ||
_credential["ctc"], | ||
) | ||
print(AuthMethod[authenticator_set["method"]]) | ||
print(authenticator_set["salt"]) | ||
assert Credential.dumps( | ||
reverse( | ||
_credential["password"], | ||
authenticator_set["info"], | ||
AuthMethod[authenticator_set["method"]], | ||
authenticator_set["salt"], | ||
) | ||
) == Credential.dumps(credential) | ||
|
||
|
||
def test_EvaluateTools(): | ||
credential = random_info.credential() | ||
salt = f"{random.randint(1,9999):05d}" | ||
assert salt in EvaluateTools().test_salt( | ||
credential, | ||
Authenticator(credential, AuthMethod.SALTED_MD5, salt).info, | ||
5, | ||
) |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# pylint: disable=missing-module-docstring, missing-class-docstring, missing-function-docstring | ||
from config import TEST_DATA | ||
from test_data import batch_generate | ||
|
||
with open("test_data.json", "w", encoding="utf-8") as file: | ||
with open(TEST_DATA, "w", encoding="utf-8") as file: | ||
file.write(batch_generate()) |
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
Oops, something went wrong.