Skip to content

Commit f8b063b

Browse files
authored
Merge pull request #89 from web-push-libs/chore/2021-03-update
chore: Update dependencies & tests
2 parents 6699d06 + 0d8b708 commit f8b063b

File tree

11 files changed

+64
-80
lines changed

11 files changed

+64
-80
lines changed

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

python/README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
`PyPI version py_vapid <https://pypi.org/project/py-vapid/>`__
21

32
Easy VAPID generation
43
=====================
@@ -95,3 +94,6 @@ that some User Agents may require you `to decode this string into a
9594
Uint8Array <https://github.com/GoogleChrome/push-notifications/blob/master/app/scripts/main.js>`__.
9695

9796
See ``bin/vapid -h`` for all options and commands.
97+
98+
.. |PyPI version py_vapid| image:: https://badge.fury.io/py/py-vapid.svg
99+
:target: https://pypi.org/project/py-vapid/

python/claims.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"sub": "mailto:[email protected]",
3-
"aud": "https://push.services.mozilla.com",
4-
"exp": "1463001340"
3+
"aud": "https://push.services.mozilla.com"
54
}
65

python/py_vapid/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def from_file(cls, private_key_file=None):
110110
111111
"""
112112
if not os.path.isfile(private_key_file):
113+
logging.info("Private key not found, generating key...")
113114
vapid = cls()
114115
vapid.generate_keys()
115116
vapid.save_key(private_key_file)

python/py_vapid/tests/test_vapid.py

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import json
66
import unittest
77
from cryptography.hazmat.primitives import serialization
8-
from nose.tools import eq_, ok_
98
from mock import patch, Mock
109

1110
from py_vapid import Vapid01, Vapid02, VapidException
@@ -49,7 +48,7 @@
4948
).strip('=').encode('utf8')
5049

5150

52-
def setUp(self):
51+
def setup_module(self):
5352
with open('/tmp/private', 'w') as ff:
5453
ff.write(TEST_KEY_PRIVATE_PEM)
5554
with open('/tmp/public', 'w') as ff:
@@ -58,16 +57,16 @@ def setUp(self):
5857
ff.write(TEST_KEY_PRIVATE_DER)
5958

6059

61-
def tearDown(self):
60+
def teardown_module(self):
6261
os.unlink('/tmp/private')
6362
os.unlink('/tmp/public')
6463

6564

6665
class VapidTestCase(unittest.TestCase):
6766
def check_keys(self, v):
68-
eq_(v.private_key.private_numbers().private_value, key.get('d'))
69-
eq_(v.public_key.public_numbers().x, key.get('x'))
70-
eq_(v.public_key.public_numbers().y, key.get('y'))
67+
assert v.private_key.private_numbers().private_value == key.get('d')
68+
assert v.public_key.public_numbers().x == key.get('x')
69+
assert v.public_key.public_numbers().y == key.get('y')
7170

7271
def test_init(self):
7372
v1 = Vapid01.from_file("/tmp/private")
@@ -80,7 +79,7 @@ def test_init(self):
8079
self.check_keys(v4)
8180
no_exist = '/tmp/not_exist'
8281
Vapid01.from_file(no_exist)
83-
ok_(os.path.isfile(no_exist))
82+
assert os.path.isfile(no_exist)
8483
os.unlink(no_exist)
8584

8685
def repad(self, data):
@@ -95,8 +94,8 @@ def test_init_bad_read(self, mm):
9594
def test_gen_key(self):
9695
v = Vapid01()
9796
v.generate_keys()
98-
ok_(v.public_key)
99-
ok_(v.private_key)
97+
assert v.public_key
98+
assert v.private_key
10099

101100
def test_private_key(self):
102101
v = Vapid01()
@@ -105,8 +104,8 @@ def test_private_key(self):
105104

106105
def test_public_key(self):
107106
v = Vapid01()
108-
eq_(v._private_key, None)
109-
eq_(v._public_key, None)
107+
assert v._private_key is None
108+
assert v._public_key is None
110109

111110
def test_save_key(self):
112111
v = Vapid01()
@@ -135,7 +134,7 @@ def test_sign_01(self):
135134
claims = {"aud": "https://example.com",
136135
"sub": "mailto:[email protected]"}
137136
result = v.sign(claims, "id=previous")
138-
eq_(result['Crypto-Key'],
137+
assert result['Crypto-Key'] == (
139138
'id=previous;p256ecdsa=' + TEST_KEY_PUBLIC_RAW.decode('utf8'))
140139
pkey = binascii.b2a_base64(
141140
v.public_key.public_bytes(
@@ -145,16 +144,16 @@ def test_sign_01(self):
145144
).decode('utf8').replace('+', '-').replace('/', '_').strip()
146145
items = decode(result['Authorization'].split(' ')[1], pkey)
147146
for k in claims:
148-
eq_(items[k], claims[k])
147+
assert items[k] == claims[k]
149148
result = v.sign(claims)
150-
eq_(result['Crypto-Key'],
151-
'p256ecdsa=' + TEST_KEY_PUBLIC_RAW.decode('utf8'))
149+
assert result['Crypto-Key'] == ('p256ecdsa=' +
150+
TEST_KEY_PUBLIC_RAW.decode('utf8'))
152151
# Verify using the same function as Integration
153152
# this should ensure that the r,s sign values are correctly formed
154-
ok_(Vapid01.verify(
153+
assert Vapid01.verify(
155154
key=result['Crypto-Key'].split('=')[1],
156155
auth=result['Authorization']
157-
))
156+
)
158157

159158
def test_sign_02(self):
160159
v = Vapid02.from_file("/tmp/private")
@@ -164,20 +163,20 @@ def test_sign_02(self):
164163
claim_check = copy.deepcopy(claims)
165164
result = v.sign(claims, "id=previous")
166165
auth = result['Authorization']
167-
eq_(auth[:6], 'vapid ')
168-
ok_(' t=' in auth)
169-
ok_(',k=' in auth)
166+
assert auth[:6] == 'vapid '
167+
assert ' t=' in auth
168+
assert ',k=' in auth
170169
parts = auth[6:].split(',')
171-
eq_(len(parts), 2)
170+
assert len(parts) == 2
172171
t_val = json.loads(base64.urlsafe_b64decode(
173172
self.repad(parts[0][2:].split('.')[1])
174173
).decode('utf8'))
175174
k_val = binascii.a2b_base64(self.repad(parts[1][2:]))
176-
eq_(binascii.hexlify(k_val)[:2], b'04')
177-
eq_(len(k_val), 65)
178-
eq_(claims, claim_check)
175+
assert binascii.hexlify(k_val)[:2] == b'04'
176+
assert len(k_val) == 65
177+
assert claims == claim_check
179178
for k in claims:
180-
eq_(t_val[k], claims[k])
179+
assert t_val[k] == claims[k]
181180

182181
def test_sign_02_localhost(self):
183182
v = Vapid02.from_file("/tmp/private")
@@ -186,9 +185,9 @@ def test_sign_02_localhost(self):
186185
"foo": "extra value"}
187186
result = v.sign(claims, "id=previous")
188187
auth = result['Authorization']
189-
eq_(auth[:6], 'vapid ')
190-
ok_(' t=' in auth)
191-
ok_(',k=' in auth)
188+
assert auth[:6] == 'vapid '
189+
assert ' t=' in auth
190+
assert ',k=' in auth
192191

193192
def test_integration(self):
194193
# These values were taken from a test page. DO NOT ALTER!
@@ -199,8 +198,8 @@ def test_integration(self):
199198
"4cCI6MTQ5NDY3MTQ3MCwic3ViIjoibWFpbHRvOnNpbXBsZS1wdXNoLWRlb"
200199
"W9AZ2F1bnRmYWNlLmNvLnVrIn0.LqPi86T-HJ71TXHAYFptZEHD7Wlfjcc"
201200
"4u5jYZ17WpqOlqDcW-5Wtx3x1OgYX19alhJ9oLumlS2VzEvNioZolQA")
202-
ok_(Vapid01.verify(key=key, auth="webpush {}".format(auth)))
203-
ok_(Vapid02.verify(auth="vapid t={},k={}".format(auth, key)))
201+
assert Vapid01.verify(key=key, auth="webpush {}".format(auth))
202+
assert Vapid02.verify(auth="vapid t={},k={}".format(auth, key))
204203

205204
def test_bad_integration(self):
206205
# These values were taken from a test page. DO NOT ALTER!
@@ -211,7 +210,7 @@ def test_bad_integration(self):
211210
"4cCI6MTQ5NDY3MTQ3MCwic3ViIjoibWFpbHRvOnNpbXBsZS1wdXNoLWRlb"
212211
"W9AZ2F1bnRmYWNlLmNvLnVrIn0.LqPi86T-HJ71TXHAYFptZEHD7Wlfjcc"
213212
"4u5jYZ17WpqOlqDcW-5Wtx3x1OgYX19alhJ9oLumlS2VzEvNioZ_BAD")
214-
eq_(Vapid01.verify(key=key, auth=auth), False)
213+
assert Vapid01.verify(key=key, auth=auth) == False
215214

216215
def test_bad_sign(self):
217216
v = Vapid01.from_file("/tmp/private")

python/setup.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from setuptools import setup, find_packages
55

6-
__version__ = "1.7.1"
6+
__version__ = "1.8.0"
77

88

99
def read_from(file):
@@ -24,31 +24,27 @@ def read_from(file):
2424
here = os.path.abspath(os.path.dirname(__file__))
2525
with io.open(os.path.join(here, 'README.rst'), encoding='utf8') as f:
2626
README = f.read()
27-
with io.open(os.path.join(here, 'CHANGELOG.md'), encoding='utf8') as f:
28-
CHANGES = f.read()
27+
#with io.open(os.path.join(here, 'CHANGELOG.md'), encoding='utf8') as f:
28+
# CHANGES = f.read()
2929

3030
setup(name="py-vapid",
3131
version=__version__,
3232
description='Simple VAPID header generation library',
33-
long_description=README + '\n\n' + CHANGES,
33+
long_description=README,
34+
long_description_content_type="text/x-rst",
3435
classifiers=["Topic :: Internet :: WWW/HTTP",
3536
"Programming Language :: Python",
36-
"Programming Language :: Python :: 2",
37-
"Programming Language :: Python :: 2.7",
3837
"Programming Language :: Python :: 3",
39-
"Programming Language :: Python :: 3.4",
40-
"Programming Language :: Python :: 3.5",
4138
],
4239
keywords='vapid push webpush',
4340
author="JR Conlin",
4441
author_email="[email protected]",
4542
url='https://github.com/mozilla-services/vapid',
4643
license="MPL2",
47-
test_suite="nose.collector",
4844
include_package_data=True,
4945
zip_safe=False,
5046
packages=find_packages(),
51-
package_data={'': ['README.md', 'CHANGELOG.md',
47+
package_data={'': ['README.rst', 'CHANGELOG.rst',
5248
'requirements.txt', 'test-requirements.txt']},
5349
install_requires=read_from('requirements.txt'),
5450
tests_require=read_from('test-requirements.txt'),

python/test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
nose
1+
-r requirements.txt
2+
pytest
23
coverage
34
mock>=1.0.1
45
flake8

python/upload.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
# Package the current branch up to pypi
33
# remember to update the README.rst file
4-
pandoc --from=markdown --to=rst --output README.rst README.md
5-
bin/python setup.py sdist
6-
bin/twine upload dist/*
4+
#pandoc --from=markdown --to=rst --output README.rst README.md
5+
#pandoc --from=markdown --to=rst --output CHANGELOG.rst CHANGELOG.md
6+
venv/bin/python setup.py sdist
7+
venv/bin/twine upload dist/* --verbose

rust/vapid/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vapid"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = ["jrconlin <[email protected]>"]
55
edition = "2018"
66
description = "An implementation of the RFC 8292 Voluntary Application Server Identification (VAPID) Auth header generator"
@@ -10,6 +10,6 @@ license = "MPL 2.0"
1010
[dependencies]
1111
openssl = "0.10"
1212
serde_json = "1.0"
13-
base64 = "0.10"
14-
time = "0.1"
13+
base64 = "0.13"
14+
time = "0.2"
1515
failure = "0.1"

rust/vapid/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum VapidErrorKind {
2323
}
2424

2525
impl Fail for VapidError {
26-
fn cause(&self) -> Option<&Fail> {
26+
fn cause(&self) -> Option<&dyn Fail> {
2727
self.inner.cause()
2828
}
2929

0 commit comments

Comments
 (0)