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