no functional change, but a small cleanup on how sfa users are configured
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 1 Apr 2014 07:34:48 +0000 (09:34 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 1 Apr 2014 07:34:48 +0000 (09:34 +0200)
system/TestAuthSfa.py
system/TestPlc.py
system/TestSliceSfa.py
system/TestUserSfa.py
system/config_default.py

index 7a4b90b..d69333d 100644 (file)
@@ -60,13 +60,12 @@ class TestAuthSfa:
         return self.test_plc.plc_spec['sfa']['SFA_REGISTRY_ROOT_AUTH']
 
     # the hrn for the auth/site
-    def hrn (self):
+    def auth_hrn (self):
         return "%s.%s"%(self.root_hrn(),self.login_base)
 
-    # something in this site (users typically)
-    def qualified (self, name):
-#        return "%s.%s"%(self.auth_sfa_spec['hrn_prefix'],name)
-        return "%s.%s"%(self.hrn(),name)
+    # something in this site (users typically); for use by classes for subobjects
+    def obj_hrn (self, name):
+        return "%s.%s"%(self.auth_hrn(),name)
 
     # xxx this needs tweaks with more recent versions of sfa that have pgv2 as the default ?
     # dir_name is local and will be pushed later on by TestPlc
@@ -84,7 +83,7 @@ class TestAuthSfa:
             key_spec = self.test_plc.locate_key (key_name)
             for (kind,ext) in [ ('private', 'pkey'), ('public', 'pub') ] :
                 contents=key_spec[kind]
-                file_name=os.path.join(dir_name,self.qualified(user_leaf))+"."+ext
+                file_name=os.path.join(dir_name,self.obj_hrn(user_leaf))+"."+ext
                 fileconf=open(file_name,'w')
                 fileconf.write (contents)
                 fileconf.close()
@@ -92,11 +91,11 @@ class TestAuthSfa:
         #
        file_name=dir_name + os.sep + 'sfi_config'
         fileconf=open(file_name,'w')
-       SFI_AUTH=self.hrn()
+       SFI_AUTH=self.auth_hrn()
         fileconf.write ("SFI_AUTH='%s'"%SFI_AUTH)
        fileconf.write('\n')
         # default is to run as a PI
-       SFI_USER=self.qualified(self.auth_sfa_spec['pi_spec']['name'])
+       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://' + sfa_spec['SFA_REGISTRY_HOST'] + ':12345/'
@@ -111,29 +110,29 @@ class TestAuthSfa:
     # using sfaadmin to bootstrap
     def sfa_add_site (self, options):
         "bootstrap a site using sfaadmin"
-        command="sfaadmin reg register -t authority -x %s"%self.hrn()
+        command="sfaadmin reg register -t authority -x %s"%self.auth_hrn()
         return self.test_plc.run_in_guest(command)==0
 
     def sfa_add_pi (self, options):
         "bootstrap a PI user for that site"
         pi_spec = self.auth_sfa_spec['pi_spec']
-        pi_hrn=self.qualified(pi_spec['name'])
+        pi_hrn=self.obj_hrn(pi_spec['name'])
         pi_mail=pi_spec['email']
         # as installed by sfi_config
-        pi_key=os.path.join(self.sfi_path(),self.qualified(pi_spec['name']+'.pub'))
+        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)
         if self.test_plc.run_in_guest(command)!=0: return False
-        command="sfaadmin reg update -t authority -x %s --pi %s"%(self.hrn(),pi_hrn)
+        command="sfaadmin reg update -t authority -x %s --pi %s"%(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.qualified(pi_name), command,)
+        return "sfi -d %s -u %s %s"%(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.qualified(user_name), command,)
+        return "sfi -d %s -u %s %s"%(self.sfi_path(),self.obj_hrn(user_name), command,)
 
     # user management
     @user_sfa_mapper
@@ -147,12 +146,12 @@ class TestAuthSfa:
         "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.hrn())))==0
+            self.test_plc.run_in_guest(self.sfi_user("list %s"%(self.auth_hrn())))==0
 
     def sfi_show (self, options):
         "run (as regular user) sfi show (on Registry)"
        return \
-            self.test_plc.run_in_guest(self.sfi_user("show %s"%(self.hrn())))==0
+            self.test_plc.run_in_guest(self.sfi_user("show %s"%(self.auth_hrn())))==0
 
     # those are step names exposed as methods of TestPlc, hence the _sfa
     @slice_sfa_mapper
index 89eb02e..2878344 100644 (file)
@@ -514,7 +514,7 @@ class TestPlc:
                     for key in val:
                         self.display_key_spec (key)
             elif passno == 1:
-                if key not in ['sites','initscripts','slices','keys', 'sfa']:
+                if key not in ['sites','initscripts','slices','keys']:
                     print '+   ',key,':',val
 
     def display_site_spec (self,site):
index 7731f86..d6bedbd 100644 (file)
@@ -22,9 +22,10 @@ class TestSliceSfa:
         # shortcuts
         self.test_plc=self.test_auth_sfa.test_plc
 
-    def qualified(self,name): return self.test_auth_sfa.qualified(name)
-    def hrn (self): return self.qualified(self.slice_spec['name'])
-    def sfi_path (self): return self.test_auth_sfa.sfi_path()
+    def hrn (self): 
+        return self.test_auth_sfa.obj_hrn(self.slice_spec['name'])
+    def sfi_path (self):
+        return self.test_auth_sfa.sfi_path()
 
     # send back up to the TestAuthSfa
     def rspec_style (self): return self.test_auth_sfa.rspec_style()
index c95733f..de7092d 100644 (file)
@@ -15,15 +15,19 @@ class TestUserSfa:
         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 qualified(self,name): return self.test_auth_sfa.qualified(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)
+    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.qualified(self.user_spec['name'])
+        user_hrn = self.hrn()
         command="add"
         command += " --type user"
         command += " --xrn %s"%user_hrn
@@ -36,7 +40,7 @@ class TestUserSfa:
 
     def sfa_update_user (self,options):
         "update a user record using sfi update"
-        user_hrn = self.qualified(self.user_spec['name'])
+        user_hrn = self.hrn()
         command="update"
         command += " --type user"
         command += " --xrn %s"%user_hrn
@@ -45,7 +49,7 @@ class TestUserSfa:
 
     def sfa_delete_user(self,options):
        "run sfi delete on user record"
-        user_hrn = self.qualified(self.user_spec['name'])
+        user_hrn = self.hrn()
         command="remove -t user %s"%user_hrn
        return \
             self.test_plc.run_in_guest(self.sfi_pi(command))==0
index 43912ac..79b1bec 100644 (file)
@@ -539,7 +539,7 @@ def sfa (options,index) :
                              for rspec_style in options.rspec_styles ]
     }
 
-# rspecstyle is 'pl' for sfav1 or 'pg' for pgv2
+# rspec_style is 'pl' for sfav1 or 'pg' for pgv2
 def test_auth_sfa_spec (options,index,rspec_style):
     # the auth/site part per se
     login_base=sfa_login_base(index,rspec_style)
@@ -547,16 +547,20 @@ def test_auth_sfa_spec (options,index,rspec_style):
     def full_hrn(x):  return "%s.%s"%(hrn_prefix,x)
     def full_mail(x): return "%s@test.%s"%(x,domain)
 
-    # 2 users
+    # 2 users; we use dashes on purpose, as it might show up in email addresses
+#    pi_alias = 'pi-user'
+#    user_alias = 'reg-user'
+    pi_alias = 'pi'
+    user_alias = 'user'
+    # 
     pi_spec = {
-        'name':         'pi',
-        'email':        full_mail ('piuser'),
+        'name':         pi_alias,
+        'email':        full_mail (pi_alias),
         'key_name':     'key_sfapi',
         }
-    user_hrn = full_hrn ('us')
     user_spec = {
-        'name':         'us',
-        'email':        full_mail ('regularuser'),
+        'name':         user_alias,
+        'email':        full_mail (user_alias),
         'key_name':     'key_sfauser',
         'add_options':  [ '--extra',"first_name=Fake",
                           '--extra',"last_name=SFA-style-%s"%rspec_style,
@@ -567,7 +571,7 @@ def test_auth_sfa_spec (options,index,rspec_style):
 
     slice_spec = {
         'name':          'sl',
-        'add_options':  [ '--researchers', user_hrn,
+        'add_options':  [ '--researchers', full_hrn (user_alias),
                           # xxx
                           '--extra', "description=SFA-testing-%s"%rspec_style,
                           '--extra', "url=http://slice%d.test.onelab.eu/"%index,