Exemplo n.º 1
0
def test_valid_header_header():
    request.headers['Content-Type'] = 'application/json'
    request.headers['Authorization'] = 'Bearer token'
    try:
        token = validate_request_header(request,
                                        content=True,
                                        authorization=True)
    except Exception:
        pytest.fail("Failed to pass content type header")
    assert token == 'token'
Exemplo n.º 2
0
def test_valid_wrapper_null_token_authorization_header():
    # request has Content-Type key but invalid value
    request.headers['Authorization'] = 'Bearer '
    with pytest.raises(BadRequestError):
        validate_request_header(request, content=True, authorization=True)
Exemplo n.º 3
0
def test_invalid_value_authorization_header():
    # request has Content-Type key but invalid value
    request.headers['Authorization'] = 'blah'
    with pytest.raises(BadRequestError):
        validate_request_header(request, content=True, authorization=True)
Exemplo n.º 4
0
def test_no_authorization_header():
    with pytest.raises(BadRequestError):
        validate_request_header(request, content=True, authorization=True)
Exemplo n.º 5
0
def test_valid_content_header():
    request.headers['Content-Type'] = 'application/json'
    try:
        validate_request_header(request, content=True, authorization=False)
    except Exception:
        pytest.fail("Failed to pass content type header")
Exemplo n.º 6
0
def test_null_value_content_header():
    # request has Content-Type key but no value
    request.headers['Content-Type'] = ''
    with pytest.raises(BadRequestError):
        validate_request_header(request, content=True, authorization=True)