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