Skip to content

Commit

Permalink
Version 0.3.0
Browse files Browse the repository at this point in the history
Refactoring som importing of bankid is sufficient.
Preparation for PyPi deployment
  • Loading branch information
hbldh committed Nov 17, 2015
1 parent b9f62a2 commit eecf9d8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 41 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ exists and can be found in deployed state on `Heroku <https://bankid-example-app

Installation
------------
To install PyBankID, install it from this GitHub repository via pip:
PyBankID can be installed though pip:

.. code-block:: bash
pip install git+https://github.com/hbldh/pybankid.git#egg=pybankid
pip install pybankid
Usage
-----
Expand All @@ -34,7 +34,7 @@ First, create a BankIDClient:

.. code-block:: python
>>> from bankid.client import BankIDClient
>>> from bankid import BankIDClient
>>> client = BankIDClient(certificates=('path/to/certificate.pem',
'path/to/key.pem'))
Expand Down
39 changes: 22 additions & 17 deletions bankid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
# -*- coding: utf-8 -*-
"""Release data for the PyBankID project."""

from .client import BankIDClient
import bankid.exceptions as exceptions
from .testcert import create_bankid_test_server_cert_and_key

__all__ = ['BankIDClient', 'exceptions', 'create_bankid_test_server_cert_and_key', 'version']

# Name of the package for release purposes. This is the name which labels
# the tarballs and RPMs made by distutils, so it's best to lowercase it.
name = 'pybankid'
_name = 'pybankid'

# Version information. An empty _version_extra corresponds to a full
# release. 'dev' as a _version_extra string means this is a development
# version.
_version_major = 0
_version_minor = 2
_version_patch = 2
_version_minor = 3
_version_patch = 0
# _version_extra = 'dev4'
# _version_extra = 'b2'
# _version_extra = 'a1'
_version_extra = '' # Uncomment this for full releases

# Construct full version string from these.
Expand All @@ -26,9 +32,9 @@
version = __version__ # backwards compatibility name
version_info = (_version_major, _version_minor, _version_patch, _version_extra)

description = "BankID client for Python"
_description = "BankID client for Python"

long_description = """
_long_description = """
PyBankID is a client for performing BankID signing.
The Swedish BankID solution for digital signing uses a SOAP
Expand All @@ -38,24 +44,23 @@
The latest development version is available at the project's `GitHub
site <https://github.com/hbldh/pybankid/>`_.
"""

license = 'MIT'
__license__ = 'MIT'

authors = {
_authors = {
'hbldh': ('Henrik Blidh', 'henrik.blidh@nedomkull.com'),
}
author = 'Henrik Blidh'
author_email = 'henrik.blidh@nedomkull.com'
url = 'https://github.com/hbldh/pybankid/'
download_url = 'https://github.com/hbldh/pybankid/downloads'
_author = 'Henrik Blidh'
_author_email = 'henrik.blidh@nedomkull.com'
_url = 'https://github.com/hbldh/pybankid/'
_download_url = 'https://github.com/hbldh/pybankid/tarball/' + '.'.join(map(str, _ver))

platforms = ['Linux', 'Mac OSX', 'Windows XP/Vista/7/8']
keywords = ['BankID', 'SOAP']
classifiers = [
_platforms = ['Linux', 'Mac OSX', 'Windows XP/Vista/7/8']
_keywords = ['BankID', 'SOAP']
_classifiers = [
'Programming Language :: Python',
'Programming Language :: Python :: 2'
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
Expand Down
11 changes: 6 additions & 5 deletions bankid/testcert.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from __future__ import absolute_import

import os
import re
import tempfile
import subprocess
import sys
Expand All @@ -29,7 +28,7 @@
_TEST_CERT_URL = "https://www.bankid.com/assets/bankid/rp/FPTestcert2_20150818_102329.pfx"


def create_test_server_cert_and_key(destination_path):
def create_bankid_test_server_cert_and_key(destination_path):
"""Fetch the P12 certificate from BankID servers, split it into
a certificate part and a key part and save them as separate files,
stored in PEM format.
Expand All @@ -48,8 +47,10 @@ def create_test_server_cert_and_key(destination_path):
certificate, key = split_test_cert_and_key()

# Paths to output files.
out_cert_path = os.path.join(os.path.abspath(destination_path), 'cert.pem')
out_key_path = os.path.join(os.path.abspath(destination_path), 'key.pem')
out_cert_path = os.path.join(os.path.abspath(
os.path.expanduser(destination_path)), 'cert.pem')
out_key_path = os.path.join(os.path.abspath(
os.path.expanduser(destination_path)), 'key.pem')

with open(out_cert_path, 'wt') as f:
f.write(certificate)
Expand Down Expand Up @@ -120,7 +121,7 @@ def split_test_cert_and_key():


def main():
paths = create_test_server_cert_and_key(os.path.expanduser('~'))
paths = create_bankid_test_server_cert_and_key(os.path.expanduser('~'))
print('Saved certificate as {0}'.format(paths[0]))
print('Saved key as {0}'.format(paths[1]))

Expand Down
24 changes: 14 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@
setup(
name='pybankid',
version=bankid.__version__,
author=bankid.author,
author_email=bankid.author_email,
description=bankid.description,
long_description=bankid.long_description,
license=bankid.license,
url=bankid.url,
classifiers=bankid.classifiers,
platforms=bankid.platforms,
packages=find_packages(),
author=bankid._author,
author_email=bankid._author_email,
description=bankid._description,
long_description=bankid._long_description,
license=bankid.__license__,
url=bankid._url,
classifiers=bankid._classifiers,
platforms=bankid._platforms,
packages=find_packages(exclude=('tests', )),
package_data={'': ['*.pem']},
install_requires=[line.strip() for line in open("requirements.txt")],
install_requires=[
'requests>=2.7.0',
'suds-jurko>=0.6',
'six>=1.9.0'
],
dependency_links=[],
ext_modules=[],
entry_points={
Expand Down
10 changes: 4 additions & 6 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

from nose.tools import raises

import bankid.client
import bankid.testcert
import bankid.exceptions
import bankid


def get_random_personal_number():
Expand Down Expand Up @@ -76,7 +74,7 @@ def __init__(self):
self.key_file = None

def setup(self):
certificate, key = bankid.testcert.create_test_server_cert_and_key(tempfile.gettempdir())
certificate, key = bankid.create_bankid_test_server_cert_and_key(tempfile.gettempdir())
self.certificate_file = certificate
self.key_file = key

Expand All @@ -90,7 +88,7 @@ def teardown(self):
def test_authentication_and_collect(self):
"""Authenticate call and then collect with the returned orderRef UUID."""

c = bankid.client.BankIDClient(certificates=(self.certificate_file, self.key_file), test_server=True)
c = bankid.BankIDClient(certificates=(self.certificate_file, self.key_file), test_server=True)
out = c.authenticate(get_random_personal_number())
assert isinstance(out, dict)
# UUID.__init__ performs the UUID compliance assertion.
Expand All @@ -100,7 +98,7 @@ def test_authentication_and_collect(self):

@raises(bankid.exceptions.InvalidParametersError)
def test_invalid_orderref_raises_error(self):
c = bankid.client.BankIDClient(certificates=(self.certificate_file, self.key_file), test_server=True)
c = bankid.BankIDClient(certificates=(self.certificate_file, self.key_file), test_server=True)
collect_status = c.collect('invalid-uuid')

@raises(bankid.exceptions.AlreadyInProgressError)
Expand Down

0 comments on commit eecf9d8

Please sign in to comment.