mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
820 python 3 only (#1454)
* Remove Python 2 specific code * Require imports to have a proper isort-supported order * Only test/lint on Python 3 * Bump most dependencies to latest supported version
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
import string
|
||||
|
||||
import six
|
||||
|
||||
from CTFd.utils.encoding import base64decode, base64encode, hexdecode, hexencode
|
||||
|
||||
|
||||
@@ -27,50 +25,23 @@ def test_hexdecode():
|
||||
|
||||
def test_base64encode():
|
||||
"""The base64encode wrapper works properly"""
|
||||
if six.PY2:
|
||||
assert base64encode("abc123") == "YWJjMTIz"
|
||||
assert base64encode(unicode("abc123")) == "YWJjMTIz" # noqa: F821
|
||||
assert (
|
||||
base64encode(
|
||||
unicode( # noqa: F821
|
||||
'"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4'
|
||||
)
|
||||
)
|
||||
== "InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ"
|
||||
)
|
||||
assert base64encode("user+user@ctfd.io") == "dXNlcit1c2VyQGN0ZmQuaW8"
|
||||
assert base64encode("😆") == "8J-Yhg"
|
||||
else:
|
||||
assert base64encode("abc123") == "YWJjMTIz"
|
||||
assert (
|
||||
base64encode('"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4')
|
||||
== "InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ"
|
||||
)
|
||||
assert base64encode("user+user@ctfd.io") == "dXNlcit1c2VyQGN0ZmQuaW8"
|
||||
assert base64encode("😆") == "8J-Yhg"
|
||||
assert base64encode("abc123") == "YWJjMTIz"
|
||||
assert (
|
||||
base64encode('"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4')
|
||||
== "InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ"
|
||||
)
|
||||
assert base64encode("user+user@ctfd.io") == "dXNlcit1c2VyQGN0ZmQuaW8"
|
||||
assert base64encode("😆") == "8J-Yhg"
|
||||
|
||||
|
||||
def test_base64decode():
|
||||
"""The base64decode wrapper works properly"""
|
||||
if six.PY2:
|
||||
assert base64decode("YWJjMTIz") == "abc123"
|
||||
assert base64decode(unicode("YWJjMTIz")) == "abc123" # noqa: F821
|
||||
assert (
|
||||
base64decode(
|
||||
unicode( # noqa: F821
|
||||
"InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ"
|
||||
)
|
||||
)
|
||||
== '"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4'
|
||||
assert base64decode("YWJjMTIz") == "abc123"
|
||||
assert (
|
||||
base64decode(
|
||||
"InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ"
|
||||
)
|
||||
assert base64decode("8J-Yhg") == "😆"
|
||||
else:
|
||||
assert base64decode("YWJjMTIz") == "abc123"
|
||||
assert (
|
||||
base64decode(
|
||||
"InRlc3RAbWFpbGluYXRvci5jb20iLkRHeGVvQS5sQ3NzVTNNMlF1QmZvaE8tRnRkZ0RRTEtiVTQ"
|
||||
)
|
||||
== '"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4'
|
||||
)
|
||||
assert base64decode("dXNlcit1c2VyQGN0ZmQuaW8") == "user+user@ctfd.io"
|
||||
assert base64decode("8J-Yhg") == "😆"
|
||||
== '"test@mailinator.com".DGxeoA.lCssU3M2QuBfohO-FtdgDQLKbU4'
|
||||
)
|
||||
assert base64decode("dXNlcit1c2VyQGN0ZmQuaW8") == "user+user@ctfd.io"
|
||||
assert base64decode("8J-Yhg") == "😆"
|
||||
|
||||
Reference in New Issue
Block a user