Skip to content

Commit f87f209

Browse files
committed
Setup the environment. Connect with travis and coverall. Fix pep8
1 parent a920a7b commit f87f209

13 files changed

Lines changed: 146 additions & 25 deletions

File tree

.coveralls.yml

Whitespace-only changes.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ __pycache_
1212
/.installed.cfg
1313
/develop-eggs
1414
/*.eg
15-
/*.egg-info
15+
*.egg-info
1616
/eggs
1717
/build
1818
/dist
1919
/venv
20+
.coverage
2021

2122
*.key
2223
*.crt

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: python
2+
python:
3+
- '2.6'
4+
- '2.7'
5+
6+
before_install:
7+
- 'travis_retry sudo apt-get install python-dev libxml2-dev libxmlsec1-dev'
8+
9+
install:
10+
- 'travis_retry pip install -e ".[test]" --use-mirrors'
11+
12+
script:
13+
- 'coverage run --source=src/onelogin/saml2 --rcfile=tests/coverage.rc setup.py test'
14+
- 'coverage report -m --rcfile=tests/coverage.rc'
15+
- 'pep8 tests/src/OneLogin/saml2_tests/*.py demo-flask/*.py demo-django/*.py src/onelogin/saml2/*.py --config=tests/pep8.rc'
16+
- 'pyflakes src/onelogin/saml2 demo-django demo-flask tests/src/OneLogin/saml2_tests'
17+
18+
after_success: 'coveralls --rcfile=.coveralls.yml'

setup.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright (c) 2014, OneLogin, Inc.
55
# All rights reserved.
66

7-
from setuptools import setup, find_packages
7+
from setuptools import setup
88

99
setup(
1010
name='python-saml',
@@ -21,27 +21,24 @@
2121
author_email='support@onelogin.com',
2222
license='BSD',
2323
url='https://github.com/onelogin/python-saml',
24-
packages = ['onelogin/saml2'],
24+
packages=['onelogin/saml2'],
2525
package_dir={
2626
'': 'src',
27-
},
27+
},
2828
test_suite='tests',
2929
install_requires=[
3030
'M2Crypto==0.22.3',
3131
'dm.xmlsec.binding==1.3.1',
3232
'isodate==0.5.0',
3333
'defusedxml==0.4.1',
34-
]
34+
],
3535
extras_require={
3636
'test': (
37-
# Test runner.
38-
'pytest',
39-
40-
# Ensure PEP8 conformance.
41-
'pytest-pep8',
42-
43-
# Ensure test coverage.
44-
'pytest-cov',
45-
)
46-
}
37+
'coverage==3.7.1',
38+
'pylint==1.3.1',
39+
'pep8==1.5.7',
40+
'pyflakes==0.8.1',
41+
'coveralls==0.4.4',
42+
),
43+
},
4744
)

src/onelogin/saml2/response.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ def is_valid(self, request_data, request_id=None):
118118
if not destination.startswith(current_url):
119119
# TODO: Review if following lines are required, since we can control the
120120
# request_data
121-
#current_url_routed = OneLogin_Saml2_Utils.get_self_routed_url_no_query(request_data)
122-
#if not destination.startswith(current_url_routed):
121+
# current_url_routed = OneLogin_Saml2_Utils.get_self_routed_url_no_query(request_data)
122+
# if not destination.startswith(current_url_routed):
123123
raise Exception('The response was received at %s instead of %s' % (current_url, destination))
124124

125125
# Checks audience
@@ -352,7 +352,7 @@ def validate_timestamps(self):
352352
:rtype: bool
353353
"""
354354
conditions_nodes = self.__query_assertion('/saml:Conditions')
355-
355+
356356
for conditions_node in conditions_nodes:
357357
nb_attr = conditions_node.get('NotBefore')
358358
nooa_attr = conditions_node.get('NotOnOrAfter')

src/onelogin/saml2/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ def validate_metadata(self, xml):
580580
else:
581581
dom = res
582582
element = dom.documentElement
583-
if not element.tagName in 'md:EntityDescriptor':
583+
if element.tagName not in 'md:EntityDescriptor':
584584
errors.append('noEntityDescriptor_xml')
585585
else:
586586
if len(element.getElementsByTagName('md:SPSSODescriptor')) != 1:

src/onelogin/saml2/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def generate_name_id(value, sp_nq, sp_format, cert=None, debug=False):
593593
enc_data = EncData(xmlsec.TransformAes128Cbc, type=xmlsec.TypeEncElement)
594594
enc_data.ensureCipherValue()
595595
key_info = enc_data.ensureKeyInfo()
596-
#enc_key = key_info.addEncryptedKey(xmlsec.TransformRsaPkcs1)
596+
# enc_key = key_info.addEncryptedKey(xmlsec.TransformRsaPkcs1)
597597
enc_key = key_info.addEncryptedKey(xmlsec.TransformRsaOaep)
598598
enc_key.ensureCipherValue()
599599

tests/coverage.rc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[run]
2+
branch = True
3+
4+
omit =
5+
6+
[paths]
7+
source = src/onelogin/saml2
8+
9+
[report]
10+
# Regexes for lines to exclude from consideration
11+
exclude_lines =
12+
13+
14+
# Have to re-enable the standard pragma
15+
pragma: no cover
16+
17+
# Don't complain about missing debug-only code:
18+
def __repr__
19+
if self\.debug
20+
if debug
21+
22+
# Don't complain if tests don't hit defensive assertion code:
23+
raise AssertionError
24+
raise NotImplementedError
25+
26+
# Don't complain if non-runnable code isn't run:
27+
if 0:
28+
if __name__ == .__main__.:
29+
30+
ignore_errors = True

tests/pep8.rc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pep8]
2+
ignore = E501
3+
max-line-length = 160

tests/pylint.rc

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[MASTER]
2+
profile=no
3+
persistent=yes
4+
ignore=
5+
cache-size=500
6+
7+
[REPORTS]
8+
output-format=text
9+
files-output=no
10+
reports=yes
11+
12+
[BASIC]
13+
no-docstring-rgx=__.*__|_.*
14+
class-rgx=[A-Z_][a-zA-Z0-9_]+$
15+
function-rgx=[a-zA_][a-zA-Z0-9_]{2,70}$
16+
method-rgx=[a-z_][a-zA-Z0-9_]{2,70}$
17+
const-rgx=(([A-Z_][A-Z0-9_]*)|([a-z_][a-z0-9_]*)|(__.*__)|register|urlpatterns)$
18+
good-names=_,i,j,k,e,qs,pk,setUp,tearDown,el,ns,fd,js
19+
20+
[TYPECHECK]
21+
22+
# Tells whether missing members accessed in mixin class should be ignored. A
23+
# mixin class is detected if its name ends with "mixin" (case insensitive).
24+
ignore-mixin-members=yes
25+
26+
# List of module names for which member attributes should not be checked
27+
# (useful for modules/projects where namespaces are manipulated during runtime
28+
# and thus extisting member attributes cannot be deduced by static analysis
29+
ignored-modules=
30+
31+
# List of classes names for which member attributes should not be checked
32+
# (useful for classes with attributes dynamically set).
33+
ignored-classes=SQLObject,WSGIRequest
34+
35+
# When zope mode is activated, add a predefined set of Zope acquired attributes
36+
# to generated-members.
37+
zope=no
38+
39+
# List of members which are set dynamically and missed by pylint inference
40+
# system, and so shouldn't trigger E0201 when accessed.
41+
generated-members=objects,DoesNotExist,id,pk,_meta,base_fields,context,views,save
42+
43+
# List of method names used to declare (i.e. assign) instance attributes
44+
defining-attr-methods=__init__,__new__,setUp
45+
46+
[VARIABLES]
47+
init-import=no
48+
dummy-variables-rgx=_|dummy
49+
50+
[SIMILARITIES]
51+
min-similarity-lines=6
52+
ignore-comments=yes
53+
ignore-docstrings=yes
54+
[MISCELLANEOUS]
55+
notes=FIXME,XXX,TODO
56+
57+
[FORMAT]
58+
max-line-length=160
59+
max-module-lines=500
60+
indent-string=' '
61+
indent-after-paren=4
62+
63+
[DESIGN]
64+
max-args=10
65+
max-locals=15
66+
max-returns=6
67+
max-branchs=12
68+
max-statements=50
69+
max-parents=10
70+
max-attributes=10
71+
min-public-methods=0
72+
max-public-methods=100
73+

0 commit comments

Comments
 (0)