コード例 #1
0
 def test_default_groupfinder(self):
     settings = SETTINGS.copy()
     del settings["who.callback"]
     policy = WhoAuthenticationPolicy.from_settings(settings)
     req = make_request(HTTP_AUTHORIZATION=GOOD_AUTHZ["test"])
     self.assertEquals(sorted(policy.effective_principals(req)),
                       [Authenticated, Everyone, "test"])
コード例 #2
0
ファイル: tests.py プロジェクト: gengo/pyramid_whoauth
 def test_default_groupfinder(self):
     settings = SETTINGS.copy()
     del settings["who.callback"]
     policy = WhoAuthenticationPolicy.from_settings(settings)
     req = make_request(HTTP_AUTHORIZATION=GOOD_AUTHZ["test"])
     self.assertEquals(sorted(policy.effective_principals(req)),
                       [Authenticated, Everyone, "test"])
コード例 #3
0
ファイル: __init__.py プロジェクト: klpdotorg/ACIDity
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    #setup auth first
    authentication_policy = WhoAuthenticationPolicy.from_settings(settings)
    authorization_policy = EpsilonKuberAuthorizationPolicy()

    set_cache_regions_from_settings(settings)
    init_caches()

    config = Configurator(settings=settings,
                          root_factory=RootFactory,
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy)

    config.set_request_property(get_user, 'user', reify=True)
    config.set_request_property(get_group, 'group', reify=True)

    config.add_view('pyramid.view.append_slash_notfound_view',
                    context='pyramid.httpexceptions.HTTPNotFound')

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')

    config.add_route('row', '/tables/{tableid:\d+}/rows/{rowid:\d+}/{action}')
    config.add_route('row_create', '/tables/{tableid:\d+}/rows/create')
    config.add_route('row_get', '/tables/{tableid:\d+}/rows/{rowid:\d+}/')
    config.add_route('row_index', '/tables/{tableid:\d+}/rows/')
    config.add_route('table', '/tables/{tableid:\d+}/{action}')
    config.add_route('table_index', '/tables/')
    config.add_route('table_create', '/tables/create')
    config.add_route('type', '/types/{typeid:\d+}/{action}')
    config.add_route('type_index', '/types/')
    config.add_route('type_create', '/types/create')

    config.scan()

    load_epsilon_env(settings)

    log.info("Kuber is hoarding data for Epsilon %s" % epsilon_version)

    return HttpMethodOverrideMiddleware(config.make_wsgi_app())
コード例 #4
0
ファイル: tests.py プロジェクト: gengo/pyramid_whoauth
 def test_settings_from_config_file(self):
     with tempfile.NamedTemporaryFile() as f:
         f.write(bytearray(dedent("""
         [plugin:basicauth]
         use = repoze.who.plugins.basicauth:make_plugin
         realm = SomeRealm
         [plugin:dummy]
         use = pyramid_whoauth.tests:DummyAuthenticator
         [identifiers]
         plugins = basicauth
         [authenticators]
         plugins = dummy
         [challengers]
         plugins = basicauth
         """), "utf-8"))
         f.flush()
         settings = {"who.config_file": f.name}
         policy = WhoAuthenticationPolicy.from_settings(settings)
         req = make_request(HTTP_AUTHORIZATION=GOOD_AUTHZ["test"])
         self.assertEquals(policy.authenticated_userid(req), "test")
 def test_settings_from_config_file(self):
     with tempfile.NamedTemporaryFile() as f:
         f.write(
             dedent("""
         [plugin:basicauth]
         use = repoze.who.plugins.basicauth:make_plugin
         realm = SomeRealm
         [plugin:dummy]
         use = pyramid_whoauth.tests:DummyAuthenticator
         [identifiers]
         plugins = basicauth
         [authenticators]
         plugins = dummy
         [challengers]
         plugins = basicauth
         """))
         f.flush()
         settings = {"who.config_file": f.name}
         policy = WhoAuthenticationPolicy.from_settings(settings)
         req = make_request(HTTP_AUTHORIZATION=GOOD_AUTHZ["test"])
         self.assertEquals(policy.authenticated_userid(req), "test")
コード例 #6
0
 def test_default_api_factory(self):
     policy = WhoAuthenticationPolicy()
     self.assertEquals(policy.api_factory, None)
     req = make_request(HTTP_AUTHORIZATION=GOOD_AUTHZ["test"])
     self.assertEquals(sorted(policy.effective_principals(req)),
                       [Authenticated, Everyone, "test"])
コード例 #7
0
ファイル: tests.py プロジェクト: gengo/pyramid_whoauth
 def test_default_api_factory(self):
     policy = WhoAuthenticationPolicy()
     self.assertEquals(policy.api_factory, None)
     req = make_request(HTTP_AUTHORIZATION=GOOD_AUTHZ["test"])
     self.assertEquals(sorted(policy.effective_principals(req)),
                       [Authenticated, Everyone, "test"])