turn off server verification in testapiserver
[tests.git] / system / TestUserSfa.py
1 # Thierry Parmentelat <thierry.parmentelat@inria.fr>
2 # Copyright (C) 2010 INRIA 
3 #
4 import os, sys, time
5
6 import utils
7
8 class TestUserSfa:
9
10     def __init__ (self, test_auth_sfa, user_spec):
11         self.test_auth_sfa = test_auth_sfa
12         self.user_spec = user_spec
13         # shortcuts
14         self.test_plc = self.test_auth_sfa.test_plc
15         self.login_base = self.test_auth_sfa.login_base
16
17     def sfi_path(self):
18         return self.test_auth_sfa.sfi_path()
19     def hrn(self):
20         return self.test_auth_sfa.obj_hrn(self.user_spec['name'])
21     def sfi_pi(self, *args, **kwds):
22         return self.test_auth_sfa.sfi_pi(*args, **kwds)
23     def sfi_user(self, *args, **kwds):
24         return self.test_auth_sfa.sfi_user(*args, **kwds)
25
26     # xxx todo - not the right place any longer - or is it ?
27     def sfa_register_user (self, options):
28         "add a regular user using sfi register"
29         user_hrn = self.hrn()
30         command = "register"
31         command += " --type user"
32         command += " --xrn {}".format(user_hrn)
33         command += " --email {}".format(self.user_spec['email'])
34         command += " " + " ".join(self.user_spec['register_options'])
35         # handle key separately because of embedded whitespace
36         # hack - the user's pubkey is avail from his hrn
37         command += " -k {}/{}.pub".format(self.sfi_path(), user_hrn)
38         return self.test_plc.run_in_guest(self.sfi_pi(command)) == 0
39
40     def sfa_update_user (self,options):
41         "update a user record using sfi update"
42         user_hrn = self.hrn()
43         command="update"
44         command += " --type user"
45         command += " --xrn {}".format(user_hrn)
46         command += " " + " ".join(self.user_spec['update_options'])
47         return self.test_plc.run_in_guest(self.sfi_pi(command)) == 0
48
49     def sfa_delete_user(self,options):
50         "run sfi delete on user record"
51         user_hrn = self.hrn()
52         command = "remove -t user {}".format(user_hrn)
53         return self.test_plc.run_in_guest(self.sfi_pi(command)) == 0