Пример #1
0
 def test_add_scope_condition_as_string(self):
     r = Resource('/api')
     r.set_scope(http_method='GET', scope='View')
     assert r.dump() == {
         'path': '/api',
         'conditions': [{
             'httpMethods': ['GET'],
             'scopes': ['View']
         }]
     }
Пример #2
0
 def test_add_scope_condition_as_list(self):
     r = Resource('/api')
     r.set_scope('GET', ['view', 'all'])
     assert r.dump() == {
         'path': '/api',
         'conditions': [{
             'httpMethods': ['GET'],
             'scopes': ['view', 'all']
         }]
     }
Пример #3
0
 def test_adding_multiple_http_methods(self):
     r = Resource('/api')
     r.set_scope('GET', 'View')
     r.set_scope('POST', 'Add')
     assert r.dump() == {
         'path':
         '/api',
         'conditions': [{
             'httpMethods': ['GET'],
             'scopes': ['View']
         }, {
             'httpMethods': ['POST'],
             'scopes': ['Add']
         }]
     }
Пример #4
0
 def test_add_scope_expression(self):
     r = Resource('/api')
     exp = {
         "rule": {
             "or": [{
                 "var1": 1
             }, {
                 "var2": 2
             }]
         },
         "data": ["https://uma.scope/read", "https://uma.scope/all"]
     }
     r.set_expression('GET', exp)
     assert r.dump() == {
         'path': '/api',
         'conditions': [{
             'httpMethods': ['GET'],
             'scope_expression': exp
         }]
     }
Пример #5
0
 def test_adding_another_scope_for_same_http_method_updates_condition(self):
     r = Resource('/api')
     r.set_scope('GET', 'View')
     r.set_scope('GET', 'All')
     assert r.dump() == {
         'path': '/api',
         'conditions': [{
             'httpMethods': ['GET'],
             'scopes': ['View', 'All']
         }]
     }
Пример #6
0
 def test_repr(self):
     r = Resource('/api')
     assert repr(r) == '<Resource /api>'
Пример #7
0
 def test_string_representation_of_resource(self):
     r = Resource('/api')
     assert str(r) == '{"path": "/api", "conditions": []}'
Пример #8
0
 def test_dump_returns_dict(self):
     r = Resource('/api')
     assert r.dump() == {'path': '/api', 'conditions': []}