|
@@ -4,6 +4,11 @@ import socket
|
|
import tempfile
|
|
import tempfile
|
|
import unittest
|
|
import unittest
|
|
|
|
|
|
|
|
+try:
|
|
|
|
+ from hashlib import sha1
|
|
|
|
+except ImportError:
|
|
|
|
+ from sha import new as sha1
|
|
|
|
+
|
|
from supervisor.tests.base import DummySupervisor
|
|
from supervisor.tests.base import DummySupervisor
|
|
from supervisor.tests.base import PopulatedDummySupervisor
|
|
from supervisor.tests.base import PopulatedDummySupervisor
|
|
from supervisor.tests.base import DummyRPCInterfaceFactory
|
|
from supervisor.tests.base import DummyRPCInterfaceFactory
|
|
@@ -271,19 +276,11 @@ class EncryptedDictionaryAuthorizedTests(unittest.TestCase):
|
|
self.assertEqual(authorizer.authorize(('foo', 'password')), True)
|
|
self.assertEqual(authorizer.authorize(('foo', 'password')), True)
|
|
|
|
|
|
def test_authorize_gooduser_badpassword_sha(self):
|
|
def test_authorize_gooduser_badpassword_sha(self):
|
|
- try:
|
|
|
|
- from hashlib import sha1
|
|
|
|
- except ImportError:
|
|
|
|
- from sha import new as sha1
|
|
|
|
password = '{SHA}' + sha1('password').hexdigest()
|
|
password = '{SHA}' + sha1('password').hexdigest()
|
|
authorizer = self._makeOne({'foo':password})
|
|
authorizer = self._makeOne({'foo':password})
|
|
self.assertEqual(authorizer.authorize(('foo', 'bar')), False)
|
|
self.assertEqual(authorizer.authorize(('foo', 'bar')), False)
|
|
|
|
|
|
def test_authorize_gooduser_goodpassword_sha(self):
|
|
def test_authorize_gooduser_goodpassword_sha(self):
|
|
- try:
|
|
|
|
- from hashlib import sha1
|
|
|
|
- except ImportError:
|
|
|
|
- from sha import new as sha1
|
|
|
|
password = '{SHA}' + sha1('password').hexdigest()
|
|
password = '{SHA}' + sha1('password').hexdigest()
|
|
authorizer = self._makeOne({'foo':password})
|
|
authorizer = self._makeOne({'foo':password})
|
|
self.assertEqual(authorizer.authorize(('foo', 'password')), True)
|
|
self.assertEqual(authorizer.authorize(('foo', 'password')), True)
|