X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FTestUserSfa.py;h=de7092d1b11768a74dd283a7d520dfc5ab3529e5;hb=eff1f5700b0830ffefb0cc528eff67bdde790a5c;hp=a460f787820f1c3f0b319482fbcdc927f7459fbc;hpb=6ea3c825254eefc7c9dc80f30745e5b200ba7b0b;p=tests.git diff --git a/system/TestUserSfa.py b/system/TestUserSfa.py index a460f78..de7092d 100644 --- a/system/TestUserSfa.py +++ b/system/TestUserSfa.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# import os, sys, time import xmlrpclib @@ -5,23 +8,48 @@ import utils class TestUserSfa: - def __init__ (self,test_plc,plc_spec_sfa): - self.test_plc=test_plc - self.spec_sfa=plc_spec_sfa - - def name(self): - return self.user_spec['user_fields']['email'] - - def add_user (self): - return \ - self.test_plc.run_in_guest("sfi.py -d /root/.sfi/ add person.xml")==0 - - def update_user (self): + def __init__ (self,test_auth_sfa, user_spec): + self.test_auth_sfa=test_auth_sfa + self.user_spec=user_spec + # shortcuts + self.test_plc=self.test_auth_sfa.test_plc + self.login_base=self.test_auth_sfa.login_base + + def sfi_path(self): + return self.test_auth_sfa.sfi_path() + def hrn(self): + return self.test_auth_sfa.obj_hrn(self.user_spec['name']) + def sfi_pi(self,*args,**kwds): + return self.test_auth_sfa.sfi_pi(*args, **kwds) + def sfi_user(self,*args,**kwds): + return self.test_auth_sfa.sfi_user(*args, **kwds) + + # xxx todo - not the right place any longer - or is it ? + def sfa_add_user (self,options): + "add a regular user using sfi add" + user_hrn = self.hrn() + command="add" + command += " --type user" + command += " --xrn %s"%user_hrn + command += " --email %s"%self.user_spec['email'] + command += " " + " ".join(self.user_spec['add_options']) + # handle key separately because of embedded whitespace + # hack - the user's pubkey is avail from his hrn + command += " -k %s/%s.pub"%(self.sfi_path(),user_hrn) + return self.test_plc.run_in_guest(self.sfi_pi(command))==0 + + def sfa_update_user (self,options): + "update a user record using sfi update" + user_hrn = self.hrn() + command="update" + command += " --type user" + command += " --xrn %s"%user_hrn + command += " " + " ".join(self.user_spec['update_options']) + return self.test_plc.run_in_guest(self.sfi_pi(command))==0 + + def sfa_delete_user(self,options): + "run sfi delete on user record" + user_hrn = self.hrn() + command="remove -t user %s"%user_hrn return \ - self.test_plc.run_in_guest("sfi.py -d /root/.sfi/ update person.xml")==0 - - def delete_user(self): - auth=self.spec_sfa['SFA_REGISTRY_ROOT_AUTH'] - return \ - self.test_plc.run_in_guest("sfi.py -d /root/.sfi/ remove -t user %s.main.sfafakeuser1"%auth)==0 - + self.test_plc.run_in_guest(self.sfi_pi(command))==0