Permalink
Browse files

tests: Add crypto patches, fix unit tests.

  • Loading branch information...
kblin committed Dec 3, 2009
1 parent 16b41b0 commit 523a7479021c808acc3da7f838e9fc8d2c53662f
Showing with 52 additions and 8 deletions.
  1. +3 −0 development.ini
  2. +4 −1 test.ini
  3. +8 −7 wombat/lib/app_globals.py
  4. +37 −0 wombat/tests/test_crypto.py
View
@@ -54,6 +54,9 @@ create_superuser = true
smtpserver = localhost
email_from = wombat@localhost
+# Allow to disable the updater helper threads (only useful for running tests)
+multithreading = true
+
# Logging configuration
[loggers]
keys = root, routes, wombat
View
@@ -19,8 +19,11 @@ port = 5000
use = config:development.ini
# Add additional test specific configuration options as necessary.
-sqlalchemy.default.url = sqlite:///%(here)s/data/test_repository.db
+sqlalchemy.url = sqlite:///%(here)s/data/test_repository.db
create_superuser = false
+multithreading = false
+
smtpserver = fake.example.com
+
View
@@ -16,12 +16,13 @@ def __init__(self):
"""
self.version = "0.5.0pre1"
- self.last_cleanup = "Never"
- self.cleanup_timer = Timer(60.0, cleanup_dbs, [self])
- self.cleanup_timer.start()
+ if config['app_conf']['multithreading'] == "true":
+ self.last_cleanup = "Never"
+ self.cleanup_timer = Timer(60.0, cleanup_dbs, [self])
+ self.cleanup_timer.start()
- self.scan_lock = Lock()
+ self.scan_lock = Lock()
- self.update_status = "Never updated"
- self.update_timer = Timer(30.0, update_media, [self])
- self.update_timer.start()
+ self.update_status = "Never updated"
+ self.update_timer = Timer(30.0, update_media, [self])
+ self.update_timer.start()
@@ -0,0 +1,37 @@
+# Copyright (C) 2009 by Kai Blin
+#
+# WOMBAT is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+
+from wombat.lib.auth import crypt_password, parse_pass, check_password
+
+def test_parse_pass():
+ password = u"{method}$SALTSALT$PASSWORDPASSWORD"
+ method, salt, crypt = parse_pass(password)
+ assert method == "{method}", "failed to parse method"
+ assert salt == "SALTSALT", "failed to parse salt"
+ assert crypt == "PASSWORDPASSWORD"
+
+def test_password_MD5():
+ pass_string = crypt_password("secret")
+ method, salt, crypt = parse_pass(pass_string)
+ assert method == "{MD5}", "method is %s, not {MD5}" % method
+ assert salt is not None, "salt is None"
+ assert crypt is not None, "crypt is None"
+
+def test_check_password_MD5():
+ pass_string = crypt_password("secret")
+ assert check_password(pass_string, "secret"), "Password verification failed"
+
+
+

0 comments on commit 523a747

Please sign in to comment.