Example #1
0
def test_set_group_permissions_sets_read_permissions_for_group_annotations():
    annotation = {
        'user': '******',
        'group': 'xyzabc',
        'permissions': {
            'read': ['group:__world__']
        }
    }

    transform.set_group_permissions(annotation)

    assert annotation['permissions']['read'] == ['group:xyzabc']
Example #2
0
def test_set_group_permissions_sets_read_permissions_for_group_annotations():
    annotation = {
        'user': '******',
        'group': 'xyzabc',
        'permissions': {
            'read': ['group:__world__']
        }
    }

    transform.set_group_permissions(annotation)

    assert annotation['permissions']['read'] == ['group:xyzabc']
Example #3
0
def test_set_group_permissions_does_not_modify_non_group_annotations():
    original_annotation = {
        'user': '******',
        'permissions': {
            'read': ['acct:[email protected]']
        },
        'group': '__world__'
    }
    annotation_to_be_modified = copy.deepcopy(original_annotation)

    transform.set_group_permissions(annotation_to_be_modified)

    assert annotation_to_be_modified == original_annotation
Example #4
0
def test_set_group_permissions_does_not_modify_non_group_annotations():
    original_annotation = {
        'user': '******',
        'permissions': {
            'read': ['acct:[email protected]']
        },
        'group': '__world__'
    }
    annotation_to_be_modified = copy.deepcopy(original_annotation)

    transform.set_group_permissions(annotation_to_be_modified)

    assert annotation_to_be_modified == original_annotation
Example #5
0
def test_set_group_permissions_does_not_modify_annotations_with_no_permissions():
    annotations = [{
        'user': '******',
    },
    {
        'user': '******',
        'group': 'xyzabc',
    }]

    for ann in annotations:
        before = copy.deepcopy(ann)
        transform.set_group_permissions(ann)

        assert ann == before
Example #6
0
def test_set_group_permissions_does_not_modify_annotations_with_no_permissions():
    annotations = [{
        'user': '******',
    },
    {
        'user': '******',
        'group': 'xyzabc',
    }]

    for ann in annotations:
        before = copy.deepcopy(ann)
        transform.set_group_permissions(ann)

        assert ann == before
Example #7
0
File: storage.py Project: hashin/h
def _prepare(request, annotation):
    """
    Prepare the given annotation for storage.

    Scan the passed annotation for any target URIs or document metadata URIs
    and add normalized versions of these to the document.
    """
    fetcher = partial(fetch_annotation, request)
    transform.set_group_if_reply(annotation, fetcher=fetcher)
    transform.insert_group_if_none(annotation)
    transform.set_group_permissions(annotation)

    # FIXME: Remove this in a month or so, when all our clients have been
    # updated. -N 2015-09-25
    transform.fix_old_style_comments(annotation)

    # FIXME: When this becomes simply part of a search indexing operation, this
    # should probably not mutate its argument.
    transform.normalize_annotation_target_uris(annotation)

    # Fire an AnnotationBeforeSaveEvent so subscribers who wish to modify an
    # annotation before save can do so.
    event = AnnotationBeforeSaveEvent(request, annotation)
    request.registry.notify(event)
Example #8
0
def _prepare(request, annotation):
    """
    Prepare the given annotation for storage.

    Scan the passed annotation for any target URIs or document metadata URIs
    and add normalized versions of these to the document.
    """
    fetcher = partial(fetch_annotation, request)
    transform.set_group_if_reply(annotation, fetcher=fetcher)
    transform.insert_group_if_none(annotation)
    transform.set_group_permissions(annotation)

    # FIXME: Remove this in a month or so, when all our clients have been
    # updated. -N 2015-09-25
    transform.fix_old_style_comments(annotation)

    # FIXME: When this becomes simply part of a search indexing operation, this
    # should probably not mutate its argument.
    transform.normalize_annotation_target_uris(annotation)

    # Fire an AnnotationBeforeSaveEvent so subscribers who wish to modify an
    # annotation before save can do so.
    event = AnnotationBeforeSaveEvent(request, annotation)
    request.registry.notify(event)