def test_world_in_principals(self): request = mock.Mock(effective_principals=['group:__world__', 'foo']) authfilter = query.AuthFilter(request) assert authfilter({}) == { 'terms': { 'permissions.read': ['group:__world__', 'foo'] } }
def test_authenticated(self): request = mock.Mock(authenticated_userid='acct:[email protected]') authfilter = query.AuthFilter(request) assert authfilter({}) == { 'or': [ {'term': {'shared': True}}, {'term': {'user_raw': 'acct:[email protected]'}}, ] }
def default_querybuilder(request): builder = query.Builder() builder.append_filter(query.AuthFilter(request)) builder.append_filter(query.UriFilter(request)) builder.append_filter(query.GroupFilter()) builder.append_filter(query.UserFilter()) builder.append_matcher(query.AnyMatcher()) builder.append_matcher(query.TagsMatcher()) for factory in request.registry.get(FILTERS_KEY, []): builder.append_filter(factory(request)) for factory in request.registry.get(MATCHERS_KEY, []): builder.append_matcher(factory(request)) return builder
def test_unauthenticated(self): request = mock.Mock(authenticated_userid=None) authfilter = query.AuthFilter(request) assert authfilter({}) == {'term': {'shared': True}}