# Path: wsse/settings.py
# TIMESTAMP_DURATION = 2 * 60 * 60
# DRIFT_OFFSET = 2 * 60
# TIMESTAMP_FORMATS = [
# 	'%Y-%m-%dT%H:%M:%SZ',    # ISO 8601 in UTC (Z specifies 0 offset)
# 	'%Y-%m-%dT%H:%M:%S',     # ISO 8601 without timezone - assumed to be UTC
# 	'%Y-%m-%dT%H:%M:%S.%fZ', # ISO 8601 with microseconds in UTC
# 	'%Y-%m-%dT%H:%M:%S.%f',  # ISO 8601 with microseconds (assumed UTC)
# 	'%Y-%m-%dT%H:%M:%S%z',   # ISO 8601 with UTC offset
# 	'%Y-%m-%dT%H:%M:%S.%f%z' # ISO 8601 with microseconds and UTC offset
# 	]
# NONCE_LENGTH = 64
# NONCE_STORE = 'wsse.server.default.store.SQLiteNonceStore'
# NONCE_STORE_ARGS = (':memory:',)
# REQUEST_HEADER = 'X-WSSE'
# SECURITY_CHECK_NONCE = True
# SECURITY_CHECK_TIMESTAMP = True
# ALLOWED_DIGEST_ALGORITHMS = ['SHA256']
# PROHIBITED_DIGEST_ALGORITHMS = ['SHA1', 'MD5']
# SECRET_KEY_LENGTH = 64
# LOGGER_NAME = 'wsse'
# 
# Path: wsse/compat.py

# 
# Path: wsse/server/django/wsse/models.py
# class UserSecret(models.Model):
# 	'''
# 	The `UserSecret` object connects every user to their secret key. The secret
# 	key can be deleted to prevent access without affecting the user.
# 	'''
# 	user = models.OneToOneField(User, on_delete = models.CASCADE,
# 		db_index = True)
# 	secret = models.CharField(max_length = settings.SECRET_KEY_LENGTH,
# 		default = _generate_secret, blank = True, null = False)
# 
# Path: wsse/client/coreapi/transport.py
# class WSSEAuthenticatedHTTPTransport(HTTPTransport):
# 	'''
# 	Attaches the HTTP Digest authentication to the headers.
# 
# 	Usage:
# 
# 		transport = WSSEAuthenticatedHTTPTransport(username, password)
# 		client = coreapi.Client(transports = [transport])
# 
# 	The transport can be re-used; it will automatically generate new tokens on a
# 	per-request basis.
# 
# 	:param username: username to authenticate as
# 	:type username: str
# 
# 	:param password: password to authenticate with
# 	:type password: str
# 	'''
# 	def __init__(self, username, password, *args, **kwargs):
# 		self._token_builder = utils.TokenBuilder(username, password)
# 		super(WSSEAuthenticatedHTTPTransport, self).__init__(*args, **kwargs)
# 
# 	@property
# 	def headers(self):
# 		h = super(WSSEAuthenticatedHTTPTransport, self).headers
# 		return h.set(settings.REQUEST_HEADER, self._token_builder.make_token())


from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.contrib.auth.models import User
from rest_framework import status
from coreapi import Client
from coreapi.exceptions import ErrorMessage
from wsse import settings
from wsse.compat import reverse_lazy
from wsse.server.django.wsse.models import UserSecret
from wsse.client.coreapi.transport import WSSEAuthenticatedHTTPTransport
# wsse/client/coreapi/tests/test_transport.py
# coding=utf-8
# pywsse
# Authors: Rushy Panchal, Naphat Sanguansin, Adam Libresco, Jérémie Lumbroso
# Date: September 1st, 2016
# Description: Test the coreapi authenticated transport implementation



def setUpModule():
	'''
	Set up the module for running tests.
	'''
	# Set the nonce store to the Django store after saving the current settings
	# so they can be restored later.
	global __old_nonce_settings
	__old_nonce_settings = (settings.NONCE_STORE, settings.NONCE_STORE_ARGS)

	settings.NONCE_STORE = 'wsse.server.django.wsse.store.DjangoNonceStore'
	settings.NONCE_STORE_ARGS = []

def tearDownModule():
	'''
	Tear down the module after running tests.
	'''
	# Restore the nonce settings.

# Path: wsse/settings.py
# TIMESTAMP_DURATION = 2 * 60 * 60
# DRIFT_OFFSET = 2 * 60
# TIMESTAMP_FORMATS = [
# 	'%Y-%m-%dT%H:%M:%SZ',    # ISO 8601 in UTC (Z specifies 0 offset)
# 	'%Y-%m-%dT%H:%M:%S',     # ISO 8601 without timezone - assumed to be UTC
# 	'%Y-%m-%dT%H:%M:%S.%fZ', # ISO 8601 with microseconds in UTC
# 	'%Y-%m-%dT%H:%M:%S.%f',  # ISO 8601 with microseconds (assumed UTC)
# 	'%Y-%m-%dT%H:%M:%S%z',   # ISO 8601 with UTC offset
# 	'%Y-%m-%dT%H:%M:%S.%f%z' # ISO 8601 with microseconds and UTC offset
# 	]
# NONCE_LENGTH = 64
# NONCE_STORE = 'wsse.server.default.store.SQLiteNonceStore'
# NONCE_STORE_ARGS = (':memory:',)
# REQUEST_HEADER = 'X-WSSE'
# SECURITY_CHECK_NONCE = True
# SECURITY_CHECK_TIMESTAMP = True
# ALLOWED_DIGEST_ALGORITHMS = ['SHA256']
# PROHIBITED_DIGEST_ALGORITHMS = ['SHA1', 'MD5']
# SECRET_KEY_LENGTH = 64
# LOGGER_NAME = 'wsse'
# 
# Path: wsse/compat.py

# 
# Path: wsse/server/django/wsse/models.py
# class UserSecret(models.Model):
# 	'''
# 	The `UserSecret` object connects every user to their secret key. The secret
# 	key can be deleted to prevent access without affecting the user.
# 	'''
# 	user = models.OneToOneField(User, on_delete = models.CASCADE,
# 		db_index = True)
# 	secret = models.CharField(max_length = settings.SECRET_KEY_LENGTH,
# 		default = _generate_secret, blank = True, null = False)
# 
# Path: wsse/client/coreapi/transport.py
# class WSSEAuthenticatedHTTPTransport(HTTPTransport):
# 	'''
# 	Attaches the HTTP Digest authentication to the headers.
# 
# 	Usage:
# 
# 		transport = WSSEAuthenticatedHTTPTransport(username, password)
# 		client = coreapi.Client(transports = [transport])
# 
# 	The transport can be re-used; it will automatically generate new tokens on a
# 	per-request basis.
# 
# 	:param username: username to authenticate as
# 	:type username: str
# 
# 	:param password: password to authenticate with
# 	:type password: str
# 	'''
# 	def __init__(self, username, password, *args, **kwargs):
# 		self._token_builder = utils.TokenBuilder(username, password)
# 		super(WSSEAuthenticatedHTTPTransport, self).__init__(*args, **kwargs)
# 
# 	@property
# 	def headers(self):
# 		h = super(WSSEAuthenticatedHTTPTransport, self).headers
# 		return h.set(settings.REQUEST_HEADER, self._token_builder.make_token())


# Path: wsse/client/coreapi/tests/test_transport.py
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.contrib.auth.models import User
from rest_framework import status
from coreapi import Client
from coreapi.exceptions import ErrorMessage
from wsse import settings
from wsse.compat import reverse_lazy
from wsse.server.django.wsse.models import UserSecret
from wsse.client.coreapi.transport import WSSEAuthenticatedHTTPTransport

# wsse/client/coreapi/tests/test_transport.py
# coding=utf-8
# pywsse
# Authors: Rushy Panchal, Naphat Sanguansin, Adam Libresco, Jérémie Lumbroso
# Date: September 1st, 2016
# Description: Test the coreapi authenticated transport implementation



def setUpModule():
	'''
	Set up the module for running tests.
	'''
	# Set the nonce store to the Django store after saving the current settings
	# so they can be restored later.
	global __old_nonce_settings
	__old_nonce_settings = (settings.NONCE_STORE, settings.NONCE_STORE_ARGS)

	settings.NONCE_STORE = 'wsse.server.django.wsse.store.DjangoNonceStore'
	settings.NONCE_STORE_ARGS = []

def tearDownModule():
	'''
	Tear down the module after running tests.
	'''
	# Restore the nonce settings.

	settings.NONCE_STORE, settings.NONCE_STORE_ARGS = __old_nonce_settings