Example #1
0
    def test_edit_rules_delete_rule_exception(self):
        exception = novaclient_exceptions.ClientException('ClientException',
                                                  message='ClientException')

        RULE_ID = '1'

        formData = {'method': 'DeleteRule',
                    'tenant_id': self.TEST_TENANT,
                    'security_group_rule_id': RULE_ID,
                   }

        self.mox.StubOutWithMock(api, 'security_group_rule_delete')
        api.security_group_rule_delete(IsA(http.HttpRequest), RULE_ID).\
                                       AndRaise(exception)

        self.mox.StubOutWithMock(messages, 'error')
        messages.error(IsA(http.HttpRequest), IsA(basestring))

        self.mox.ReplayAll()

        res = self.client.post(SG_EDIT_RULE_URL, formData)

        self.assertRedirectsNoFollow(res, SG_EDIT_RULE_URL)

        self.mox.VerifyAll()
Example #2
0
    def test_edit_rules_delete_rule(self):
        sec_group = self.security_groups.first()
        rule = self.security_group_rules.first()

        self.mox.StubOutWithMock(api, 'security_group_rule_delete')
        api.security_group_rule_delete(IsA(http.HttpRequest), rule.id)
        self.mox.ReplayAll()

        form_data = {"action": "rules__delete__%s" % rule.id}
        req = self.factory.post(self.edit_url, form_data)
        table = RulesTable(req, sec_group.rules)
        handled = table.maybe_handle()
        self.assertEqual(strip_absolute_base(handled['location']), INDEX_URL)
Example #3
0
    def test_edit_rules_delete_rule_exception(self):
        rule = self.security_group_rules.first()

        self.mox.StubOutWithMock(api, 'security_group_rule_delete')
        exc = novaclient_exceptions.ClientException('ClientException')
        api.security_group_rule_delete(IsA(http.HttpRequest),
                                       rule.id).AndRaise(exc)
        self.mox.ReplayAll()

        form_data = {"action": "rules__delete__%s" % rule.id}
        req = self.factory.post(self.edit_url, form_data)
        table = RulesTable(req, self.security_group_rules.list())
        handled = table.maybe_handle()
        self.assertEqual(strip_absolute_base(handled['location']),
                         INDEX_URL)
Example #4
0
    def test_edit_rules_delete_rule(self):
        RULE_ID = 1

        self.mox.StubOutWithMock(api, 'security_group_rule_delete')
        api.security_group_rule_delete(IsA(http.HttpRequest), RULE_ID)

        self.mox.ReplayAll()

        form_data = {"action": "rules__delete__%s" % RULE_ID}
        req = self.factory.post(SG_EDIT_RULE_URL, form_data)
        table = RulesTable(req, self.rules)
        handled = table.maybe_handle()

        self.assertEqual(strip_absolute_base(handled['location']),
                         INDEX_URL)
Example #5
0
    def test_edit_rules_delete_rule(self):
        RULE_ID = '1'

        formData = {'method': 'DeleteRule',
                    'tenant_id': self.TEST_TENANT,
                    'security_group_rule_id': RULE_ID,
                   }

        self.mox.StubOutWithMock(api, 'security_group_rule_delete')
        api.security_group_rule_delete(IsA(http.HttpRequest), RULE_ID)

        self.mox.ReplayAll()

        res = self.client.post(SG_EDIT_RULE_URL, formData)

        self.assertRedirectsNoFollow(res, SG_EDIT_RULE_URL)
Example #6
0
    def handle(self, request, data):
        security_group_rule_id = data['security_group_rule_id']
        tenant_id = data['tenant_id']
        try:
            LOG.info('Delete security_group_rule: "%s"' % data)

            security_group = api.security_group_rule_delete(
                                                request,
                                                security_group_rule_id)
            messages.info(request, _('Successfully deleted rule: %s')
                                    % security_group_rule_id)
        except novaclient_exceptions.ClientException, e:
            LOG.exception("ClientException in DeleteRule")
            messages.error(request, _('Error authorizing security group: %s')
                                     % e.message)
Example #7
0
    def handle(self, request, data):
        security_group_rule_id = data['security_group_rule_id']
        tenant_id = data['tenant_id']
        try:
            LOG.info('Delete security_group_rule: "%s"' % data)

            security_group = api.security_group_rule_delete(
                request, security_group_rule_id)
            messages.info(
                request,
                _('Successfully deleted rule: %s') % security_group_rule_id)
        except novaclient_exceptions.ClientException, e:
            LOG.exception("ClientException in DeleteRule")
            messages.error(
                request,
                _('Error authorizing security group: %s') % e.message)
Example #8
0
 def delete(self, request, obj_id):
     api.security_group_rule_delete(request, obj_id)
Example #9
0
 def delete(self, request, obj_id):
     api.security_group_rule_delete(request, obj_id)