Skip to content

Commit 5eb1031

Browse files
committed
Fixes tox dependancies and adds tests for stripping the pkcs5 padding
1 parent 1a68a51 commit 5eb1031

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed

requirements_tox.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
click==6.6
2+
Django==1.10.2
3+
Flask==0.11.1
4+
itsdangerous==0.24
5+
Jinja2==2.8
6+
MarkupSafe==0.23
7+
mock==2.0.0
8+
pbr==1.10.0
9+
pytest==3.0.3
10+
six==1.10.0
11+
tox>=1.7.2
12+
virtualenv==13.1.2
13+
future==0.15.2
14+
Werkzeug==0.11.11
15+
wheel==0.24.0

tox.ini

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,54 @@
11
[tox]
22
envlist = py26,py27,py33,py34,py35,py36
33
{py26,py27,py33,py34,py35,py36}-{oldest,cryptography14,requests26,protobuf30}
4-
py36-macOS
4+
{py26,py36}-macOS
55
py36-macOS-{oldest,cryptography14,requests26,protobuf30}
66
skip_missing_interpreters = True
77

88
[testenv]
99
commands = py.test -c {posargs:pytest.ini}
1010
whitelist_externals = py.test
1111
macOS: env
12-
deps = future011,oldest: future==0.11.0
12+
13+
14+
; Tox doesn't allow us to combine main requirements.txt with specific deps versions,
15+
; since it will result in 'multiple deps error'.
16+
; The solution is to omit those deps in a tox-specific requirements.txt file
17+
; and maintain 2 sets of deps by explicitly stating them in tox.ini
18+
deps =
1319
protobuf30,oldest: protobuf==3.0.0
1420
requests20,oldest: requests==2.0.0
1521
cryptography14,oldest: cryptography==1.4
16-
future013: future>=0.13,<0.14
1722
requests26: requests>=2.6,<2.7
23+
-rrequirements_tox.txt
24+
25+
[testenv:py26]
26+
; Make sure those are the same as in requirements.txt
27+
; they will be used in envs that do not specify specific, older versions of these packages.
28+
deps =
29+
cryptography==1.5.2
30+
protobuf==3.1.0.post1
31+
requests==2.11.1
32+
-rrequirements_tox.txt
1833

19-
[testenv:py36]
2034
platform = win32|linux2|linux|cygwin
2135

36+
[testenv:py27]
37+
deps = {[testenv:py26]deps}
38+
39+
[testenv:py33]
40+
deps = {[testenv:py26]deps}
41+
42+
[testenv:py34]
43+
deps = {[testenv:py26]deps}
44+
45+
[testenv:py35]
46+
deps = {[testenv:py26]deps}
47+
48+
[testenv:py36]
49+
platform = {[testenv:py26]platform}
50+
deps = {[testenv:py26]deps}
51+
2252
[testenv:py36-oldest]
2353
platform = {[testenv:py36]platform}
2454

@@ -38,6 +68,10 @@ platform = {[testenv:py36]platform}
3868
install_command = env LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install {opts} {packages}
3969
platform = darwin
4070

71+
[testenv:py26-macOS]
72+
install_command = {[testenv:macOS]install_command}
73+
platform = {[testenv:macOS]platform}
74+
4175
[testenv:py36-macOS]
4276
install_command = {[testenv:macOS]install_command}
4377
platform = {[testenv:macOS]platform}

yoti/tests/test_crypto.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import pytest
55

6+
from yoti.crypto import Crypto
7+
68

79
@pytest.mark.parametrize('invalid_token', [
810
'',
@@ -22,3 +24,12 @@ def test_given_proper_encrypted_token__decrypting_should_yield_decrypted_token(
2224
decrypted_token = crypto.decrypt_token(encrypted_request_token).decode('utf-8')
2325
assert decrypted_token == expected_token
2426

27+
28+
@pytest.mark.parametrize('with_padding,stripped', [
29+
(b'\xfa\x01', b'\xfa'),
30+
(b'\xfa\x06\x06\x06\x06\x06\x06', b'\xfa'),
31+
(b'\xfa\x08\x08\x08\x08\x08\x08\x08\x08', b'\xfa'),
32+
])
33+
def test_strip_pkcs5_padding(with_padding, stripped):
34+
assert Crypto.strip_pkcs5_padding(with_padding) == stripped
35+

0 commit comments

Comments
 (0)