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

        self.config = {
            'app': {
                'root':
                'cloudpulse.api.controllers.root.RootController',
                'modules': ['cloudpulse.api'],
                'static_root':
                '%s/public' % root_dir,
                'template_path':
                '%s/api/templates' % root_dir,
                'enable_acl':
                enable_acl,
                'acl_public_routes': ['/', '/v1'],
                'hooks': [
                    hooks.ContextHook(),
                    hooks.RPCHook(),
                    hooks.NoExceptionTracebackHook(),
                ],
            },
        }

        return pecan.testing.load_test_app(self.config)
Ejemplo n.º 2
0
 def test_context_hook_before_method_auth_info(self):
     state = mock.Mock(request=fakes.FakePecanRequest())
     state.request.environ['keystone.token_info'] = 'assert_this'
     hook = hooks.ContextHook()
     hook.before(state)
     ctx = state.request.context
     self.assertIsInstance(ctx, cloudpulse_context.RequestContext)
     self.assertEqual(fakes.fakeAuthTokenHeaders['X-Auth-Token'],
                      ctx.auth_token)
     self.assertEqual('assert_this', ctx.auth_token_info)
Ejemplo n.º 3
0
 def test_context_hook_before_method(self):
     state = mock.Mock(request=fakes.FakePecanRequest())
     hook = hooks.ContextHook()
     hook.before(state)
     ctx = state.request.context
     self.assertIsInstance(ctx, cloudpulse_context.RequestContext)
     self.assertEqual(ctx.auth_token,
                      fakes.fakeAuthTokenHeaders['X-Auth-Token'])
     self.assertEqual(ctx.project_id,
                      fakes.fakeAuthTokenHeaders['X-Project-Id'])
     self.assertEqual(ctx.user_id, fakes.fakeAuthTokenHeaders['X-User-Id'])
     self.assertEqual(ctx.auth_url,
                      fakes.fakeAuthTokenHeaders['X-Auth-Url'])
     self.assertEqual(ctx.domain_name,
                      fakes.fakeAuthTokenHeaders['X-User-Domain-Name'])
     self.assertEqual(ctx.domain_id,
                      fakes.fakeAuthTokenHeaders['X-User-Domain-Id'])
Ejemplo n.º 4
0
# Copyright 2013 - Noorul Islam K M
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from cloudpulse.api import hooks

# Pecan Application Configurations
app = {
    'root':
    'cloudpulse.api.controllers.root.RootController',
    'modules': ['cloudpulse.api'],
    'debug':
    False,
    'hooks': [
        hooks.ContextHook(),
        hooks.RPCHook(),
        hooks.NoExceptionTracebackHook(),
    ],
    'acl_public_routes': ['/'],
}
Ejemplo n.º 5
0
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from cloudpulse.api import hooks

# Server Specific Configurations
server = {'port': '8080', 'host': '0.0.0.0'}

# Pecan Application Configurations
app = {
    'root': 'cloudpulse.api.controllers.root.RootController',
    'modules': ['cloudpulse.api'],
    'debug': True,
    'hooks': [hooks.ContextHook(), hooks.RPCHook()],
    'acl_public_routes': ['/'],
}

# Custom Configurations must be in Python dictionary format::
#
# foo = {'bar':'baz'}
#
# All configurations are accessible at::
# pecan.conf