Exemple #1
0
def test_path_elements():
    assert utils.path_elements('/ows/proxy/lovely_bird') == [
        'ows', 'proxy', 'lovely_bird'
    ]
    assert utils.path_elements('/ows/proxy/lovely_bird/') == [
        'ows', 'proxy', 'lovely_bird'
    ]
    assert utils.path_elements('/ows/proxy/lovely_bird/ ') == [
        'ows', 'proxy', 'lovely_bird'
    ]
Exemple #2
0
 def get_token_param(self, request):
     token = None
     if 'access_token' in request.params:
         token = request.params['access_token']   # in params
     elif 'Access-Token' in request.headers:
         token = request.headers['Access-Token']  # in header
     else:  # in path
         elements = path_elements(request.path)
         if len(elements) > 1:  # there is always /ows/
             token = elements[-1]   # last path element
     return token
Exemple #3
0
 def get_token_param(self, request):
     token = None
     if 'token' in request.params:
         token = request.params['token']   # in params
     elif 'access_token' in request.params:
         token = request.params['access_token']   # in params
     elif 'Access-Token' in request.headers:
         token = request.headers['Access-Token']  # in header
     else:  # in path
         elements = path_elements(request.path)
         if len(elements) > 1:  # there is always /ows/
             token = elements[-1]   # last path element
     return token
Exemple #4
0
def test_path_elements():
    assert utils.path_elements('/ows/proxy/lovely_bird') == ['ows', 'proxy', 'lovely_bird']
    assert utils.path_elements('/ows/proxy/lovely_bird/') == ['ows', 'proxy', 'lovely_bird']
    assert utils.path_elements('/ows/proxy/lovely_bird/ ') == ['ows', 'proxy', 'lovely_bird']