Esempio 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.get_path()

        self.config = {
            'app': {
                'root':
                'magnum.api.controllers.root.RootController',
                'modules': ['magnum.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)
Esempio n. 2
0
    def setUp(self):
        super(FunctionalTest, self).setUp()
        cfg.CONF.set_override("auth_version",
                              "v2.0",
                              group='keystone_authtoken')
        cfg.CONF.set_override("admin_user",
                              "admin",
                              group='keystone_authtoken')

        # Determine where we are so we can set up paths in the config
        self.config = {
            'app': {
                'root':
                'magnum.api.controllers.root.RootController',
                'modules': ['magnum.api'],
                'hooks': [
                    hooks.ContextHook(),
                    hooks.RPCHook(),
                    hooks.NoExceptionTracebackHook(),
                ],
            },
        }

        self.app = self._make_app()

        def reset_pecan():
            pecan.set_config({}, overwrite=True)

        self.addCleanup(reset_pecan)

        p = mock.patch('magnum.api.controllers.v1.Controller._check_version')
        self._check_version = p.start()
        self.addCleanup(p.stop)
Esempio n. 3
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, magnum_context.RequestContext)
     self.assertEqual(fakes.fakeAuthTokenHeaders['X-Auth-Token'],
                      ctx.auth_token)
     self.assertEqual('assert_this', ctx.auth_token_info)
Esempio n. 4
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, magnum_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'])
     self.assertIsNone(ctx.auth_token_info)
Esempio n. 5
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 magnum.api import hooks

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

# Custom Configurations must be in Python dictionary format::
#
# foo = {'bar':'baz'}
#
# All configurations are accessible at::
# pecan.conf
Esempio n. 6
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 magnum.api import hooks

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

# Pecan Application Configurations
app = {
    'root': 'magnum.api.controllers.root.RootController',
    'modules': ['magnum.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