def test_validate_policy_with_missing_name(self):
     policy = {
         "service":
         "service_tag",
         "policyType":
         0,
         "description":
         "Test rule",
         "resources": {
             "tag": {
                 "values": ["visible"],
                 "isExcludes": False,
                 "isRecursive": True
             }
         },
         "policyItems": [{
             "accesses": [{
                 "type": "hive:select",
                 "isAllowed": True
             }, {
                 "type": "hive:read",
                 "isAllowed": True
             }],
             "users": ["myuser"],
             "delegateAdmin":
             False
         }]
     }
     with self.assertRaises(AttributeError):
         policyutil.validate_policy(policy)
         self.fail(
             "Validate policy did not raise exception for missing name.")
 def test_validate_policy_with_ok_input(self):
     policy = {
         "service":
         "service_tag",
         "name":
         "test_policy_rule",
         "policyType":
         0,
         "description":
         "Test rule",
         "resources": {
             "tag": {
                 "values": ["visible"],
                 "isExcludes": False,
                 "isRecursive": True
             }
         },
         "policyItems": [{
             "accesses": [{
                 "type": "hive:select",
                 "isAllowed": True
             }, {
                 "type": "hive:read",
                 "isAllowed": True
             }],
             "users": ["myuser"],
             "delegateAdmin":
             False
         }]
     }
     policyutil.validate_policy(policy)
 def test_validate_policy_with_missing_policyitems_and_policytype_not_0(
         self):
     policy = {
         "service": "service_tag",
         "name": "test_policy_rule",
         "policyType": 1,
         "description": "Test rule",
         "resources": {
             "tag": {
                 "values": ["visible"],
                 "isExcludes": False,
                 "isRecursive": True
             }
         }
     }
     policyutil.validate_policy(policy)
 def test_validate_policy_with_missing_policyitems_and_policytype_0(self):
     policy = {
         "service": "service_tag",
         "name": "test_policy_rule",
         "policyType": 0,
         "description": "Test rule",
         "resources": {
             "tag": {
                 "values": ["visible"],
                 "isExcludes": False,
                 "isRecursive": True
             }
         }
     }
     with self.assertRaises(AttributeError):
         policyutil.validate_policy(policy)
         self.fail(
             "Validate policy did not raise exception for missing policyItems."
         )