now that we create an SFA auth to hold the sfa entities involved:
[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): return self.test_auth_sfa.sfi_path()
19     def qualified(self,name): return self.test_auth_sfa.qualified(name)
20
21     # xxx todo - not the right place any longer - or is it ?
22     def sfa_add_user (self,options):
23         "add a regular user using sfi add"
24         sfi_add_options = self.user_spec['sfi_options']
25         user_hrn = self.qualified(self.user_spec['name'])
26         command="sfi -d %s add"%(self.sfi_path())
27         command += " --type user"
28         command += " --xrn %s"%user_hrn
29         command += " --email %s"%self.user_spec['email']
30         for opt in sfi_add_options:
31             command += " %s"%(opt,)
32         # handle key separately because of embedded whitespace
33         # hack - the user's pubkey is avail from his hrn
34         command += " -k %s/%s.pub"%(self.sfi_path(),user_hrn)
35         return self.test_plc.run_in_guest(command)==0
36
37     def sfa_update_user (self,options):
38         "update a user record using sfi update"
39         # xxx TODO now that we use sfi arguments
40         utils.header ("WARNING: TestUserSfa.update_user needs more work")
41         return True
42
43     def sfa_delete_user(self,options):
44         "run sfi delete on user record"
45         auth=self.test_auth_sfa.root_hrn()
46         return \
47             self.test_plc.run_in_guest("sfi -d %s remove -t user %s.%s.%s"%(
48                 self.sfi_path(),auth,self.login_base,self.regularuser))==0