update tests on Moonclient 47/15747/1
authorDUVAL Thomas <thomas.duval@orange.com>
Thu, 16 Jun 2016 12:37:22 +0000 (14:37 +0200)
committerDUVAL Thomas <thomas.duval@orange.com>
Thu, 16 Jun 2016 12:37:22 +0000 (14:37 +0200)
Change-Id: I11dee646deec20423411c5bcaf4b8e694622bd79

moonclient/moonclient/shell.py
moonclient/moonclient/tests.py
moonclient/moonclient/tests/tests_empty_policy_new_user.json
moonclient/moonclient/tests/tests_empty_policy_nova.json
moonclient/moonclient/tests/tests_empty_policy_swift.json
moonclient/moonclient/tests/tests_subjects.json

index 79f9a24..fa675dd 100644 (file)
@@ -188,7 +188,7 @@ class MoonClient(App):
         finally:
             self.log.debug(str(content))
 
-    def auth_keystone(self, username=None, password=None, host=None, port=None):
+    def auth_keystone(self, username=None, password=None, host=None, port=None, tenant=None):
         """Send a new authentication request to Keystone
 
         :param username: user identification name
@@ -198,6 +198,8 @@ class MoonClient(App):
             self.post["auth"]["identity"]["password"]["user"]["name"] = username
         if password:
             self.post["auth"]["identity"]["password"]["user"]["password"] = password
+        if tenant:
+            self.post["auth"]["scope"]["project"]["name"] = tenant
         if host:
             self.host = host
         if port:
index e2824fa..5a33130 100644 (file)
@@ -117,6 +117,7 @@ class TestsLaunch(Lister):
                 if "auth_name" in test or "auth_password" in test or "auth_url" in test:
                     username = None
                     password = None
+                    tenant = None
                     host = None
                     port = None
                     description = ""
@@ -124,13 +125,15 @@ class TestsLaunch(Lister):
                         username = test["auth_name"]
                     if "auth_password" in test:
                         password = test["auth_password"]
+                    if "auth_tenant" in test:
+                        tenant = test["auth_tenant"]
                     if "auth_host" in test:
                         host = test["auth_host"]
                     if "auth_port" in test:
                         port = test["auth_port"]
                     if "description" in test:
                         description = test["description"]
-                    self.app.auth_keystone(username, password, host, port)
+                    self.app.auth_keystone(username, password, host, port, tenant)
                     title = "Change auth to "
                     if username:
                         title += username
index 69f4e16..6caf34e 100644 (file)
@@ -4,18 +4,32 @@
     "authz": [
       {
         "auth_name": "admin",
+        "auth_password": "password",
+        "auth_tenant": "admin",
         "description": "Change user to admin (just in case...)"
       },
 
       {
         "name": "nova image-list",
         "external_command": "nova image-list",
-        "result": "(?P<uuid_image>[\\w-]+)\\s+\\| cirros-0.3.4-x86_64-uec",
+        "result": "(?P<uuid_image>[\\w-]+)\\s+\\| cirros-0.3",
         "description": "Get an Image ID"
       },
+      {
+        "name": "create teannt test",
+        "external_command": "openstack project create test_moonclient",
+        "result": "(?P<uuid_image>[\\w-]+)\\s+\\| cirros-0.3",
+        "description": "Get an Image ID"
+      },
+      {
+        "name": "add role admin to demo",
+        "external_command": "openstack role add --project admin --user demo admin",
+        "result": "",
+        "description": "Force the admin role for the user demo on the project admin (for testing purpose)."
+      },
       {
         "name": "nova boot new server",
-        "external_command": "nova boot  --flavor m1.micro --image $uuid_image test_moonclient",
+        "external_command": "nova boot  --flavor m1.tiny --image $uuid_image test_moonclient",
         "result": "\\| OS-EXT-STS\\:vm_state\\s+\\| building",
         "description": "Boot a new nova server."
       },
       },
       {
         "name": "add_subject",
-        "command": "subject add demo --subject_pass nomoresecrete",
+        "command": "subject add demo --subject_pass password",
         "result": "",
         "description": "",
         "command_options": ""
       },
       {
         "name": "add_subject",
-        "command": "subject add demo --subject_pass nomoresecrete",
+        "command": "subject add demo --subject_pass password",
         "result": "",
         "description": "Add demo subject.",
         "command_options": ""
       },
       {
         "name": "add_subject",
-        "command": "subject add demo --subject_pass nomoresecrete",
+        "command": "subject add demo --subject_pass password",
         "result": "",
         "description": "Add demo subject.",
         "command_options": ""
 
       {
         "name": "demo: check nova command",
-        "external_command": "nova --os-user-name demo list",
+        "external_command": "nova --os-user-name demo --os-project-name admin list",
         "result": "test_moonclient",
-        "description": "Check demo cant list nova servers due to the current rules"
+        "description": "Check demo can list nova servers due to the current rules"
       },
       {
         "name": "demo: try to pause nova instance",
-        "external_command": "nova --os-username demo pause $uuid_server",
+        "external_command": "nova --os-username demo --os-project-name admin pause $uuid_server",
         "result": "^$",
         "description": "Pausing the server must be impossible due to the current rules"
       },
       {
         "name": "check nova command",
-        "external_command": "nova --os-user-name demo list",
+        "external_command": "nova --os-user-name demo  --os-project-name admin list",
         "result": "\\| (?P<uuid_server>[\\w\\-]+)\\s+\\| test_moonclient\\s+\\| ACTIVE\\s+\\| [\\w\\-]+\\s+\\| Running",
         "description": "Check that nova server is still in running state."
       },
+      {
+        "name": "pause",
+        "external_command": "read",
+        "result": "",
+        "description": "Pause"
+      },
 
       {
         "name": "list tenant",
 
       {
         "auth_name": "demo",
+        "auth_password": "password",
+        "auth_tenant": "admin",
         "description": "Change user to demo"
       },
 
 
       {
         "auth_name": "admin",
+        "auth_tenant": "admin",
         "description": "Change user to admin"
       },
 
index fdab951..521b1f1 100644 (file)
       },
       {
         "name": "add_subject",
-        "command": "subject add admin --password nomoresecrete",
+        "command": "subject add admin --subject_pass password",
         "result": "",
         "description": "",
         "command_options": ""
       },
       {
         "name": "add_subject",
-        "command": "subject add demo --password nomoresecrete",
+        "command": "subject add demo --subject_pass password",
         "result": "",
         "description": "",
         "command_options": ""
index 5ee1833..4c9e131 100644 (file)
@@ -93,7 +93,7 @@
       },
       {
         "name": "add_subject",
-        "command": "subject add admin --password nomoresecrete",
+        "command": "subject add admin --subject_pass password",
         "result": "",
         "description": "",
         "command_options": ""
       },
       {
         "name": "add_subject",
-        "command": "subject add demo --password nomoresecrete",
+        "command": "subject add demo --subject_pass password",
         "result": "",
         "description": "",
         "command_options": ""
index 5543372..97a45da 100644 (file)
@@ -62,7 +62,7 @@
       },
       {
         "name": "add_subject",
-        "command": "subject add alt_demo --password nomoresecrete",
+        "command": "subject add alt_demo --subject_pass password",
         "result": "",
         "description": "Add the alt_demo subject",
         "command_options": ""
       },
       {
         "name": "add_subject",
-        "command": "subject add alt_demo --password nomoresecrete",
+        "command": "subject add alt_demo --subject_pass password",
         "result": "",
         "description": "Add the alt_demo subject",
         "command_options": ""