Ejemplo n.º 1
0
    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']
            }
        }
Ejemplo n.º 2
0
    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]'}},
            ]
        }
Ejemplo n.º 3
0
Archivo: core.py Proyecto: zermelozf/h
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
Ejemplo n.º 4
0
    def test_unauthenticated(self):
        request = mock.Mock(authenticated_userid=None)
        authfilter = query.AuthFilter(request)

        assert authfilter({}) == {'term': {'shared': True}}