X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FTestAuthSfa.py;h=771cf2cb8ab217b0e9df4bd3bca607c81e2a8b75;hb=d5381e90de0d772a5b8867f03f26d40db8f33fba;hp=cbf52e31c1894c37ea45c930297dc711284ec069;hpb=86a4fa16fea07411dc6613750c10eb539fe453d9;p=tests.git diff --git a/system/TestAuthSfa.py b/system/TestAuthSfa.py index cbf52e3..771cf2c 100644 --- a/system/TestAuthSfa.py +++ b/system/TestAuthSfa.py @@ -14,8 +14,8 @@ def slice_sfa_mapper (method): # used to map on several slices... overall=True slice_method = TestSliceSfa.__dict__[method.__name__] - slice_spec=self.auth_sfa_spec['slice_spec'] - test_slice_sfa = TestSliceSfa(self,slice_spec) + slice_spec = self.auth_sfa_spec['slice_spec'] + test_slice_sfa = TestSliceSfa(self, slice_spec) if not slice_method(test_slice_sfa, *args, **kwds): overall=False return overall # restore the doc text @@ -32,25 +32,23 @@ def user_sfa_mapper (method): if not user_method(test_user_sfa, *args, **kwds): overall=False return overall # restore the doc text - actual.__doc__=TestUserSfa.__dict__[method.__name__].__doc__ + actual.__doc__ = TestUserSfa.__dict__[method.__name__].__doc__ return actual class TestAuthSfa: - def __init__ (self,test_plc,auth_sfa_spec): - self.test_plc=test_plc - self.auth_sfa_spec=auth_sfa_spec - self.test_ssh=TestSsh(self.test_plc.test_ssh) + def __init__ (self, test_plc, auth_sfa_spec): + self.test_plc = test_plc + self.auth_sfa_spec = auth_sfa_spec + self.test_ssh = TestSsh(self.test_plc.test_ssh) # # shortcuts - self.login_base=self.auth_sfa_spec['login_base'] -# self.piuser=self.auth_sfa_spec['piuser'] -# self.regularuser=self.auth_sfa_spec['regularuser'] + self.login_base = self.auth_sfa_spec['login_base'] +# self.piuser = self.auth_sfa_spec['piuser'] +# self.regularuser = self.auth_sfa_spec['regularuser'] - def rspec_style (self): return self.auth_sfa_spec['rspec_style'] - def sfi_path (self): - return "/root/sfi/%s"%(self.rspec_style()) + return "/root/sfi" # the hrn for the root authority def root_hrn (self): @@ -58,11 +56,11 @@ class TestAuthSfa: # the hrn for the auth/site def auth_hrn (self): - return "%s.%s"%(self.root_hrn(),self.login_base) + return "{}.{}".format(self.root_hrn(), self.login_base) # something in this site (users typically); for use by classes for subobjects def obj_hrn (self, name): - return "%s.%s"%(self.auth_hrn(),name) + return "{}.{}".format(self.auth_hrn(), name) def regular_user_hrn(self): return self.obj_hrn(self.auth_sfa_spec['user_spec']['name']) @@ -89,30 +87,30 @@ class TestAuthSfa: fileconf=open(file_name,'w') fileconf.write (contents) fileconf.close() - utils.header ("(Over)wrote %s"%file_name) + utils.header ("(Over)wrote {}".format(file_name)) # - file_name=dir_name + os.sep + 'sfi_config' + file_name=dir_name + os.sep + 'sfi_config' fileconf=open(file_name,'w') - SFI_AUTH=self.auth_hrn() - fileconf.write ("SFI_AUTH='%s'"%SFI_AUTH) - fileconf.write('\n') + SFI_AUTH=self.auth_hrn() + fileconf.write ("SFI_AUTH='{}'".format(SFI_AUTH)) + fileconf.write('\n') # default is to run as a PI - SFI_USER=self.obj_hrn(self.auth_sfa_spec['pi_spec']['name']) - fileconf.write ("SFI_USER='%s'"%SFI_USER) - fileconf.write('\n') - SFI_REGISTRY='http://%s:%s/'%(sfa_spec['settings']['SFA_REGISTRY_HOST'],12345) - fileconf.write ("SFI_REGISTRY='%s'"%SFI_REGISTRY) - fileconf.write('\n') - SFI_SM='http://%s:%s/'%(sfa_spec['settings']['SFA_SM_HOST'],sfa_spec['sfi-connects-to-port']) - fileconf.write ("SFI_SM='%s'"%SFI_SM) - fileconf.write('\n') + SFI_USER=self.obj_hrn(self.auth_sfa_spec['pi_spec']['name']) + fileconf.write("SFI_USER='{}'".format(SFI_USER)) + fileconf.write('\n') + SFI_REGISTRY='http://{}:{}/'.format(sfa_spec['settings']['SFA_REGISTRY_HOST'], 12345) + fileconf.write("SFI_REGISTRY='{}'".format(SFI_REGISTRY)) + fileconf.write('\n') + SFI_SM='http://{}:{}/'.format(sfa_spec['settings']['SFA_SM_HOST'], sfa_spec['sfi-connects-to-port']) + fileconf.write("SFI_SM='{}'".format(SFI_SM)) + fileconf.write('\n') fileconf.close() - utils.header ("(Over)wrote %s"%file_name) + utils.header ("(Over)wrote {}".format(file_name)) # using sfaadmin to bootstrap def sfa_register_site (self, options): "bootstrap a site using sfaadmin" - command="sfaadmin reg register -t authority -x %s"%self.auth_hrn() + command="sfaadmin reg register -t authority -x {}".format(self.auth_hrn()) return self.test_plc.run_in_guest(command)==0 def sfa_register_pi (self, options): @@ -122,19 +120,19 @@ class TestAuthSfa: pi_mail=pi_spec['email'] # as installed by sfi_config pi_key=os.path.join(self.sfi_path(),self.obj_hrn(pi_spec['name']+'.pub')) - command="sfaadmin reg register -t user -x %s --email %s --key %s"%(pi_hrn,pi_mail,pi_key) + command="sfaadmin reg register -t user -x {} --email {} --key {}".format(pi_hrn, pi_mail, pi_key) if self.test_plc.run_in_guest(command)!=0: return False - command="sfaadmin reg update -t authority -x %s --pi %s"%(self.auth_hrn(),pi_hrn) - return self.test_plc.run_in_guest(command)==0 + command="sfaadmin reg update -t authority -x {} --pi {}".format(self.auth_hrn(), pi_hrn) + return self.test_plc.run_in_guest(command) == 0 # run as pi def sfi_pi (self, command): pi_name=self.auth_sfa_spec['pi_spec']['name'] - return "sfi -d %s -u %s %s"%(self.sfi_path(),self.obj_hrn(pi_name), command,) + return "sfi -d {} -u {} {}".format(self.sfi_path(), self.obj_hrn(pi_name), command) # the sfi command line option to run as a regular user def sfi_user (self, command): user_name=self.auth_sfa_spec['user_spec']['name'] - return "sfi -d %s -u %s %s"%(self.sfi_path(),self.obj_hrn(user_name), command,) + return "sfi -d {} -u {} {}".format(self.sfi_path(), self.obj_hrn(user_name), command) # user management @user_sfa_mapper @@ -146,38 +144,38 @@ class TestAuthSfa: def sfa_remove_user_from_slice (self, options): "remove regular user from slice" - command="update -t slice -x %s -r none"%(self.slice_hrn()) + command="update -t slice -x {} -r none".format(self.slice_hrn()) # xxx should check result other than visually return self.test_plc.run_in_guest(self.sfi_pi(command))==0 def sfa_insert_user_in_slice (self, options): "defines regular user as unique user in slice" - command="update -t slice -x %s -r %s"%(self.slice_hrn(),self.regular_user_hrn()) + command="update -t slice -x {} -r {}".format(self.slice_hrn(), self.regular_user_hrn()) # xxx should check result other than visually return self.test_plc.run_in_guest(self.sfi_pi(command))==0 def sfi_list (self, options): "run (as regular user) sfi list (on Registry)" - return \ - self.test_plc.run_in_guest(self.sfi_user("list -r %s"%self.root_hrn()))==0 and \ - self.test_plc.run_in_guest(self.sfi_user("list %s"%(self.auth_hrn())))==0 + return \ + self.test_plc.run_in_guest(self.sfi_user("list -r {}".format(self.root_hrn()))) == 0 and \ + self.test_plc.run_in_guest(self.sfi_user("list {}".format(self.auth_hrn()))) == 0 def sfi_show_site (self, options): "run (as regular user) sfi show (on Registry)" - return \ - self.test_plc.run_in_guest(self.sfi_user("show %s"%(self.auth_hrn())))==0 + return \ + self.test_plc.run_in_guest(self.sfi_user("show {}".format(self.auth_hrn()))) == 0 def sfi_show_slice (self, options): "run (as PI) sfi show -n (on Registry)" return \ - self.test_plc.run_in_guest(self.sfi_pi("show -n %s"%self.slice_hrn()))==0 + self.test_plc.run_in_guest(self.sfi_pi("show -n {}".format(self.slice_hrn()))) == 0 # checks if self.regular_user is found in registry's reg-researchers def sfi_show_slice_researchers (self, options): "run (as PI) sfi show -k researcher -k reg-researchers (on Registry)" return \ - self.test_plc.run_in_guest(self.sfi_pi("show %s -k researcher -k reg-researchers"%self.slice_hrn()))==0 + self.test_plc.run_in_guest(self.sfi_pi("show {} -k researcher -k reg-researchers".format(self.slice_hrn()))) == 0 # those are step names exposed as methods of TestPlc, hence the _sfa @@ -194,10 +192,18 @@ class TestAuthSfa: @slice_sfa_mapper def sfa_allocate (self, *args, **kwds): pass @slice_sfa_mapper + def sfa_allocate_empty (self, *args, **kwds): pass + @slice_sfa_mapper def sfa_provision (self, *args, **kwds): pass @slice_sfa_mapper + def sfa_provision_empty (self, *args, **kwds): pass + @slice_sfa_mapper + def sfa_describe (self, *args, **kwds): pass + @slice_sfa_mapper def sfa_check_slice_plc (self, *args, **kwds): pass @slice_sfa_mapper + def sfa_check_slice_plc_empty (self, *args, **kwds): pass + @slice_sfa_mapper def sfa_update_slice (self, *args, **kwds): pass @slice_sfa_mapper def sfa_delete_slice (self, *args, **kwds): pass