Skip to content

Commit

Permalink
Merge pull request #14 from samstav/bump-version
Browse files Browse the repository at this point in the history
bump cryptography and requests-chef version
  • Loading branch information
stavxyz committed Apr 25, 2016
2 parents 0e70e7b + 3af3dd7 commit 4ce4b21
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 74 deletions.
7 changes: 4 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ machine:

dependencies:
override:
- pip install tox
- pip install python-coveralls
- pip install -U pip
- pip install -U tox tox-pyenv python-coveralls
- pyenv local 2.7.9 3.4.3 3.5.0

test:
override:
- env PATH="$HOME/bin:$PATH" tox
- tox -v
post:
- mkdir -p $CIRCLE_ARTIFACTS/coverage
- mkdir -p $CIRCLE_TEST_REPORTS/xunit
Expand Down
16 changes: 12 additions & 4 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
[Messages Control]
# W0511: TODOs in code comments are fine.
# W0142: *args and **kwargs are fine.
disable=W0511,W0142
disable=
bad-builtin,
locally-disabled,
fixme

[BASIC]
# Don't require docstrings on tests or Python Special Methods
no-docstring-rgx=(__.*__|[tT]est.*|setUp|tearDown)
no-docstring-rgx=(__.*__|[tT]est.*|setUp|tearDown)
# Some names we are okay with
good-names=f,e,i,j,k,v,ex,_,x,y,z

[REPORTS]
msg-template={msg_id}({symbol}): {path},{line}: {msg} | {obj}
reports=yes
output-format=colorized
4 changes: 2 additions & 2 deletions requests_chef/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
__title__ = 'requests-chef'
__summary__ = 'Chef Authentication protocol support for Python-Requests'
__url__ = 'https://github.com/samstav/requests-chef'
__version__ = '0.1.5'
__version__ = '0.1.6'
__author__ = 'Sam Stavinoha'
__email__ = 'samuel.stavinoha@rackspace.com'
__keywords__ = ['opscode', 'chef', 'requests', 'authentication', 'auth']
__license__ = 'Apache License, Version 2.0'
__copyright__ = 'Copyright 2015 Sam Stavinoha'
__copyright__ = 'Copyright 2015-2016 Sam Stavinoha'
2 changes: 2 additions & 0 deletions requests_chef/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=wildcard-import

"""requests-chef."""

Expand Down
2 changes: 1 addition & 1 deletion requests_chef/mixlib_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def splitter(iterable, chunksize=60):
for i in range(0, len(iterable), chunksize))


class ChefAuth(requests.auth.AuthBase):
class ChefAuth(requests.auth.AuthBase): # pylint: disable=R0903

"""Sign requests with user's private key.
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
git+https://github.com/samstav/cryptography.git@rsa-bypass-hash-on-signer
requests>=2.7.0
six>=1.9.0
git+https://github.com/samstav/cryptography.git@rsa-bypass-hash-on-signer#egg=cryptography==1.3.1f
requests==2.9.1
six==1.10.0
20 changes: 10 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=invalid-name,wrong-import-order

"""requests-chef packaging, installation, and package attributes."""

import os
import setuptools
import subprocess
import sys

from setuptools import find_packages
from setuptools import setup


src_dir = os.path.dirname(os.path.realpath(__file__))


about = {}
with open(os.path.join(src_dir, 'requests_chef', '__about__.py')) as abt:
exec(abt.read(), about)
exec(abt.read(), {'__builtins__': {}}, about) # pylint: disable=exec-used


# pandoc --from=markdown_github --to=rst README.md --output=README.rst
Expand All @@ -41,16 +42,16 @@


INSTALL_REQUIRES = [
'cryptography==1.0.1f',
'cryptography==1.3.1f',
'requests>=2.7.0',
'six>=1.9.0',
]


# cryptography==1.0.1f is not on pypi, so provide a link
# cryptography==1.3.1f is not on pypi, so provide a link
DEPENDENCY_LINKS = [
('https://github.com/samstav/cryptography'
'/tarball/rsa-bypass-hash-on-signer#egg=cryptography-1.0.1f'),
'/tarball/rsa-bypass-hash-on-signer#egg=cryptography-1.3.1f'),
]


Expand All @@ -75,7 +76,6 @@

# Add the commit hash to the keywords for sanity.
if any(k in ' '.join(sys.argv).lower() for k in ['upload', 'dist']):
import subprocess
try:
current_commit = subprocess.check_output(
['git', 'rev-parse', 'HEAD']).strip()
Expand All @@ -96,7 +96,7 @@
'tests_require': TESTS_REQUIRE,
'test_suite': 'tests',
'install_requires': INSTALL_REQUIRES,
'packages': find_packages(exclude=['tests']),
'packages': setuptools.find_packages(exclude=['tests']),
'author': about['__author__'],
'author_email': about['__email__'],
'classifiers': CLASSIFIERS,
Expand All @@ -105,4 +105,4 @@
}


setup(**package_attributes)
setuptools.setup(**package_attributes)
44 changes: 23 additions & 21 deletions tests/test_requests_chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

def ascii_digest(n=1024):
# digest of some random text/data
chars = ''.join([random.choice(string.ascii_letters)
for _ in xrange(n)])
chars = u''.join([random.choice(string.ascii_letters)
for _ in range(n)]).encode()
return hashlib.sha1(chars).hexdigest()


Expand All @@ -34,7 +34,7 @@ class TestChefAuth(unittest.TestCase):
@classmethod
def setUpClass(self):
self.user = 'patsy'
with open(TEST_PEM, 'r') as pkey:
with open(TEST_PEM, 'rb') as pkey:
pkey = pkey.read()
self.private_key = serialization.load_pem_private_key(
pkey,
Expand Down Expand Up @@ -70,27 +70,27 @@ def utcnow(cls):
def assert_xops_headers(self, request):
self.assertEqual(
request.headers['X-Ops-Authorization-1'],
'nRO82dpi5XCH9AC2xM0iPzMBSpmLbazJaPa70X8h27KxRUYEEKUUBTcoM7zg'
b'nRO82dpi5XCH9AC2xM0iPzMBSpmLbazJaPa70X8h27KxRUYEEKUUBTcoM7zg'
)
self.assertEqual(
request.headers['X-Ops-Authorization-2'],
'P2FJQ3ppu3K9r8arv/fnenx2Lt6VK4rQivzrDFpsh3yuDLW3lJaXe2Co4yPA'
b'P2FJQ3ppu3K9r8arv/fnenx2Lt6VK4rQivzrDFpsh3yuDLW3lJaXe2Co4yPA'
)
self.assertEqual(
request.headers['X-Ops-Authorization-3'],
'X67KCw6otyrUFwSblVEdAVRp5K3QlHrmVUzqGQyEMZNS2XCmdfVT7dswacso'
b'X67KCw6otyrUFwSblVEdAVRp5K3QlHrmVUzqGQyEMZNS2XCmdfVT7dswacso'
)
self.assertEqual(
request.headers['X-Ops-Authorization-4'],
'BuNG89DBAtSF3epxq/G9LqrrUOWywfm7L8iIk8hjr1fFTioWbsvhkB7jmopa'
b'BuNG89DBAtSF3epxq/G9LqrrUOWywfm7L8iIk8hjr1fFTioWbsvhkB7jmopa'
)
self.assertEqual(
request.headers['X-Ops-Authorization-5'],
'LPEwUUFrkAf1o3RfxkawYbVdCJBj3Qja9qVlkTXE/ECVhi+uc+V1ThJZtkIH'
b'LPEwUUFrkAf1o3RfxkawYbVdCJBj3Qja9qVlkTXE/ECVhi+uc+V1ThJZtkIH'
)
self.assertEqual(
request.headers['X-Ops-Authorization-6'],
'QGLcWHWLeiHMJMLZYKLW26NoDmwVPohANflsTEU9xQ=='
b'QGLcWHWLeiHMJMLZYKLW26NoDmwVPohANflsTEU9xQ=='
)

def test_from_string(self):
Expand Down Expand Up @@ -129,15 +129,17 @@ def test_rsakey_handles_text(self):
rsakey = requests_chef.RSAKey(self.private_key)
data = six.text_type(self.data)
result = rsakey.sign(data)
expected = ('MiCicRdNBa6hLya65Mtlp0mPr+1X01pW/mvXL6b'
'JLXi9QpJExAvX2OzqJ/oDRU/m+OMGoU7x3MOHi2'
'pJNtPcG4+3bs7mr9yzF9CvFas5+UzgvH2R3ooFy'
'GuEv1kTVPk6ul1ws6LewX+2DV1X6YXj0gJwO2UP'
'jt9wIho5LI+oKfCU1YcyfhKIpEruiMFqjWUKyqr'
'/teC80q6q1ku5sDhO7JQQbkEHgzxcF4Bxcm06Ku'
'rNJ+gYLHkPchQJKYPr6Ty024xwIJ5lg2Qm3a3cK'
'L70cEu7vM65Eru2JCbpmybjYwLhJmcyLHipyxlE'
'oD9r1ZzBjv5PAEoc3Ayba8d4B1A6bQ==')
expected = six.b(
'MiCicRdNBa6hLya65Mtlp0mPr+1X01pW/mvXL6b'
'JLXi9QpJExAvX2OzqJ/oDRU/m+OMGoU7x3MOHi2'
'pJNtPcG4+3bs7mr9yzF9CvFas5+UzgvH2R3ooFy'
'GuEv1kTVPk6ul1ws6LewX+2DV1X6YXj0gJwO2UP'
'jt9wIho5LI+oKfCU1YcyfhKIpEruiMFqjWUKyqr'
'/teC80q6q1ku5sDhO7JQQbkEHgzxcF4Bxcm06Ku'
'rNJ+gYLHkPchQJKYPr6Ty024xwIJ5lg2Qm3a3cK'
'L70cEu7vM65Eru2JCbpmybjYwLhJmcyLHipyxlE'
'oD9r1ZzBjv5PAEoc3Ayba8d4B1A6bQ=='
)
self.assertEqual(expected, result)

def test_repr(self):
Expand Down Expand Up @@ -199,7 +201,7 @@ def test_from_requests_chef_rsakey_from_path(self):
encryption_algorithm=serialization.NoEncryption()
)
sfx = 'requests-chef-tests.pem'
with tempfile.NamedTemporaryFile(suffix=sfx, mode='w') as pem:
with tempfile.NamedTemporaryFile(suffix=sfx, mode='wb') as pem:
pem.write(serialized_key)
pem.flush()
rsakey = requests_chef.RSAKey.load_pem(pem.name)
Expand Down Expand Up @@ -252,12 +254,12 @@ def setUp(self):
self.expected_result = 'yZtNP9J1L//viv+CGWLGgUZof48='

def test_handles_binary(self):
data = six.binary_type(self.data)
data = six.b(self.data)
result = requests_chef.mixlib_auth.digester(data)
self.assertEqual(self.expected_result, result)

def test_handles_text(self):
data = six.text_type(self.data, encoding='utf_8')
data = six.u(self.data)
result = requests_chef.mixlib_auth.digester(data)
self.assertEqual(self.expected_result, result)

Expand Down
41 changes: 11 additions & 30 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
[tox]
# Only the following setting are valid in this section and in the Jenkins section
# https://tox.readthedocs.org/en/latest/config.html#tox-global-settings
envlist = py27,py34,py35,style

# minversion=ver # minimally required tox version
# toxworkdir=path # tox working directory, defaults to {toxinidir}/.tox
# setupdir=path # defaults to {toxinidir}
# distdir=path # defaults to {toxworkdir}/dist
# distshare=path # defaults to {homedir}/.tox/distshare
# envlist=ENVLIST # defaults to the list of all environments
# skipsdist=BOOL # defaults to false
envlist = py27
skipsdist = True


##############
# DEFAULT #
##############
[testenv]
# This is the default setup. All other environments will inherit these settings
usedevelop = True
install_command = pip install --verbose --pre --exists-action=w {opts} {packages}
basepython = python
pyflake_codes = F401,F402,F403,F404,F811,F812,F821,F822,F823,F831,F841

# pull in dependencies from our pip-* files
install_command = pip install --verbose -U --pre {opts} {packages}
deps= -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt

commands=
nosetests {posargs} --with-doctest --with-coverage --cover-html --cover-package=requests_chef --cover-html-dir=coverage/ --with-xunit
flake8 --select="{[testenv]pyflake_codes}" {posargs:requests_chef}
flake8 --exit-zero -j 1 {posargs:requests_chef}
/bin/bash -c 'pylint requests_chef --rcfile=pylintrc || exit 0'
python -c "import sys;print('\nPYTHON VERSION\n%s\n' % sys.version)"
nosetests {posargs} --verbose --with-doctest --with-coverage --cover-html --cover-package=requests_chef --cover-html-dir=coverage/ --with-xunit

[testenv:style]
basepython = python2.7
commands =
flake8 requests_chef setup.py --statistics
flake8 tests --statistics --ignore D100,D101,D102
pylint requests_chef setup.py


[flake8]
#flake8 default settings
exclude = tests
max-complexity = 12

0 comments on commit 4ce4b21

Please sign in to comment.