Ejemplo n.º 1
0
    def _make_app(self, enable_acl=False):
        # Determine where we are so we can set up paths in the config

        # NOTE(sbauza): Keystone middleware auth can be deactivated using
        #               enable_acl set to False

        if enable_acl:
            self.keystone_middleware = self.useFixture(
                fixture.AuthTokenFixture())

            self.keystone_middleware.add_token_data(token_id=self.ADMIN_TOKEN,
                                                    user_id='user_id1',
                                                    user_name='user_name1',
                                                    project_id='123i2910',
                                                    role_list=['admin'])
            self.keystone_middleware.add_token_data(token_id=self.MEMBER_TOKEN,
                                                    user_id='user_id2',
                                                    user_name='user-good',
                                                    project_id='project-good',
                                                    role_list=['Member'])

        self.config = {
            'app': {
                'modules': ['blazar.api.v2'],
                'root': 'blazar.api.root.RootController',
                'enable_acl': enable_acl,
            },
        }

        return pecan.testing.load_test_app(self.config)
Ejemplo n.º 2
0
 def setUp(self):
     super(AuthTest, self).setUp()
     self.auth_token_fixture = self.useFixture(
         ksm_fixture.AuthTokenFixture())
     self.auth_token_fixture.add_token_data(token_id=VALID_TOKEN,
                                            project_id='admin',
                                            role_list=['admin'],
                                            user_name='user_name',
                                            user_id='user_id',
                                            is_v2=True)
Ejemplo n.º 3
0
    def setUp(self):
        super(TestServer, self).setUp()

        # stub out auth_token middleware
        self.auth_token_fixture = self.useFixture(
            ksm_fixture.AuthTokenFixture())

        # create a token, mock it and save it and the ID for later use
        self.token = self.create_token()
        self.token_id = self.auth_token_fixture.add_token(self.token)
    def setUp(self):
        super(TestAPIACL, self).setUp()
        self.auth_token_fixture = self.useFixture(
            ksm_fixture.AuthTokenFixture())
        self.auth_token_fixture.add_token_data(
            token_id=VALID_TOKEN,
            # FIXME(morganfainberg): The project-id should be a proper uuid
            project_id='123i2910',
            role_list=['admin'],
            user_name='user_id2',
            user_id='user_id2',
            is_v2=True)
        self.auth_token_fixture.add_token_data(
            token_id=VALID_TOKEN2,
            # FIXME(morganfainberg): The project-id should be a proper uuid
            project_id='project-good',
            role_list=['Member'],
            user_name='user_id1',
            user_id='user_id1',
            is_v2=True)

        for cnt in [
                sample.Sample('meter.test',
                              'cumulative',
                              '',
                              1,
                              'user-good',
                              'project-good',
                              'resource-good',
                              timestamp=datetime.datetime(2012, 7, 2, 10, 40),
                              resource_metadata={
                                  'display_name': 'test-server',
                                  'tag': 'self.sample'
                              },
                              source='test_source'),
                sample.Sample('meter.mine',
                              'gauge',
                              '',
                              1,
                              'user-fred',
                              'project-good',
                              'resource-56',
                              timestamp=datetime.datetime(2012, 7, 2, 10, 43),
                              resource_metadata={
                                  'display_name': 'test-server',
                                  'tag': 'self.sample4'
                              },
                              source='test_source')
        ]:
            msg = utils.meter_message_from_counter(
                cnt, self.CONF.publisher.telemetry_secret)
            self.conn.record_metering_data(msg)
Ejemplo n.º 5
0
    def setUp(self):
        self.token_id = uuid.uuid4().hex
        self.user_id = uuid.uuid4().hex
        self.role_list = [uuid.uuid4().hex, uuid.uuid4().hex]
        super(AuthTokenFixtureTest, self).setUp()

        self.atm_fixture = self.useFixture(fixture.AuthTokenFixture())
        self.atm_fixture.add_token_data(token_id=self.token_id,
                                        user_id=self.user_id,
                                        role_list=self.role_list)
        self.set_middleware()
        self.middleware._app.expected_env = {
            'HTTP_X_USER_ID': self.user_id,
            'HTTP_X_ROLES': ','.join(self.role_list)}
Ejemplo n.º 6
0
 def setUp(self):
     super(TestAPIACL, self).setUp()
     self.auth_token_fixture = self.useFixture(
         ksm_fixture.AuthTokenFixture())
     self.auth_token_fixture.add_token_data(
         token_id=VALID_TOKEN,
         # FIXME(morganfainberg): The project-id should be a proper uuid
         project_id='123i2910',
         role_list=['admin'],
         user_name='user_id2',
         user_id='user_id2',
         is_v2=True)
     self.auth_token_fixture.add_token_data(
         token_id=VALID_TOKEN2,
         # FIXME(morganfainberg): The project-id should be a proper uuid
         project_id='project-good',
         role_list=['Member'],
         user_name='user_id1',
         user_id='user_id1',
         is_v2=True)