aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/buildbot-0.8.8-py2.7.egg/buildbot/test/unit/test_status_web_auth_HTPasswdAuth.py
blob: d27dc193271ae4be80ba9b68057d6c416315a119 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# This file is part of Buildbot.  Buildbot 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.
#
# 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 Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright Buildbot Team Members
"""
Test Passwords
desbuildmaster:yifux5rkzvI5w
desbuildslave:W8SPURMnCs7Tc
desbuildbot:IzclhyfHAq6Oc
"""


from twisted.trial import unittest

from buildbot.status.web.auth import HTPasswdAuth
from buildbot.test.util import compat

class TestHTPasswdAuth(unittest.TestCase):

    htpasswd = HTPasswdAuth(__file__)

    @compat.skipUnlessPlatformIs('posix') # crypt module
    def test_authenticate_des(self):
        for key in ('buildmaster','buildslave','buildbot'):                
            if self.htpasswd.authenticate('des'+key, key) == False:
                self.fail("authenticate failed for '%s'" % ('des'+key))

    def test_authenticate_unknown(self):
        if self.htpasswd.authenticate('foo', 'bar') == True:
            self.fail("authenticate succeed for 'foo:bar'")

    @compat.skipUnlessPlatformIs('posix') # crypt module
    def test_authenticate_wopassword(self):
        for algo in ('des','md5','sha'):
            if self.htpasswd.authenticate(algo+'buildmaster', '') == True:
                self.fail("authenticate succeed for %s w/o password"
                                        % (algo+'buildmaster'))

    @compat.skipUnlessPlatformIs('posix') # crypt module
    def test_authenticate_wrongpassword(self):
        for algo in ('des','md5','sha'):
            if self.htpasswd.authenticate(algo+'buildmaster', algo) == True:
                self.fail("authenticate succeed for %s w/ wrong password"
                                        % (algo+'buildmaster'))