コード例 #1
0
ファイル: test_utils.py プロジェクト: COSHPC/ironic
    def test_safe_rstrip(self):
        value = '/test/'
        rstripped_value = '/test'
        not_rstripped = '/'

        self.assertEqual(rstripped_value, utils.safe_rstrip(value, '/'))
        self.assertEqual(not_rstripped, utils.safe_rstrip(not_rstripped, '/'))
コード例 #2
0
ファイル: test_utils.py プロジェクト: ajya/ironic-fork
    def test_safe_rstrip(self):
        value = '/test/'
        rstripped_value = '/test'
        not_rstripped = '/'

        self.assertEqual(rstripped_value, utils.safe_rstrip(value, '/'))
        self.assertEqual(not_rstripped, utils.safe_rstrip(not_rstripped, '/'))
コード例 #3
0
ファイル: test_utils.py プロジェクト: bacaldwell/ironic
    def test_safe_rstrip(self):
        value = "/test/"
        rstripped_value = "/test"
        not_rstripped = "/"

        self.assertEqual(rstripped_value, utils.safe_rstrip(value, "/"))
        self.assertEqual(not_rstripped, utils.safe_rstrip(not_rstripped, "/"))
コード例 #4
0
ファイル: auth_token.py プロジェクト: Haomeng/ironic
    def __call__(self, env, start_response):
        path = utils.safe_rstrip(env.get('PATH_INFO'), '/')

        if path in self.public_api_routes:
            return self.app(env, start_response)

        return super(AuthTokenMiddleware, self).__call__(env, start_response)
コード例 #5
0
ファイル: auth_token.py プロジェクト: mshabdiz/ironic
    def __call__(self, env, start_response):
        path = utils.safe_rstrip(env.get('PATH_INFO'), '/')

        if path in self.public_api_routes:
            return self.app(env, start_response)

        return super(AuthTokenMiddleware, self).__call__(env, start_response)
コード例 #6
0
ファイル: test_utils.py プロジェクト: COSHPC/ironic
    def test_safe_rstrip_not_raises_exceptions(self):
        # Supplying an integer should normally raise an exception because it
        # does not save the rstrip() method.
        value = 10

        # In the case of raising an exception safe_rstrip() should return the
        # original value.
        self.assertEqual(value, utils.safe_rstrip(value))
コード例 #7
0
ファイル: test_utils.py プロジェクト: ajya/ironic-fork
    def test_safe_rstrip_not_raises_exceptions(self):
        # Supplying an integer should normally raise an exception because it
        # does not save the rstrip() method.
        value = 10

        # In the case of raising an exception safe_rstrip() should return the
        # original value.
        self.assertEqual(value, utils.safe_rstrip(value))
コード例 #8
0
ファイル: auth_token.py プロジェクト: JoProvost/ironic
    def __call__(self, env, start_response):
        path = utils.safe_rstrip(env.get("PATH_INFO"), "/")

        # The information whether the API call is being performed against the
        # public API is required for some other components. Saving it to the
        # WSGI environment is reasonable thereby.
        env["is_public_api"] = any(map(lambda pattern: re.match(pattern, path), self.public_api_routes))

        if env["is_public_api"]:
            return self.app(env, start_response)

        return super(AuthTokenMiddleware, self).__call__(env, start_response)
コード例 #9
0
    def __call__(self, env, start_response):
        path = utils.safe_rstrip(env.get('PATH_INFO'), '/')

        # The information whether the API call is being performed against the
        # public API is required for some other components. Saving it to the
        # WSGI environment is reasonable thereby.
        env['is_public_api'] = any(map(lambda pattern: re.match(pattern, path),
                                       self.public_api_routes))

        if env['is_public_api']:
            return self._ironic_app(env, start_response)

        return super(AuthTokenMiddleware, self).__call__(env, start_response)
コード例 #10
0
ファイル: hooks.py プロジェクト: Haomeng/ironic
    def before(self, state):
        user_id = state.request.headers.get('X-User-Id')
        user_id = state.request.headers.get('X-User', user_id)
        tenant = state.request.headers.get('X-Tenant-Id')
        tenant = state.request.headers.get('X-Tenant', tenant)
        domain_id = state.request.headers.get('X-User-Domain-Id')
        domain_name = state.request.headers.get('X-User-Domain-Name')
        auth_token = state.request.headers.get('X-Auth-Token', None)
        creds = {'roles': state.request.headers.get('X-Roles', '').split(',')}

        is_admin = policy.check('admin', state.request.headers, creds)

        path = utils.safe_rstrip(state.request.path, '/')
        is_public_api = path in self.public_api_routes

        state.request.context = context.RequestContext(
            auth_token=auth_token,
            user=user_id,
            tenant=tenant,
            domain_id=domain_id,
            domain_name=domain_name,
            is_admin=is_admin,
            is_public_api=is_public_api)