Exemple #1
0
def test_request_get_header():
    request = Request()
    assert request.get_header("not-there") is None

    request.headers["a-header"] = "header-value"
    assert request.get_header("not-there") is None
    assert request.get_header("a-header") == "header-value"
    assert request.get_header("A-Header") == "header-value"
Exemple #2
0
def test_request_has_header():
    request = Request()
    assert not request.has_header("not-there")

    request.headers["a-header"] = "header-value"
    assert not request.has_header("not-there")
    assert request.has_header("a-header")
    assert request.has_header("A-Header")
Exemple #3
0
def test_request_get_credentials_valid():
    request = Request()
    assert request.get_credentials() is None

    username = "******"
    password = "******"
    request.headers["Authorization"] = "Basic " + "{0}:{1}".format(username, password).encode("base64")

    credentials = request.get_credentials()
    assert credentials.id == username
    assert credentials.secret == password
Exemple #4
0
def test_request_get_credentials_invalid():
    request = Request()
    request.headers["Authorization"] = "Invalid no-data"
    request.get_credentials()