chiark / gitweb /
update copyright date
[disorder] / tests / hashes.py
... / ...
CommitLineData
1#! /usr/bin/env python
2#
3# This file is part of DisOrder.
4# Copyright (C) 2009 Richard Kettlewell
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19import dtest,disorder,re
20
21def set_auth_algo(h):
22 configpath = "%s/config" % dtest.testroot
23 config = open(configpath, "r").readlines()
24 config = filter(lambda l: not re.match('authorization_algorithm', l),
25 config)
26 config.append('authorization_algorithm %s\n' % h)
27 open(configpath, "w").write("".join(config))
28
29def test():
30 """Authentication hash tests"""
31 created = False
32 for h in ['sha1', 'SHA1', 'sha256', 'SHA256',
33 'sha384', 'SHA384', 'sha512', "SHA512" ]:
34 print " setting authorization hash to %s" % h
35 set_auth_algo(h)
36 dtest.start_daemon()
37 if not created:
38 dtest.create_user()
39 created = True
40 print " exercising C implementation"
41 dtest.command(["disorder",
42 "--config", disorder._configfile, "--no-per-user-config",
43 "--user", "root", "version"])
44 print " exercising Python implementation"
45 c = disorder.client()
46 c.version()
47 dtest.stop_daemon()
48
49if __name__ == '__main__':
50 dtest.run()