2013-10-19 00:47:24 +02:00
|
|
|
"""
|
|
|
|
|
This file demonstrates writing tests using the unittest module. These will pass
|
|
|
|
|
when you run "manage.py test".
|
|
|
|
|
|
|
|
|
|
Replace this with more appropriate tests for your application.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from django.test import TestCase
|
2013-10-27 21:14:30 +01:00
|
|
|
from password_encryption import encrypt_ldap_password, decrypt_ldap_password
|
2013-10-19 00:47:24 +02:00
|
|
|
|
2013-10-27 21:14:30 +01:00
|
|
|
class PasswordEncryptionTest(TestCase):
|
2013-10-27 21:13:41 +01:00
|
|
|
"""
|
|
|
|
|
Test for the cbmi apps.
|
|
|
|
|
"""
|
|
|
|
|
TEST_LDAP_PASSWD = 'correcthorsebatterystaple'
|
2013-10-19 00:47:24 +02:00
|
|
|
|
2013-10-27 21:13:41 +01:00
|
|
|
def encrypt_it(self):
|
|
|
|
|
return encrypt_ldap_password(self.TEST_LDAP_PASSWD)
|
|
|
|
|
|
|
|
|
|
def test_encrypt_ldap_password(self):
|
|
|
|
|
message, key = self.encrypt_it()
|
|
|
|
|
print 'key:', key
|
|
|
|
|
print 'message:', message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_decrypt_ldap_password(self):
|
|
|
|
|
message, key = self.encrypt_it()
|
|
|
|
|
decrypted = decrypt_ldap_password(message, key)
|
|
|
|
|
self.assertEqual(self.TEST_LDAP_PASSWD, decrypted)
|