Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
461b1240
Commit
461b1240
authored
Jul 14, 2009
by
Juan Lang
Committed by
Alexandre Julliard
Jul 15, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Add tests for WinHttpSetDefaultProxyConfiguration.
parent
585e8dfb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
3 deletions
+132
-3
session.c
dlls/winhttp/session.c
+1
-2
Makefile.in
dlls/winhttp/tests/Makefile.in
+1
-1
winhttp.c
dlls/winhttp/tests/winhttp.c
+130
-0
No files found.
dlls/winhttp/session.c
View file @
461b1240
...
...
@@ -703,8 +703,7 @@ BOOL WINAPI WinHttpGetProxyForUrl( HINTERNET hsession, LPCWSTR url, WINHTTP_AUTO
*/
BOOL
WINAPI
WinHttpSetDefaultProxyConfiguration
(
WINHTTP_PROXY_INFO
*
info
)
{
FIXME
(
"%p [%u, %s, %s]
\n
"
,
info
,
info
->
dwAccessType
,
debugstr_w
(
info
->
lpszProxy
),
debugstr_w
(
info
->
lpszProxyBypass
));
FIXME
(
"%p
\n
"
,
info
);
return
TRUE
;
}
...
...
dlls/winhttp/tests/Makefile.in
View file @
461b1240
...
...
@@ -3,7 +3,7 @@ TOPOBJDIR = ../../..
SRCDIR
=
@srcdir@
VPATH
=
@srcdir@
TESTDLL
=
winhttp.dll
IMPORTS
=
winhttp kernel32
IMPORTS
=
winhttp
advapi32
kernel32
CTESTS
=
\
notification.c
\
...
...
dlls/winhttp/tests/winhttp.c
View file @
461b1240
...
...
@@ -24,6 +24,7 @@
#include <winbase.h>
#include <winhttp.h>
#include <wincrypt.h>
#include <winreg.h>
#include "wine/test.h"
...
...
@@ -817,6 +818,134 @@ static void test_request_parameter_defaults(void)
WinHttpCloseHandle
(
ses
);
}
static
const
WCHAR
Connections
[]
=
{
'S'
,
'o'
,
'f'
,
't'
,
'w'
,
'a'
,
'r'
,
'e'
,
'\\'
,
'M'
,
'i'
,
'c'
,
'r'
,
'o'
,
's'
,
'o'
,
'f'
,
't'
,
'\\'
,
'W'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
'\\'
,
'C'
,
'u'
,
'r'
,
'r'
,
'e'
,
'n'
,
't'
,
'V'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'\\'
,
'I'
,
'n'
,
't'
,
'e'
,
'r'
,
'n'
,
'e'
,
't'
,
' '
,
'S'
,
'e'
,
't'
,
't'
,
'i'
,
'n'
,
'g'
,
's'
,
'\\'
,
'C'
,
'o'
,
'n'
,
'n'
,
'e'
,
'c'
,
't'
,
'i'
,
'o'
,
'n'
,
's'
,
0
};
static
const
WCHAR
WinHttpSettings
[]
=
{
'W'
,
'i'
,
'n'
,
'H'
,
't'
,
't'
,
'p'
,
'S'
,
'e'
,
't'
,
't'
,
'i'
,
'n'
,
'g'
,
's'
,
0
};
static
DWORD
get_default_proxy_reg_value
(
BYTE
*
buf
,
DWORD
len
,
DWORD
*
type
)
{
LONG
l
;
HKEY
key
;
DWORD
ret
=
0
;
l
=
RegOpenKeyExW
(
HKEY_LOCAL_MACHINE
,
Connections
,
0
,
KEY_READ
,
&
key
);
if
(
!
l
)
{
DWORD
size
=
0
;
l
=
RegQueryValueExW
(
key
,
WinHttpSettings
,
NULL
,
type
,
NULL
,
&
size
);
if
(
!
l
)
{
if
(
size
<=
len
)
l
=
RegQueryValueExW
(
key
,
WinHttpSettings
,
NULL
,
type
,
buf
,
&
size
);
if
(
!
l
)
ret
=
size
;
}
RegCloseKey
(
key
);
}
return
ret
;
}
static
void
set_default_proxy_reg_value
(
BYTE
*
buf
,
DWORD
len
,
DWORD
type
)
{
LONG
l
;
HKEY
key
;
l
=
RegCreateKeyExW
(
HKEY_LOCAL_MACHINE
,
Connections
,
0
,
NULL
,
0
,
KEY_WRITE
,
NULL
,
&
key
,
NULL
);
if
(
!
l
)
{
RegSetValueExW
(
key
,
WinHttpSettings
,
0
,
type
,
buf
,
len
);
RegCloseKey
(
key
);
}
}
static
void
test_set_default_proxy_config
(
void
)
{
static
const
WCHAR
wideString
[]
=
{
0x226f
,
0x575b
,
0
};
static
const
WCHAR
normalString
[]
=
{
'f'
,
'o'
,
'o'
,
0
};
DWORD
type
,
len
;
BYTE
*
saved_proxy_settings
=
NULL
;
WINHTTP_PROXY_INFO
info
;
BOOL
ret
;
/* FIXME: it would be simpler to read the current settings using
* WinHttpGetDefaultProxyConfiguration and save them using
* WinHttpSetDefaultProxyConfiguration, but they appear to have a bug.
*
* If a proxy is configured in the registry, e.g. via 'proxcfg -p "foo"',
* the access type reported by WinHttpGetDefaultProxyConfiguration is 1,
* WINHTTP_ACCESS_TYPE_NO_PROXY, whereas it should be
* WINHTTP_ACCESS_TYPE_NAMED_PROXY.
* If WinHttpSetDefaultProxyConfiguration is called with dwAccessType = 1,
* the lpszProxy and lpszProxyBypass values are ignored.
* Thus, if a proxy is set with proxycfg, then calling
* WinHttpGetDefaultProxyConfiguration followed by
* WinHttpSetDefaultProxyConfiguration results in the proxy settings
* getting deleted from the registry.
*
* Instead I read the current registry value and restore it directly.
*/
len
=
get_default_proxy_reg_value
(
NULL
,
0
,
&
type
);
if
(
len
)
{
saved_proxy_settings
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
len
=
get_default_proxy_reg_value
(
saved_proxy_settings
,
len
,
&
type
);
}
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpSetDefaultProxyConfiguration
(
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
/* test with invalid access type */
info
.
dwAccessType
=
0xdeadbeef
;
info
.
lpszProxy
=
info
.
lpszProxyBypass
=
NULL
;
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpSetDefaultProxyConfiguration
(
&
info
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
/* at a minimum, the proxy server must be set */
info
.
dwAccessType
=
WINHTTP_ACCESS_TYPE_NAMED_PROXY
;
info
.
lpszProxy
=
info
.
lpszProxyBypass
=
NULL
;
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpSetDefaultProxyConfiguration
(
&
info
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
info
.
lpszProxyBypass
=
normalString
;
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpSetDefaultProxyConfiguration
(
&
info
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
/* the proxy server can't have wide characters */
info
.
lpszProxy
=
wideString
;
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpSetDefaultProxyConfiguration
(
&
info
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
info
.
lpszProxy
=
normalString
;
SetLastError
(
0xdeadbeef
);
ret
=
WinHttpSetDefaultProxyConfiguration
(
&
info
);
ok
(
ret
,
"WinHttpSetDefaultProxyConfiguration failed: %d
\n
"
,
GetLastError
());
set_default_proxy_reg_value
(
saved_proxy_settings
,
len
,
type
);
}
START_TEST
(
winhttp
)
{
test_OpenRequest
();
...
...
@@ -827,4 +956,5 @@ START_TEST (winhttp)
test_secure_connection
();
test_request_parameter_defaults
();
test_QueryOption
();
test_set_default_proxy_config
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment