Esempio n. 1
0
File: auth.py Progetto: zxfly/trac
    def test_extra_entries_ignored(self):
        """Extra entries and comments are ignored."""
        with open(self.filename, 'w') as fd:
            fd.write("crypt:PgjnZnmDQ8S7w:User One #comment\n")
            fd.write("md5:$apr1$PjxHNVvY$41a7qPozEZ1b47OomFoos/:User Two \n")
            fd.write("sha:{SHA}2PRZAyDhNDqRW2OUFwZQqPNdaSY=:User Three #\n")

        auth = BasicAuthentication(self.filename, 'realm')
        self.assertTrue(auth.test('crypt', 'crypt'))
        self.assertFalse(auth.test('crypt', 'other'))
        self.assertTrue(auth.test('md5', 'md5'))
        self.assertFalse(auth.test('md5', 'other'))
        self.assertTrue(auth.test('sha', 'sha'))
        self.assertFalse(auth.test('sha', 'other'))
Esempio n. 2
0
class BasicAuthenticationTestCase(unittest.TestCase):
    def setUp(self):
        filename = os.path.join(os.path.split(__file__)[0], 'htpasswd.txt')
        self.auth = BasicAuthentication(filename, 'realm')

    def tearDown(self):
        self.auth = None

    def test_crypt(self):
        self.assertTrue(self.auth.test('crypt', 'crypt'))
        self.assertFalse(self.auth.test('crypt', 'other'))

    def test_md5(self):
        self.assertTrue(self.auth.test('md5', 'md5'))
        self.assertFalse(self.auth.test('md5', 'other'))

    def test_sha(self):
        self.assertTrue(self.auth.test('sha', 'sha'))
        self.assertFalse(self.auth.test('sha', 'other'))
Esempio n. 3
0
class BasicAuthenticationTestCase(unittest.TestCase):
    def setUp(self):
        filename = os.path.join(os.path.split(__file__)[0], 'htpasswd.txt')
        self.auth = BasicAuthentication(filename, 'realm')

    def tearDown(self):
        self.auth = None

    def test_crypt(self):
        self.assert_(self.auth.test('crypt', 'crypt'))
        self.assert_(not self.auth.test('crypt', 'other'))

    def test_md5(self):
        self.assert_(self.auth.test('md5', 'md5'))
        self.assert_(not self.auth.test('md5', 'other'))

    def test_sha(self):
        self.assert_(self.auth.test('sha', 'sha'))
        self.assert_(not self.auth.test('sha', 'other'))
Esempio n. 4
0
File: auth.py Progetto: zxfly/trac
 def test_sha(self):
     self._write_default_htpasswd()
     auth = BasicAuthentication(self.filename, 'realm')
     self.assertTrue(auth.test('sha', 'sha'))
     self.assertFalse(auth.test('sha', 'other'))
Esempio n. 5
0
 def setUp(self):
     filename = os.path.join(os.path.split(__file__)[0], 'htpasswd.txt')
     self.auth = BasicAuthentication(filename, 'realm')
Esempio n. 6
0
 def setUp(self):
     filename = os.path.join(os.path.split(__file__)[0], 'htpasswd.txt')
     self.auth = BasicAuthentication(filename, 'realm')
Esempio n. 7
0
def application(environ, start_application):
    auth = {"*" : BasicAuthentication("/var/trac/users", "realm")}
    wsgi_app = AuthenticationMiddleware(dispatch_request, auth)
    return wsgi_app(environ, start_application)
Esempio n. 8
0
def application(environ, start_application):
    auth = {"*": BasicAuthentication("/etc/nginx/conf.d/users", "admin")}
    wsgi_app = AuthenticationMiddleware(dispatch_request, auth)
    return wsgi_app(environ, start_application)