Exemplo n.º 1
0
 def setUp(self):
     super(TestNoAuthMiddleware, self).setUp()
     self.stubs.Set(context, 'RequestContext', fakes.FakeRequestContext)
     fakes.FakeAuthManager.clear_fakes()
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_rate_limiting(self.stubs)
     fakes.stub_out_networking(self.stubs)
Exemplo n.º 2
0
 def setUp(self):
     super(CloudpipeTest, self).setUp()
     self.flags(allow_admin_api=True)
     self.app = fakes.wsgi_app()
     inner_app = v2.APIRouter()
     adm_ctxt = context.get_admin_context()
     self.app = auth.InjectContext(adm_ctxt, inner_app)
     route = inner_app.map.match('/1234/os-cloudpipe')
     self.controller = route['controller'].controller
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     self.stubs.Set(db, "instance_get_all_by_project",
                    db_instance_get_all_by_project)
     self.stubs.Set(db, "security_group_exists",
                    db_security_group_exists)
     self.stubs.SmartSet(self.controller.cloudpipe, "launch_vpn_instance",
                         pipelib_launch_vpn_instance)
     #self.stubs.SmartSet(self.controller.auth_manager, "get_project",
     #                    auth_manager_get_project)
     #self.stubs.SmartSet(self.controller.auth_manager, "get_projects",
     #                    auth_manager_get_projects)
     # NOTE(todd): The above code (just setting the stub, not invoking it)
     # causes failures in AuthManagerLdapTestCase.  So use a fake object.
     self.controller.auth_manager = FakeAuthManager()
     self.stubs.Set(utils, 'vpn_ping', utils_vpn_ping)
     self.context = context.get_admin_context()
     global EMPTY_INSTANCE_LIST
     EMPTY_INSTANCE_LIST = True
Exemplo n.º 3
0
 def setUp(self):
     super(CloudpipeTest, self).setUp()
     self.flags(allow_admin_api=True)
     self.app = fakes.wsgi_app()
     inner_app = v2.APIRouter()
     adm_ctxt = context.get_admin_context()
     self.app = auth.InjectContext(adm_ctxt, inner_app)
     route = inner_app.map.match('/1234/os-cloudpipe')
     self.controller = route['controller'].controller
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     self.stubs.Set(db, "instance_get_all_by_project",
                    db_instance_get_all_by_project)
     self.stubs.Set(db, "security_group_exists", db_security_group_exists)
     self.stubs.SmartSet(self.controller.cloudpipe, "launch_vpn_instance",
                         pipelib_launch_vpn_instance)
     #self.stubs.SmartSet(self.controller.auth_manager, "get_project",
     #                    auth_manager_get_project)
     #self.stubs.SmartSet(self.controller.auth_manager, "get_projects",
     #                    auth_manager_get_projects)
     # NOTE(todd): The above code (just setting the stub, not invoking it)
     # causes failures in AuthManagerLdapTestCase.  So use a fake object.
     self.controller.auth_manager = FakeAuthManager()
     self.stubs.Set(utils, 'vpn_ping', utils_vpn_ping)
     self.context = context.get_admin_context()
     global EMPTY_INSTANCE_LIST
     EMPTY_INSTANCE_LIST = True
Exemplo n.º 4
0
 def setUp(self):
     super(TestLimiter, self).setUp()
     self.stubs.Set(engine.api.x7.v2.auth.AuthMiddleware,
         '__init__', fakes.fake_auth_init)
     self.stubs.Set(context, 'RequestContext', fakes.FakeRequestContext)
     fakes.FakeAuthManager.clear_fakes()
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_networking(self.stubs)
Exemplo n.º 5
0
 def setUp(self):
     super(KeypairsTest, self).setUp()
     self.controller = keypairs.KeypairController()
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     self.stubs.Set(db, "key_pair_get_all_by_user",
                    db_key_pair_get_all_by_user)
     self.stubs.Set(db, "key_pair_create", db_key_pair_create)
     self.stubs.Set(db, "key_pair_destroy", db_key_pair_destroy)
     self.context = context.get_admin_context()
 def setUp(self):
     super(FixedIpTest, self).setUp()
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     self.stubs.Set(compute.api.API, "add_fixed_ip",
                    compute_api_add_fixed_ip)
     self.stubs.Set(compute.api.API, "remove_fixed_ip",
                    compute_api_remove_fixed_ip)
     self.stubs.Set(compute.api.API, 'get', compute_api_get)
     self.context = context.get_admin_context()
Exemplo n.º 7
0
 def setUp(self):
     super(FixedIpTest, self).setUp()
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     self.stubs.Set(compute.api.API, "add_fixed_ip",
                    compute_api_add_fixed_ip)
     self.stubs.Set(compute.api.API, "remove_fixed_ip",
                    compute_api_remove_fixed_ip)
     self.stubs.Set(compute.api.API, 'get', compute_api_get)
     self.context = context.get_admin_context()
Exemplo n.º 8
0
    def setUp(self):
        super(FlavorsTest, self).setUp()
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        self.stubs.Set(engine.compute.instance_types, "get_all_types",
                       fake_instance_type_get_all)
        self.stubs.Set(engine.compute.instance_types,
                       "get_instance_type_by_flavor_id",
                       fake_instance_type_get_by_flavor_id)

        self.controller = flavors.Controller()
Exemplo n.º 9
0
    def setUp(self):
        super(FlavorsTest, self).setUp()
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        self.stubs.Set(engine.compute.instance_types, "get_all_types",
                       fake_instance_type_get_all)
        self.stubs.Set(engine.compute.instance_types,
                       "get_instance_type_by_flavor_id",
                       fake_instance_type_get_by_flavor_id)

        self.controller = flavors.Controller()
Exemplo n.º 10
0
    def setUp(self):
        super(ZonesTest, self).setUp()
        self.flags(verbose=True, allow_admin_api=True)
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)

        self.stubs.Set(engine.db, 'zone_get', zone_get)
        self.stubs.Set(engine.db, 'zone_update', zone_update)
        self.stubs.Set(engine.db, 'zone_create', zone_create)
        self.stubs.Set(engine.db, 'zone_delete', zone_delete)

        self.controller = zones.Controller()
Exemplo n.º 11
0
 def setUp(self):
     super(KeypairsTest, self).setUp()
     self.controller = keypairs.KeypairController()
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     self.stubs.Set(db, "key_pair_get_all_by_user",
                    db_key_pair_get_all_by_user)
     self.stubs.Set(db, "key_pair_create",
                    db_key_pair_create)
     self.stubs.Set(db, "key_pair_destroy",
                    db_key_pair_destroy)
     self.context = context.get_admin_context()
Exemplo n.º 12
0
    def setUp(self):
        super(ZonesTest, self).setUp()
        self.flags(verbose=True, allow_admin_api=True)
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)

        self.stubs.Set(engine.db, 'zone_get', zone_get)
        self.stubs.Set(engine.db, 'zone_update', zone_update)
        self.stubs.Set(engine.db, 'zone_create', zone_create)
        self.stubs.Set(engine.db, 'zone_delete', zone_delete)

        self.controller = zones.Controller()
Exemplo n.º 13
0
    def setUp(self):
        super(VSAApiTest, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        fakes.FakeAuthManager.reset_fake_data()
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(vsa.api.API, "create", stub_vsa_create)
        self.stubs.Set(vsa.api.API, "delete", stub_vsa_delete)
        self.stubs.Set(vsa.api.API, "get", stub_vsa_get)
        self.stubs.Set(vsa.api.API, "get_all", stub_vsa_get_all)

        self.context = context.get_admin_context()
Exemplo n.º 14
0
    def setUp(self):
        super(VSAApiTest, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        fakes.FakeAuthManager.reset_fake_data()
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(vsa.api.API, "create", stub_vsa_create)
        self.stubs.Set(vsa.api.API, "delete", stub_vsa_delete)
        self.stubs.Set(vsa.api.API, "get", stub_vsa_get)
        self.stubs.Set(vsa.api.API, "get_all", stub_vsa_get_all)

        self.context = context.get_admin_context()
Exemplo n.º 15
0
    def setUp(self):
        super(SnapshotApiTest, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        fakes.FakeAuthManager.reset_fake_data()
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(volume.api.API, "create_snapshot", stub_snapshot_create)
        self.stubs.Set(volume.api.API, "create_snapshot_force",
            stub_snapshot_create)
        self.stubs.Set(volume.api.API, "delete_snapshot", stub_snapshot_delete)
        self.stubs.Set(volume.api.API, "get_snapshot", stub_snapshot_get)
        self.stubs.Set(volume.api.API, "get_all_snapshots",
            stub_snapshot_get_all)

        self.context = context.get_admin_context()
Exemplo n.º 16
0
    def setUp(self):
        super(UsersTest, self).setUp()
        self.flags(verbose=True, allow_admin_api=True)
        self.stubs.Set(users.Controller, '__init__', fake_init)
        self.stubs.Set(users.Controller, '_check_admin', fake_admin_check)
        fakes.FakeAuthManager.clear_fakes()
        fakes.FakeAuthManager.projects = dict(
            testacct=Project('testacct', 'testacct', 'id1', 'test', []))
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)

        fakemgr = fakes.FakeAuthManager()
        fakemgr.add_user(User('id1', 'guy1', 'acc1', 'secret1', False))
        fakemgr.add_user(User('id2', 'guy2', 'acc2', 'secret2', True))

        self.controller = users.Controller()
Exemplo n.º 17
0
    def setUp(self):
        super(AccountsTest, self).setUp()
        self.flags(verbose=True, allow_admin_api=True)
        self.stubs.Set(accounts.Controller, '__init__', fake_init)
        self.stubs.Set(accounts.Controller, '_check_admin', fake_admin_check)
        fakes.FakeAuthManager.clear_fakes()
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)

        fakemgr = fakes.FakeAuthManager()
        joeuser = User('id1', 'guy1', 'acc1', 'secret1', False)
        superuser = User('id2', 'guy2', 'acc2', 'secret2', True)
        fakemgr.add_user(joeuser)
        fakemgr.add_user(superuser)
        fakemgr.create_project('test1', joeuser)
        fakemgr.create_project('test2', superuser)
Exemplo n.º 18
0
    def setUp(self):
        super(AccountsTest, self).setUp()
        self.flags(verbose=True, allow_admin_api=True)
        self.stubs.Set(accounts.Controller, '__init__',
                       fake_init)
        self.stubs.Set(accounts.Controller, '_check_admin',
                       fake_admin_check)
        fakes.FakeAuthManager.clear_fakes()
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)

        fakemgr = fakes.FakeAuthManager()
        joeuser = User('id1', 'guy1', 'acc1', 'secret1', False)
        superuser = User('id2', 'guy2', 'acc2', 'secret2', True)
        fakemgr.add_user(joeuser)
        fakemgr.add_user(superuser)
        fakemgr.create_project('test1', joeuser)
        fakemgr.create_project('test2', superuser)
Exemplo n.º 19
0
    def setUp(self, test_obj=None, test_objs=None):
        super(VSAVolumeApiTest, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        fakes.FakeAuthManager.reset_fake_data()
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(engine.db, 'vsa_get', return_vsa)
        self.stubs.Set(vsa.api.API, "get_vsa_volume_type",
                       stub_get_vsa_volume_type)

        self.stubs.Set(volume.api.API, "update", stub_volume_update)
        self.stubs.Set(volume.api.API, "delete", stub_volume_delete)
        self.stubs.Set(volume.api.API, "get", stub_volume_get)
        self.stubs.Set(volume.api.API, "get_all", stub_volume_get_all)

        self.context = context.get_admin_context()
        self.test_obj = test_obj if test_obj else "volume"
        self.test_objs = test_objs if test_objs else "volumes"
Exemplo n.º 20
0
    def setUp(self, test_obj=None, test_objs=None):
        super(VSAVolumeApiTest, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        fakes.FakeAuthManager.reset_fake_data()
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(engine.db, 'vsa_get', return_vsa)
        self.stubs.Set(vsa.api.API, "get_vsa_volume_type",
                        stub_get_vsa_volume_type)

        self.stubs.Set(volume.api.API, "update", stub_volume_update)
        self.stubs.Set(volume.api.API, "delete", stub_volume_delete)
        self.stubs.Set(volume.api.API, "get", stub_volume_get)
        self.stubs.Set(volume.api.API, "get_all", stub_volume_get_all)

        self.context = context.get_admin_context()
        self.test_obj = test_obj if test_obj else "volume"
        self.test_objs = test_objs if test_objs else "volumes"
Exemplo n.º 21
0
    def setUp(self):
        super(UsersTest, self).setUp()
        self.flags(verbose=True, allow_admin_api=True)
        self.stubs.Set(users.Controller, '__init__',
                       fake_init)
        self.stubs.Set(users.Controller, '_check_admin',
                       fake_admin_check)
        fakes.FakeAuthManager.clear_fakes()
        fakes.FakeAuthManager.projects = dict(testacct=Project('testacct',
                                                               'testacct',
                                                               'id1',
                                                               'test',
                                                               []))
        fakes.FakeAuthDatabase.data = {}
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_auth(self.stubs)

        fakemgr = fakes.FakeAuthManager()
        fakemgr.add_user(User('id1', 'guy1', 'acc1', 'secret1', False))
        fakemgr.add_user(User('id2', 'guy2', 'acc2', 'secret2', True))

        self.controller = users.Controller()