Пример #1
0
 def setUp(self):
     super(TestQuantumSecurityGroupRulesTestCase, self).setUp()
     id1 = "11111111-1111-1111-1111-111111111111"
     sg_template1 = test_security_groups.security_group_template(security_group_rules=[], id=id1)
     id2 = "22222222-2222-2222-2222-222222222222"
     sg_template2 = test_security_groups.security_group_template(security_group_rules=[], id=id2)
     self.controller_sg = security_groups.SecurityGroupController()
     quantum = get_client()
     quantum._fake_security_groups[id1] = sg_template1
     quantum._fake_security_groups[id2] = sg_template2
Пример #2
0
 def setUp(self):
     super(TestQuantumSecurityGroupRulesTestCase, self).setUp()
     id1 = '11111111-1111-1111-1111-111111111111'
     sg_template1 = test_security_groups.security_group_template(
         security_group_rules=[], id=id1)
     id2 = '22222222-2222-2222-2222-222222222222'
     sg_template2 = test_security_groups.security_group_template(
         security_group_rules=[], id=id2)
     quantum = get_client()
     quantum._fake_security_groups[id1] = sg_template1
     quantum._fake_security_groups[id2] = sg_template2
 def setUp(self):
     super(TestNeutronSecurityGroupRulesTestCase, self).setUp()
     id1 = '11111111-1111-1111-1111-111111111111'
     sg_template1 = test_security_groups.security_group_template(
         security_group_rules=[], id=id1)
     id2 = '22222222-2222-2222-2222-222222222222'
     sg_template2 = test_security_groups.security_group_template(
         security_group_rules=[], id=id2)
     self.controller_sg = security_groups.SecurityGroupController()
     neutron = get_client()
     neutron._fake_security_groups[id1] = sg_template1
     neutron._fake_security_groups[id2] = sg_template2
Пример #4
0
 def setUp(self):
     super(TestQuantumSecurityGroupRulesTestCase, self).setUp()
     id1 = '11111111-1111-1111-1111-111111111111'
     sg_template1 = test_security_groups.security_group_template(
         security_group_rules=[], id=id1)
     id2 = '22222222-2222-2222-2222-222222222222'
     sg_template2 = test_security_groups.security_group_template(
         security_group_rules=[], id=id2)
     self.controller_sg = security_groups.SecurityGroupController()
     quantum = get_client()
     quantum._fake_security_groups[id1] = sg_template1
     quantum._fake_security_groups[id2] = sg_template2
    def test_show(self):
        def fake_get_instance_security_groups(inst, context, id):
            return [{'name': 'fake-2-0'}, {'name': 'fake-2-1'}]

        self.stubs.Set(neutron_driver.SecurityGroupAPI,
                       'get_instance_security_groups',
                       fake_get_instance_security_groups)

        url = '/v2/fake/servers'
        image_uuid = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
        req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
        security_groups = [{'name': 'fake-2-0'}, {'name': 'fake-2-1'}]
        for security_group in security_groups:
            sg = test_security_groups.security_group_template(
                name=security_group['name'])
            self.controller.create(req, {'security_group': sg})
        server = dict(name='server_test', imageRef=image_uuid, flavorRef=2,
                      security_groups=security_groups)

        res = self._make_request(url, {'server': server})
        self.assertEqual(res.status_int, 202)
        server = self._get_server(res.body)
        for i, group in enumerate(self._get_groups(server)):
            name = 'fake-2-%s' % i
            self.assertEqual(group.get('name'), name)

        # Test that show (GET) returns the same information as create (POST)
        url = '/v2/fake/servers/' + test_security_groups.UUID3
        res = self._make_request(url)
        self.assertEqual(res.status_int, 200)
        server = self._get_server(res.body)

        for i, group in enumerate(self._get_groups(server)):
            name = 'fake-2-%s' % i
            self.assertEqual(group.get('name'), name)
Пример #6
0
    def test_show(self):
        def fake_get_instance_security_groups(inst, context, id):
            return [{'name': 'fake-2-0'}, {'name': 'fake-2-1'}]

        self.stubs.Set(neutron_driver.SecurityGroupAPI,
                       'get_instance_security_groups',
                       fake_get_instance_security_groups)

        url = '/v2/fake/servers'
        image_uuid = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
        req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
        security_groups = [{'name': 'fake-2-0'}, {'name': 'fake-2-1'}]
        for security_group in security_groups:
            sg = test_security_groups.security_group_template(
                name=security_group['name'])
            self.controller.create(req, {'security_group': sg})
        server = dict(name='server_test', imageRef=image_uuid, flavorRef=2,
                      security_groups=security_groups)

        res = self._make_request(url, {'server': server})
        self.assertEqual(res.status_int, 202)
        server = self._get_server(res.body)
        for i, group in enumerate(self._get_groups(server)):
            name = 'fake-2-%s' % i
            self.assertEqual(group.get('name'), name)

        # Test that show (GET) returns the same information as create (POST)
        url = '/v2/fake/servers/' + test_security_groups.UUID3
        res = self._make_request(url)
        self.assertEqual(res.status_int, 200)
        server = self._get_server(res.body)

        for i, group in enumerate(self._get_groups(server)):
            name = 'fake-2-%s' % i
            self.assertEqual(group.get('name'), name)
Пример #7
0
    def test_show(self):
        def fake_get_instance_security_groups(inst, context, id):
            return [{"name": "fake-2-0"}, {"name": "fake-2-1"}]

        self.stubs.Set(
            neutron_driver.SecurityGroupAPI, "get_instance_security_groups", fake_get_instance_security_groups
        )

        url = "/v2/fake/servers"
        image_uuid = "c905cedb-7281-47e4-8a62-f26bc5fc4c77"
        req = fakes.HTTPRequest.blank("/v2/fake/os-security-groups")
        security_groups = [{"name": "fake-2-0"}, {"name": "fake-2-1"}]
        for security_group in security_groups:
            sg = test_security_groups.security_group_template(name=security_group["name"])
            self.controller.create(req, {"security_group": sg})
        server = dict(name="server_test", imageRef=image_uuid, flavorRef=2, security_groups=security_groups)

        res = self._make_request(url, {"server": server})
        self.assertEqual(res.status_int, 202)
        server = self._get_server(res.body)
        for i, group in enumerate(self._get_groups(server)):
            name = "fake-2-%s" % i
            self.assertEqual(group.get("name"), name)

        # Test that show (GET) returns the same information as create (POST)
        url = "/v2/fake/servers/" + test_security_groups.UUID3
        res = self._make_request(url)
        self.assertEqual(res.status_int, 200)
        server = self._get_server(res.body)

        for i, group in enumerate(self._get_groups(server)):
            name = "fake-2-%s" % i
            self.assertEqual(group.get("name"), name)
Пример #8
0
 def test_create_add_existing_rules_by_group_id(self):
     sg = test_security_groups.security_group_template()
     req = fakes.HTTPRequest.blank("/v2/fake/os-security-groups")
     self.controller_sg.create(req, {"security_group": sg})
     rule = test_security_groups.security_group_rule_template(group=self.sg1["id"], parent_group_id=self.sg2["id"])
     req = fakes.HTTPRequest.blank("/v2/fake/os-security-group-rules")
     self.controller.create(req, {"security_group_rule": rule})
     self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, req, {"security_group_rule": rule})
 def test_create_add_existing_rules_by_cidr(self):
     sg = test_security_groups.security_group_template()
     req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
     self.controller_sg.create(req, {'security_group': sg})
     rule = test_security_groups.security_group_rule_template(
         cidr='15.0.0.0/8', parent_group_id=self.sg2['id'])
     req = fakes.HTTPRequest.blank('/v2/fake/os-security-group-rules')
     self.controller.create(req, {'security_group_rule': rule})
     self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,
                       req, {'security_group_rule': rule})
Пример #10
0
 def test_create_add_existing_rules_by_group_id(self):
     sg = test_security_groups.security_group_template()
     req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
     self.controller_sg.create(req, {'security_group': sg})
     rule = test_security_groups.security_group_rule_template(
         group=self.sg1['id'], parent_group_id=self.sg2['id'])
     req = fakes.HTTPRequest.blank('/v2/fake/os-security-group-rules')
     self.controller.create(req, {'security_group_rule': rule})
     self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,
                       req, {'security_group_rule': rule})
Пример #11
0
    def test_show(self):
        url = "/v2/fake/servers"
        image_uuid = "c905cedb-7281-47e4-8a62-f26bc5fc4c77"
        req = fakes.HTTPRequest.blank("/v2/fake/os-security-groups")
        security_groups = [{"name": "fake-2-0"}, {"name": "fake-2-1"}]
        for security_group in security_groups:
            sg = test_security_groups.security_group_template(name=security_group["name"])
            self.controller.create(req, {"security_group": sg})
        server = dict(name="server_test", imageRef=image_uuid, flavorRef=2, security_groups=security_groups)

        res = self._make_request(url, {"server": server})
        self.assertEqual(res.status_int, 202)
        server = self._get_server(res.body)
        for i, group in enumerate(self._get_groups(server)):
            name = "fake-2-%s" % i
            self.assertEqual(group.get("name"), name)
    def test_create(self):
        url = '/v2/fake/servers'
        image_uuid = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
        req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
        security_groups = [{'name': 'fake-2-0'}, {'name': 'fake-2-1'}]
        for security_group in security_groups:
            sg = test_security_groups.security_group_template(
                name=security_group['name'])
            self.controller.create(req, {'security_group': sg})

        server = dict(name='server_test', imageRef=image_uuid, flavorRef=2,
                      security_groups=security_groups)
        res = self._make_request(url, {'server': server})
        self.assertEqual(res.status_int, 202)
        server = self._get_server(res.body)
        for i, group in enumerate(self._get_groups(server)):
            name = 'fake-2-%s' % i
            self.assertEqual(group.get('name'), name)
Пример #13
0
    def test_create(self):
        url = '/v2/fake/servers'
        image_uuid = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
        req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
        security_groups = [{'name': 'fake-2-0'}, {'name': 'fake-2-1'}]
        for security_group in security_groups:
            sg = test_security_groups.security_group_template(
                name=security_group['name'])
            self.controller.create(req, {'security_group': sg})

        server = dict(name='server_test', imageRef=image_uuid, flavorRef=2,
                      security_groups=security_groups)
        res = self._make_request(url, {'server': server})
        self.assertEqual(res.status_int, 202)
        server = self._get_server(res.body)
        for i, group in enumerate(self._get_groups(server)):
            name = 'fake-2-%s' % i
            self.assertEqual(group.get('name'), name)
 def _create_sg_template(self, **kwargs):
     sg = test_security_groups.security_group_template(**kwargs)
     req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
     return self.controller.create(req, {'security_group': sg})
Пример #15
0
 def _create_sg_template(self, **kwargs):
     sg = test_security_groups.security_group_template(**kwargs)
     req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
     return self.controller.create(req, {'security_group': sg})