Implement WinHTTP authentication

This commit is contained in:
Tobias Taschner
2018-10-25 23:33:05 +02:00
parent 1a34f3dab9
commit 4fd6091513
5 changed files with 145 additions and 20 deletions

View File

@@ -57,6 +57,7 @@ public:
{
switch (evt.GetState())
{
case wxWebRequest::State_Unauthorized:
case wxWebRequest::State_Completed:
case wxWebRequest::State_Failed:
case wxWebRequest::State_Cancelled:
@@ -124,6 +125,28 @@ TEST_CASE_METHOD(RequestFixture, "WebRequest", "[net][.]")
request->SetMethod("PUT");
Run();
}
SECTION("Server auth BASIC")
{
Create("/digest-auth/auth/wxtest/wxwidgets");
Run(wxWebRequest::State_Unauthorized, 401);
REQUIRE( request->GetAuthChallenge() != NULL );
request->GetAuthChallenge()->SetCredentials("wxtest", "wxwidgets");
loop.Run();
REQUIRE( request->GetResponse()->GetStatus() == 200 );
REQUIRE( request->GetState() == wxWebRequest::State_Completed );
}
SECTION("Server auth DIGEST")
{
Create("/digest-auth/auth/wxtest/wxwidgets");
Run(wxWebRequest::State_Unauthorized, 401);
REQUIRE( request->GetAuthChallenge() != NULL );
request->GetAuthChallenge()->SetCredentials("wxtest", "wxwidgets");
loop.Run();
REQUIRE( request->GetResponse()->GetStatus() == 200 );
REQUIRE( request->GetState() == wxWebRequest::State_Completed );
}
}
#endif // wxUSE_WEBREQUEST