Ejemplo n.º 1
0
    def test_when_request_has_no_json_body(self):
        request = mock.Mock()
        # Make request.json_body raise ValueError.
        type(request).json_body = mock.PropertyMock(side_effect=ValueError)
        annotations = resources.Annotations(request)

        assert annotations.__acl__() == [(security.Deny, security.Everyone,
                                          'create')]
Ejemplo n.º 2
0
    def test_when_request_has_a_group(self):
        request = mock.Mock()
        request.json_body = {'group': 'xyzabc'}
        annotations = resources.Annotations(request)

        assert annotations.__acl__() == [
            (security.Allow, 'group:xyzabc', 'create'),
            (security.Deny, security.Everyone, 'create')
        ]
Ejemplo n.º 3
0
    def test_when_request_contains_no_group(self):
        request = mock.Mock()
        request.json_body = {}
        annotations = resources.Annotations(request)

        assert annotations.__acl__() == [
            (security.Allow, security.Authenticated, 'create'),
            (security.Deny, security.Everyone, 'create')
        ]
Ejemplo n.º 4
0
    def test_when_request_has_non_object_body(self):
        request = mock.Mock()
        request.json_body = "flibble"
        annotations = resources.Annotations(request)

        assert annotations.__acl__() == [
            (security.Allow, security.Authenticated, 'create'),
            (security.Deny, security.Everyone, 'create')
        ]
Ejemplo n.º 5
0
    def test_when_request_has_group_world(self):
        request = mock.Mock()
        request.json_body = {'group': '__world__'}
        annotations = resources.Annotations(request)

        assert annotations.__acl__() == [
            (security.Allow, security.Authenticated, 'create'),
            (security.Deny, security.Everyone, 'create')
        ]