示例#1
0
async def test_should_return_error_with_wrong_credentials(
        playwright: Playwright, server: Server):
    server.set_auth("/empty.html", "user", "pass")
    request = await playwright.request.new_context(http_credentials={
        "username": "******",
        "password": "******"
    })
    response = await request.get(server.EMPTY_PAGE)
    assert response.status == 401
    assert response.ok is False
示例#2
0
async def test_should_support_global_http_credentials_option(
        playwright: Playwright, server: Server):
    server.set_auth("/empty.html", "user", "pass")
    request1 = await playwright.request.new_context()
    response1 = await request1.get(server.EMPTY_PAGE)
    assert response1.status == 401
    await response1.dispose()

    request2 = await playwright.request.new_context(http_credentials={
        "username": "******",
        "password": "******"
    })
    response2 = await request2.get(server.EMPTY_PAGE)
    assert response2.status == 200
    assert response2.ok is True
    await response2.dispose()