Beispiel #1
0
    def test_remove_security_service(self):
        security_dict1 = {'id': 'fake security service id1',
                          'project_id': self.fake_context.project_id,
                          'type': 'fake type'}

        db_api.share_network_create(self.fake_context, self.share_nw_dict)
        db_api.security_service_create(self.fake_context, security_dict1)
        db_api.share_network_add_security_service(self.fake_context,
                                                  self.share_nw_dict['id'],
                                                  security_dict1['id'])

        db_api.share_network_remove_security_service(self.fake_context,
                                                     self.share_nw_dict['id'],
                                                     security_dict1['id'])

        result = sqlalchemy_api.model_query(
            self.fake_context,
            models.ShareNetworkSecurityServiceAssociation).\
            filter_by(security_service_id=security_dict1['id']).\
            filter_by(share_network_id=self.share_nw_dict['id']).first()

        self.assertTrue(result is None)

        share_nw_ref = db_api.share_network_get(self.fake_context,
                                                self.share_nw_dict['id'])
        self.assertEqual(len(share_nw_ref['security_services']), 0)
Beispiel #2
0
    def test_add_security_service_association_error_status_active(self):
        security_dict1 = {
            "id": "fake security service id1",
            "project_id": self.fake_context.project_id,
            "type": "fake type",
        }

        db_api.share_network_create(self.fake_context, self.share_nw_dict)
        db_api.share_network_update(self.fake_context, self.share_nw_dict["id"], {"status": constants.STATUS_ACTIVE})
        db_api.security_service_create(self.fake_context, security_dict1)

        self.assertRaises(
            exception.ShareNetworkSecurityServiceAssociationError,
            db_api.share_network_add_security_service,
            self.fake_context,
            self.share_nw_dict["id"],
            security_dict1["id"],
        )

        assoc_ref = (
            sqlalchemy_api.model_query(self.fake_context, models.ShareNetworkSecurityServiceAssociation)
            .filter_by(security_service_id=security_dict1["id"])
            .filter_by(share_network_id=self.share_nw_dict["id"])
            .first()
        )

        self.assertTrue(assoc_ref is None)
    def test_remove_security_service(self):
        security_dict1 = {
            'id': 'fake security service id1',
            'project_id': self.fake_context.project_id,
            'type': 'fake type'
        }

        db_api.share_network_create(self.fake_context, self.share_nw_dict)
        db_api.security_service_create(self.fake_context, security_dict1)
        db_api.share_network_add_security_service(self.fake_context,
                                                  self.share_nw_dict['id'],
                                                  security_dict1['id'])

        db_api.share_network_remove_security_service(self.fake_context,
                                                     self.share_nw_dict['id'],
                                                     security_dict1['id'])

        result = sqlalchemy_api.model_query(
                self.fake_context,
                models.ShareNetworkSecurityServiceAssociation).\
                filter_by(security_service_id=security_dict1['id']).\
                filter_by(share_network_id=self.share_nw_dict['id']).first()

        self.assertTrue(result is None)

        share_nw_ref = db_api.share_network_get(self.fake_context,
                                                self.share_nw_dict['id'])
        self.assertEqual(len(share_nw_ref['security_services']), 0)
    def test_add_security_service_association_error_status_active(self):
        security_dict1 = {'id': 'fake security service id1',
                          'project_id': self.fake_context.project_id,
                          'type': 'fake type'}

        db_api.share_network_create(self.fake_context, self.share_nw_dict)
        db_api.share_network_update(self.fake_context,
                                    self.share_nw_dict['id'],
                                    {'status': constants.STATUS_ACTIVE})
        db_api.security_service_create(self.fake_context, security_dict1)

        self.assertRaises(
            exception.ShareNetworkSecurityServiceAssociationError,
            db_api.share_network_add_security_service,
            self.fake_context,
            self.share_nw_dict['id'],
            security_dict1['id'])

        assoc_ref = sqlalchemy_api.model_query(
                self.fake_context,
                models.ShareNetworkSecurityServiceAssociation).\
                filter_by(security_service_id=security_dict1['id']).\
                filter_by(share_network_id=self.share_nw_dict['id']).first()

        self.assertTrue(assoc_ref is None)
Beispiel #5
0
    def test_add_security_service(self):
        security_dict1 = {'id': 'fake security service id1',
                          'project_id': self.fake_context.project_id,
                          'type': 'fake type'}

        db_api.share_network_create(self.fake_context, self.share_nw_dict)
        db_api.security_service_create(self.fake_context, security_dict1)
        db_api.share_network_add_security_service(self.fake_context,
                                                  self.share_nw_dict['id'],
                                                  security_dict1['id'])

        result = db_api.model_query(
            self.fake_context,
            models.ShareNetworkSecurityServiceAssociation).\
            filter_by(security_service_id=security_dict1['id']).\
            filter_by(share_network_id=self.share_nw_dict['id']).first()

        self.assertTrue(result is not None)
Beispiel #6
0
    def test_add_security_service(self):
        security_dict1 = {
            "id": "fake security service id1",
            "project_id": self.fake_context.project_id,
            "type": "fake type",
        }

        db_api.share_network_create(self.fake_context, self.share_nw_dict)
        db_api.security_service_create(self.fake_context, security_dict1)
        db_api.share_network_add_security_service(self.fake_context, self.share_nw_dict["id"], security_dict1["id"])

        result = (
            sqlalchemy_api.model_query(self.fake_context, models.ShareNetworkSecurityServiceAssociation)
            .filter_by(security_service_id=security_dict1["id"])
            .filter_by(share_network_id=self.share_nw_dict["id"])
            .first()
        )

        self.assertTrue(result is not None)