Add a "no_result" key in JSON test files because "(?!...)" regular expression doesn... 17/3617/1
authorasteroide <thomas.duval@orange.com>
Wed, 25 Nov 2015 14:45:29 +0000 (15:45 +0100)
committerasteroide <thomas.duval@orange.com>
Wed, 25 Nov 2015 14:45:29 +0000 (15:45 +0100)
Change-Id: I67a8b6a529b71bc7499ba68cb431403a63482c1c

23 files changed:
moonclient/moonclient/shell.py
moonclient/moonclient/tests.py
moonclient/moonclient/tests/tests_action_assignments.json
moonclient/moonclient/tests/tests_action_categories.json
moonclient/moonclient/tests/tests_action_scopes.json
moonclient/moonclient/tests/tests_actions.json
moonclient/moonclient/tests/tests_admin_intraextensions.json
moonclient/moonclient/tests/tests_configuration.json
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_external_commands.json
moonclient/moonclient/tests/tests_object_assignments.json
moonclient/moonclient/tests/tests_object_categories.json
moonclient/moonclient/tests/tests_object_scopes.json
moonclient/moonclient/tests/tests_objects.json
moonclient/moonclient/tests/tests_rules.json
moonclient/moonclient/tests/tests_subject_assignments.json
moonclient/moonclient/tests/tests_subject_categories.json
moonclient/moonclient/tests/tests_subject_scopes.json
moonclient/moonclient/tests/tests_subjects.json
moonclient/moonclient/tests/tests_submetarules.json
moonclient/moonclient/tests/tests_tenants.json

index 8343d86..65adbc0 100644 (file)
@@ -178,7 +178,7 @@ class MoonClient(App):
                         content['error']['message'],
                     ))
                 except ValueError:
-                    raise Exception("Getting an error while requiring {} ({})".format(url, content))
+                    raise Exception("Bad error format while requiring {} ({})".format(url, content))
             return content
         except ValueError:
             raise Exception("Getting an error while requiring {} ({})".format(url, content))
index e85c276..24732db 100644 (file)
@@ -136,8 +136,12 @@ class TestsLaunch(Lister):
                     self.logfile.write("{}".format(result_str))
                 data_tmp.append(group_name)
                 data_tmp.append(test["name"])
-                compare = self.__compare_results(self.__replace_var_in_str(test["result"]), result_str)
-                self.logfile.write("\\---->{}: {}\n\n".format(compare, self.__replace_var_in_str(test["result"])))
+                if "result" in test:
+                    compare = self.__compare_results(self.__replace_var_in_str(test["result"]), result_str)
+                    self.logfile.write("\\---->{}: {}\n\n".format(compare, self.__replace_var_in_str(test["result"])))
+                else:
+                    compare = not self.__compare_results(self.__replace_var_in_str(test["no_result"]), result_str)
+                    self.logfile.write("\\---->{}: not {}\n\n".format(compare, self.__replace_var_in_str(test["no_result"])))
                 if error_str:
                     if compare:
                         compare = "\033[33mTrue\033[m"
index dc9cb27..4ce5833 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_assignment",
         "command": "action assignment list $uuid_action $uuid_action_category",
-        "result": "(?!$uuid_action_scope)",
+        "no_result": "$uuid_action_scope",
         "description": "Check deleted assignment.",
         "command_options": "-c id -f value"
       },
       {
         "name": "list_action_category",
         "command": "action category list",
-        "result": "(?!$uuid_action_category)",
+        "no_result": "$uuid_action_category",
         "description": "Check that my_new_action_category action_category was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_assignment",
         "command": "action assignment list $uuid_action $uuid_action_category",
-        "result": "(?!$uuid_action_scope)",
+        "no_result": "$uuid_action_scope",
         "description": "Check deleted assignment.",
         "command_options": "-c id -f value"
       },
       {
         "name": "list_action_category",
         "command": "action category list",
-        "result": "(?!$uuid_action_category)",
+        "no_result": "$uuid_action_category",
         "description": "Check that my_new_action_category action_category was deleted."
       },
       {
index bf6a72c..d748570 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -78,7 +78,7 @@
       {
         "name": "list_action_category",
         "command": "action category list",
-        "result": "(?!$uuid_action_category)",
+        "no_result": "$uuid_action_category",
         "description": "Check that my_new_action_category action_category was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_action_category",
         "command": "action category list",
-        "result": "(?!$uuid_action_category)",
+        "no_result": "$uuid_action_category",
         "description": "Check that my_new_action_category action_category was deleted."
       },
       {
index 437c8e6..2dd26c6 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -86,7 +86,7 @@
       {
         "name": "check_deleted_scope",
         "command": "action scope list $uuid_action_category",
-        "result": "(?!$uuid_action_scope)",
+        "no_result": "$uuid_action_scope",
         "description": "Check deleted scope.",
         "command_options": "-c id -f value"
       },
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_scope",
         "command": "action scope list $uuid_action_category",
-        "result": "(?!$uuid_action_scope)",
+        "no_result": "$uuid_action_scope",
         "description": "Check deleted scope.",
         "command_options": "-c id -f value"
       },
index f565cca..f512a91 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -78,7 +78,7 @@
       {
         "name": "list_action",
         "command": "action list",
-        "result": "(?!$uuid_action)",
+        "no_result": "$uuid_action",
         "description": "Check that new_action_1 action was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_action",
         "command": "action list",
-        "result": "(?!$uuid_action)",
+        "no_result": "$uuid_action",
         "description": "Check that new_action_1 action was deleted."
       },
       {
index 40ac04a..5d3fa92 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "List all tenants (must be empty)"
       },
       {
index d712a0f..3ad327c 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -97,7 +97,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
index 6344a3e..3e03fdf 100644 (file)
@@ -29,7 +29,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!demo)",
+        "no_result": "demo",
         "description": "Check if tenant demo is used."
       },
       {
index c17d825..6348221 100644 (file)
@@ -29,7 +29,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!demo)",
+        "no_result": "demo",
         "description": "Check if tenant demo is used."
       },
       {
       {
         "name": "check nova command",
         "external_command": "nova list",
-        "result": "(?!test_moonclient)",
+        "no_result": "test_moonclient",
         "description": "Check that we cannot list nova servers due to the current rules"
       },
       {
index e31e66c..a1c197c 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "swift list",
         "external_command": "swift list",
-        "result": "(?!moonclient_test)",
+        "no_result": "moonclient_test",
         "description": "Check Swift command"
       },
       {
@@ -30,7 +30,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!demo)",
+        "no_result": "demo",
         "description": "Check if tenant demo is used."
       },
       {
       {
         "name": "swift list",
         "external_command": "swift list",
-        "result": "(?!moonclient_test)",
+        "no_result": "moonclient_test",
         "description": "Check Swift command, it must be impossible due to current rules"
       },
 
       {
         "name": "swift list",
         "external_command": "swift list moonclient_test",
-        "result": "(?!tmp/test.txt)",
+        "no_result": "tmp/test.txt",
         "description": "Check that test file has not been uploaded."
       },
       {
index 0aa6f70..0b212e9 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!demo)",
+        "no_result": "demo",
         "description": "List all tenants (must be empty)"
       },
       {
index 35fd34a..fa834cc 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_assignment",
         "command": "object assignment list $uuid_object $uuid_object_category",
-        "result": "(?!$uuid_object_scope)",
+        "no_result": "$uuid_object_scope",
         "description": "Check deleted assignment.",
         "command_options": "-c id -f value"
       },
         "description": "Delete one scope from object category role",
         "command_options": ""
       },
+      {
+        "name": "check_added_scope",
+        "command": "object scope list $uuid_object_category",
+        "no_result": "$uuid_object_scope",
+        "description": "Check added scope was deleted.",
+        "command_options": "-c id -f value"
+      },
       {
         "name": "delete_object_category",
         "command": "object category delete $uuid_object_category",
       {
         "name": "list_object_category",
         "command": "object category list",
-        "result": "(?!$uuid_object_category)",
+        "no_result": "$uuid_object_category",
         "description": "Check that my_new_object_category object_category was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_assignment",
         "command": "object assignment list $uuid_object $uuid_object_category",
-        "result": "(?!$uuid_object_scope)",
+        "no_result": "$uuid_object_scope",
         "description": "Check deleted assignment.",
         "command_options": "-c id -f value"
       },
         "description": "Delete one scope from object category role",
         "command_options": ""
       },
+      {
+        "name": "check_deleted_scope",
+        "command": "object scope list $uuid_object_category",
+        "no_result": "$uuid_object_scope",
+        "description": "Check added scope was deleted.",
+        "command_options": "-c id -f value"
+      },
       {
         "name": "delete_object_category",
         "command": "object category delete $uuid_object_category",
       {
         "name": "list_object_category",
         "command": "object category list",
-        "result": "(?!$uuid_object_category)",
+        "no_result": "$uuid_object_category",
         "description": "Check that my_new_object_category object_category was deleted."
       },
       {
index a646464..a8a8011 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -78,7 +78,7 @@
       {
         "name": "list_object_category",
         "command": "object category list",
-        "result": "(?!$uuid_object_category)",
+        "no_result": "$uuid_object_category",
         "description": "Check that my_new_object_category object_category was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_object_category",
         "command": "object category list",
-        "result": "(?!$uuid_object_category)",
+        "no_result": "$uuid_object_category",
         "description": "Check that my_new_object_category object_category was deleted."
       },
       {
index c9f832e..b97636b 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -86,7 +86,7 @@
       {
         "name": "check_deleted_scope",
         "command": "object scope list $uuid_object_category",
-        "result": "(?!$uuid_object_scope)",
+        "no_result": "$uuid_object_scope",
         "description": "Check deleted scope.",
         "command_options": "-c id -f value"
       },
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_scope",
         "command": "object scope list $uuid_object_category",
-        "result": "(?!$uuid_object_scope)",
+        "no_result": "$uuid_object_scope",
         "description": "Check deleted scope.",
         "command_options": "-c id -f value"
       },
index c3a70f4..10481d3 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -78,7 +78,7 @@
       {
         "name": "list_object",
         "command": "object list",
-        "result": "(?!$uuid_object)",
+        "no_result": "$uuid_object",
         "description": "Check that nova_server_1 object was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_object",
         "command": "object list",
-        "result": "(?!$uuid_object)",
+        "no_result": "$uuid_object",
         "description": "Check that nova_server_1 object was deleted."
       },
       {
index 5d3229b..6c22073 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_rule",
         "command": "rule list $submetarule_uuid",
-        "result": "(?!very_high)",
+        "no_result": "very_high",
         "description": "Check that the rule was correctly deleted.",
         "command_options": "-c s:subject_security_level -f value"
       },
       {
         "name": "list_intraextension_authz",
         "command": "intraextension list",
-        "result": "(?!$uuid_authz)",
+        "no_result": "$uuid_authz",
         "description": "Check the existence of that authz intra extension"
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       }
     ],
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_rule",
         "command": "rule list $submetarule_uuid",
-        "result": "(?!very_high)",
+        "no_result": "very_high",
         "description": "Check that the rule was correctly deleted.",
         "command_options": "-c s:subject_security_level -f value"
       },
       {
         "name": "list_intraextension_authz",
         "command": "intraextension list",
-        "result": "(?!$uuid_authz)",
+        "no_result": "$uuid_authz",
         "description": "Check the existence of that authz intra extension"
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       }
     ]
index 7eb1e82..d038c2c 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -57,7 +57,7 @@
       },
       {
         "name": "add_subject",
-        "command": "subject add alt_demo",
+        "command": "subject add alt_demo --password nomoresecrete",
         "result": "",
         "description": "Add the new subject category alt_demo",
         "command_options": ""
       {
         "name": "check_deleted_assignment",
         "command": "subject assignment list $uuid_subject $uuid_subject_category",
-        "result": "(?!$uuid_subject_scope)",
+        "no_result": "$uuid_subject_scope",
         "description": "Check deleted assignment.",
         "command_options": "-c id -f value"
       },
       {
         "name": "list_subject_category",
         "command": "subject category list",
-        "result": "(?!$uuid_subject_category)",
+        "no_result": "$uuid_subject_category",
         "description": "Check that my_new_subject_category subject_category was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       },
       {
         "name": "add_subject",
-        "command": "subject add alt_demo",
+        "command": "subject add alt_demo --password nomoresecrete",
         "result": "",
         "description": "Add the new subject category alt_demo",
         "command_options": ""
       {
         "name": "check_deleted_assignment",
         "command": "subject assignment list $uuid_subject $uuid_subject_category",
-        "result": "(?!$uuid_subject_scope)",
+        "no_result": "$uuid_subject_scope",
         "description": "Check deleted assignment.",
         "command_options": "-c id -f value"
       },
       {
         "name": "list_subject_category",
         "command": "subject category list",
-        "result": "(?!$uuid_subject_category)",
+        "no_result": "$uuid_subject_category",
         "description": "Check that my_new_subject_category subject_category was deleted."
       },
       {
index 63bd349..54540f0 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -78,7 +78,7 @@
       {
         "name": "list_subject_category",
         "command": "subject category list",
-        "result": "(?!$uuid_subject_category)",
+        "no_result": "$uuid_subject_category",
         "description": "Check that my_new_subject_category subject_category was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_subject_category",
         "command": "subject category list",
-        "result": "(?!$uuid_subject_category)",
+        "no_result": "$uuid_subject_category",
         "description": "Check that my_new_subject_category subject_category was deleted."
       },
       {
index c6f7f30..218038c 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -86,7 +86,7 @@
       {
         "name": "check_deleted_scope",
         "command": "subject scope list $uuid_subject_category",
-        "result": "(?!$uuid_subject_scope)",
+        "no_result": "$uuid_subject_scope",
         "description": "Check deleted scope.",
         "command_options": "-c id -f value"
       },
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "check_deleted_scope",
         "command": "subject scope list $uuid_subject_category",
-        "result": "(?!$uuid_subject_scope)",
+        "no_result": "$uuid_subject_scope",
         "description": "Check deleted scope.",
         "command_options": "-c id -f value"
       },
index 37d37f4..db79367 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
@@ -78,7 +78,7 @@
       {
         "name": "list_subject",
         "command": "subject list",
-        "result": "(?!$uuid_subject)",
+        "no_result": "$uuid_subject",
         "description": "Check that alt_demo subject was deleted."
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_subject",
         "command": "subject list",
-        "result": "(?!$uuid_subject)",
+        "no_result": "$uuid_subject",
         "description": "Check that alt_demo subject was deleted."
       },
       {
index 955f628..d8b3e4d 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_intraextension_authz",
         "command": "intraextension list",
-        "result": "(?!$uuid_authz)",
+        "no_result": "$uuid_authz",
         "description": "Check the existence of that authz intra extension"
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       }
     ],
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       },
       {
       {
         "name": "list_intraextension_authz",
         "command": "intraextension list",
-        "result": "(?!$uuid_authz)",
+        "no_result": "$uuid_authz",
         "description": "Check the existence of that authz intra extension"
       },
       {
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "Check if tenant alt_demo is used."
       }
     ]
index 02b2075..c2674db 100644 (file)
@@ -5,7 +5,7 @@
       {
         "name": "list tenant",
         "command": "tenant list",
-        "result": "(?!alt_demo)",
+        "no_result": "alt_demo",
         "description": "List all tenants (must be empty)"
       },
       {