[WINHTTP_WINETEST] Sync with Wine Staging 2.2. CORE-12823
authorAmine Khaldi <amine.khaldi@reactos.org>
Sun, 19 Mar 2017 17:05:35 +0000 (17:05 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sun, 19 Mar 2017 17:05:35 +0000 (17:05 +0000)
svn path=/trunk/; revision=74198

rostests/winetests/winhttp/url.c
rostests/winetests/winhttp/winhttp.c

index b76e82c..6bde1de 100644 (file)
@@ -118,7 +118,7 @@ static void WinHttpCreateUrl_test( void )
 {
     URL_COMPONENTS uc;
     WCHAR *url;
-    DWORD len;
+    DWORD len, err;
     BOOL ret;
 
     /* NULL components */
@@ -144,22 +144,33 @@ static void WinHttpCreateUrl_test( void )
     ok( !ret, "expected failure\n" );
     ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
 
-    /* valid components, NULL url */
+    /* valid components, NULL url, insufficient length */
+    len = 0;
     SetLastError( 0xdeadbeef );
     ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
     ok( !ret, "expected failure\n" );
-    ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
-        GetLastError() == ERROR_INVALID_PARAMETER,
-        "expected ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+    ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError() );
+    ok( len == 57, "expected len 57 got %u\n", len );
+
+    /* valid components, NULL url, sufficient length */
+    SetLastError( 0xdeadbeef );
+    len = 256;
+    ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
+    err = GetLastError();
+    ok( !ret, "expected failure\n" );
+    ok( err == ERROR_INVALID_PARAMETER || broken(err == ERROR_INSUFFICIENT_BUFFER) /* < win7 */,
+        "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+    ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
 
     /* correct size, NULL url */
     fill_url_components( &uc );
     SetLastError( 0xdeadbeef );
     ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
+    err = GetLastError();
     ok( !ret, "expected failure\n" );
-    ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER ||
-        GetLastError() == ERROR_INVALID_PARAMETER,
-        "expected ERROR_INSUFFICIENT_BUFFER or ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+    ok( err == ERROR_INVALID_PARAMETER || broken(err == ERROR_INSUFFICIENT_BUFFER) /* < win7 */,
+        "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
+    ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
 
     /* valid components, allocated url, short length */
     SetLastError( 0xdeadbeef );
index b961c83..20727be 100644 (file)
@@ -1002,7 +1002,10 @@ static void test_secure_connection(void)
     ok(req != NULL, "failed to open a request %u\n", GetLastError());
 
     ret = WinHttpSetOption(req, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0);
-    ok(!ret && GetLastError() == ERROR_WINHTTP_INCORRECT_HANDLE_STATE, "setting client cert context returned %x (%u)\n", ret, GetLastError());
+    err = GetLastError();
+    ok(!ret, "unexpected success\n");
+    ok(err == ERROR_WINHTTP_INCORRECT_HANDLE_STATE || broken(err == ERROR_INVALID_PARAMETER) /* winxp */,
+       "setting client cert context returned %u\n", err);
 
     ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0);
     err = GetLastError();
@@ -1028,7 +1031,8 @@ static void test_secure_connection(void)
     ok(req != NULL, "failed to open a request %u\n", GetLastError());
 
     ret = WinHttpSetOption(req, WINHTTP_OPTION_CLIENT_CERT_CONTEXT, WINHTTP_NO_CLIENT_CERT_CONTEXT, 0);
-    ok(ret, "failed to set client cert context %u\n", GetLastError());
+    err = GetLastError();
+    ok(ret || broken(!ret && err == ERROR_INVALID_PARAMETER) /* winxp */, "failed to set client cert context %u\n", err);
 
     WinHttpSetStatusCallback(req, cert_error, WINHTTP_CALLBACK_STATUS_SECURE_FAILURE, 0);
 
@@ -1220,21 +1224,28 @@ static DWORD get_default_proxy_reg_value( BYTE *buf, DWORD len, DWORD *type )
     return ret;
 }
 
-static void set_default_proxy_reg_value( BYTE *buf, DWORD len, DWORD type )
+static void set_proxy( REGSAM access, BYTE *buf, DWORD len, DWORD type )
 {
-    LONG l;
-    HKEY key;
+    HKEY hkey;
+    if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, NULL, 0, access, NULL, &hkey, NULL ))
+    {
+        if (len) RegSetValueExW( hkey, WinHttpSettings, 0, type, buf, len );
+        else RegDeleteValueW( hkey, WinHttpSettings );
+        RegCloseKey( hkey );
+    }
+}
 
-    l = RegCreateKeyExW( HKEY_LOCAL_MACHINE, Connections, 0, NULL, 0,
-        KEY_WRITE, NULL, &key, NULL );
-    if (!l)
+static void set_default_proxy_reg_value( BYTE *buf, DWORD len, DWORD type )
+{
+    BOOL wow64;
+    IsWow64Process( GetCurrentProcess(), &wow64 );
+    if (sizeof(void *) > sizeof(int) || wow64)
     {
-        if (len)
-            RegSetValueExW( key, WinHttpSettings, 0, type, buf, len );
-        else
-            RegDeleteValueW( key, WinHttpSettings );
-        RegCloseKey( key );
+        set_proxy( KEY_WRITE|KEY_WOW64_64KEY, buf, len, type );
+        set_proxy( KEY_WRITE|KEY_WOW64_32KEY, buf, len, type );
     }
+    else
+        set_proxy( KEY_WRITE, buf, len, type );
 }
 
 static void test_set_default_proxy_config(void)