[URLMON_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
[reactos.git] / rostests / winetests / urlmon / url.c
index b460f0c..d9a3811 100644 (file)
@@ -170,7 +170,6 @@ static const WCHAR wszWineHQSite[] =
 static const WCHAR wszWineHQIP[] =
     {'2','0','9','.','3','2','.','1','4','1','.','3',0};
 static const CHAR wszIndexHtmlA[] = "index.html";
-static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
 static const CHAR dwl_htmlA[] = "dwl.html";
 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
@@ -772,7 +771,7 @@ static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         }
         IHttpNegotiate2_Release(http_negotiate2);
         ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
-        ok(size == no_callback ? 512 : 13, "size=%d\n", size);
+        ok(size == (no_callback ? 512 : 13), "size=%d\n", size);
 
         if(!no_callback) {
             SET_EXPECT(QueryService_IHttpSecurity);
@@ -2573,6 +2572,7 @@ static BOOL test_bscholder(IBindStatusCallback *holder)
     IHttpNegotiate *http_negotiate, *http_negotiate_serv;
     IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
     IAuthenticate *authenticate, *authenticate_serv;
+    IInternetBindInfo *bind_info;
     IInternetProtocol *protocol;
     BINDINFO bindinfo = {sizeof(bindinfo)};
     BOOL ret = TRUE;
@@ -2687,6 +2687,16 @@ static BOOL test_bscholder(IBindStatusCallback *holder)
     IAuthenticate_Release(authenticate);
     IAuthenticate_Release(authenticate_serv);
 
+    hres = IBindStatusCallback_QueryInterface(holder, &IID_IInternetBindInfo, (void**)&bind_info);
+    ok(hres == S_OK || broken(hres == E_NOINTERFACE /* win2k */), "Could not get IInternetBindInfo interface: %08x\n", hres);
+
+    if(SUCCEEDED(hres)) {
+        hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_USER_AGENT, &wstr, 1, &dw);
+        ok(hres == E_NOINTERFACE, "GetBindString(BINDSTRING_USER_AGENT) failed: %08x\n", hres);
+
+        IInternetBindInfo_Release(bind_info);
+    }
+
     SET_EXPECT(OnStopBinding);
     hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
     ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
@@ -2861,7 +2871,7 @@ static void init_bind_test(int protocol, DWORD flags, DWORD t)
         url_a = (flags & BINDTEST_INVALID_CN) ? "https://209.46.25.134/favicon.ico" : "https://test.winehq.org/tests/hello.html";
         break;
     case FTP_TEST:
-        url_a = "ftp://ftp.winehq.org/pub/other/winelogo.xcf.tar.bz2";
+        url_a = "ftp://ftp.winehq.org/welcome.msg";
         break;
     default:
         url_a = "winetest:test";
@@ -3085,14 +3095,10 @@ static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
     if(!no_callback) {
         CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
         CHECK_CALLED(GetBindInfo);
-        if(abort_start)
-            todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol);
-        else
+        todo_wine_if(abort_start)
             CHECK_CALLED(QueryInterface_IInternetProtocol);
         if(!emulate_protocol) {
-            if(abort_start)
-                todo_wine CHECK_CALLED(QueryService_IInternetProtocol);
-            else
+            todo_wine_if(abort_start)
                 CHECK_CALLED(QueryService_IInternetProtocol);
         }
         CHECK_CALLED(OnStartBinding);
@@ -3412,10 +3418,7 @@ static void test_BindToObject(int protocol, DWORD flags, HRESULT exhres)
     }
 
     ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
-    if(test_protocol != HTTP_TEST || emulate_protocol || !(bindf & BINDF_ASYNCHRONOUS))
-        ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
-    else
-        IBindCtx_Release(bctx);
+    IBindCtx_Release(bctx);
 
     if(emulate_protocol)
         CoRevokeClassObject(regid);
@@ -3849,6 +3852,32 @@ static void register_protocols(void)
     IInternetSession_Release(session);
 }
 
+static BOOL can_do_https(void)
+{
+    HINTERNET ses, con, req;
+    BOOL ret;
+
+    ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
+    ok(ses != NULL, "InternetOpen failed\n");
+
+    con = InternetConnectA(ses, "test.winehq.org", INTERNET_DEFAULT_HTTPS_PORT,
+            NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(con != NULL, "InternetConnect failed\n");
+
+    req = HttpOpenRequestA(con, "GET", "/tests/hello.html", NULL, NULL, NULL,
+            INTERNET_FLAG_SECURE, 0);
+    ok(req != NULL, "HttpOpenRequest failed\n");
+
+    ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
+    ok(ret || broken(GetLastError() == ERROR_INTERNET_CANNOT_CONNECT),
+        "request failed: %u\n", GetLastError());
+
+    InternetCloseHandle(req);
+    InternetCloseHandle(con);
+    InternetCloseHandle(ses);
+    return ret;
+}
+
 START_TEST(url)
 {
     HMODULE hurlmon;
@@ -3928,25 +3957,34 @@ START_TEST(url)
         trace("file test (no callback)...\n");
         test_BindToStorage(FILE_TEST, BINDTEST_NO_CALLBACK, TYMED_ISTREAM);
 
-        trace("synchronous https test (invalid CN, dialog)\n");
-        onsecurityproblem_hres = S_FALSE;
-        http_is_first = TRUE;
-        test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
+        if(can_do_https()) {
+            trace("synchronous https test (invalid CN, dialog)\n");
+            onsecurityproblem_hres = S_FALSE;
+            http_is_first = TRUE;
+            test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
 
-        bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
+            bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
 
-        trace("asynchronous https test (invalid CN, fail)\n");
-        onsecurityproblem_hres = E_FAIL;
-        test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
+            trace("asynchronous https test (invalid CN, fail)\n");
+            onsecurityproblem_hres = E_FAIL;
+            test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
 
-        trace("asynchronous https test (invalid CN, accept)\n");
-        onsecurityproblem_hres = S_OK;
-        test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
+            trace("asynchronous https test (invalid CN, accept)\n");
+            onsecurityproblem_hres = S_OK;
+            test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
 
-        trace("asynchronous https test (invalid CN, dialog 2)\n");
-        onsecurityproblem_hres = S_FALSE;
-        test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
-        invalid_cn_accepted = FALSE;
+            trace("asynchronous https test (invalid CN, dialog 2)\n");
+            onsecurityproblem_hres = S_FALSE;
+            test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
+            invalid_cn_accepted = FALSE;
+
+            trace("asynchronous https test...\n");
+            test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
+        }else {
+            win_skip("Skipping https testt\n");
+        }
+
+        bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
 
         trace("winetest test (async switch)...\n");
         test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_ASYNC_SWITCH, TYMED_ISTREAM);
@@ -4001,9 +4039,6 @@ START_TEST(url)
         trace("winetest test (no callback)...\n");
         test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_NO_CALLBACK|BINDTEST_USE_CACHE, TYMED_ISTREAM);
 
-        trace("asynchronous https test...\n");
-        test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
-
         trace("emulated https test...\n");
         test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);