Exemple #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'
Exemple #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)
Exemple #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)
Exemple #4
0
def test_no_authorization_header():
    with pytest.raises(BadRequestError):
        validate_request_header(request, content=True, authorization=True)
Exemple #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")
Exemple #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)