def test_accesspolicy_update(self): t = template_format.parse(user_policy_template) resource_name = 'WebServerAccessPolicy' stack = utils.parse_stack(t) rsrc = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) self.assertRaises(resource.UpdateReplace, rsrc.handle_update, {}, {}, {})
def test_accesspolicy_update(self): t = self.load_template() resource_name = 'WebServerAccessPolicy' stack = self.parse_stack(t) resource = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) self.assertEqual(user.AccessPolicy.UPDATE_REPLACE, resource.handle_update({}))
def test_accesspolicy_create_ok(self): t = template_format.parse(user_policy_template) stack = utils.parse_stack(t) resource_name = 'WebServerAccessPolicy' rsrc = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) scheduler.TaskRunner(rsrc.create)() self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
def test_accesspolicy_create_ok(self): t = self.load_template() stack = self.parse_stack(t) resource_name = 'WebServerAccessPolicy' resource = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) self.assertEqual(None, resource.create()) self.assertEqual(user.User.CREATE_COMPLETE, resource.state)
def test_accesspolicy_access_allowed(self): t = template_format.parse(user_policy_template) resource_name = 'WebServerAccessPolicy' stack = utils.parse_stack(t) rsrc = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) self.assertTrue(rsrc.access_allowed('WikiDatabase')) self.assertFalse(rsrc.access_allowed('NotWikiDatabase')) self.assertFalse(rsrc.access_allowed(None))
def test_accesspolicy_access_allowed(self): t = self.load_template() resource_name = 'WebServerAccessPolicy' stack = self.parse_stack(t) resource = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) self.assertTrue(resource.access_allowed('WikiDatabase')) self.assertFalse(resource.access_allowed('NotWikiDatabase')) self.assertFalse(resource.access_allowed(None))
def test_accesspolicy_create_ok_empty(self): t = template_format.parse(user_policy_template) resource_name = 'WebServerAccessPolicy' t['Resources'][resource_name]['Properties']['AllowedResources'] = [] stack = parse_stack(t) resource = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) scheduler.TaskRunner(resource.create)() self.assertEqual(user.User.CREATE_COMPLETE, resource.state)
def test_accesspolicy_create_ok_empty(self): t = template_format.parse(user_policy_template) resource_name = 'WebServerAccessPolicy' t['Resources'][resource_name]['Properties']['AllowedResources'] = [] stack = utils.parse_stack(t) resource_defns = stack.t.resource_definitions(stack) rsrc = user.AccessPolicy(resource_name, resource_defns[resource_name], stack) scheduler.TaskRunner(rsrc.create)() self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
def test_accesspolicy_create_err_notfound(self): t = template_format.parse(user_policy_template) resource_name = 'WebServerAccessPolicy' t['Resources'][resource_name]['Properties']['AllowedResources'] = [ 'NoExistResource'] stack = utils.parse_stack(t) rsrc = user.AccessPolicy(resource_name, t['Resources'][resource_name], stack) self.assertRaises(exception.ResourceNotFound, rsrc.handle_create)