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
a7cfe075
Commit
a7cfe075
authored
Oct 22, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Oct 23, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cryptnet: Add tests for CryptRetrieveObjectByUrl.
parent
2fbefb6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
137 additions
and
0 deletions
+137
-0
cryptnet.c
dlls/cryptnet/tests/cryptnet.c
+137
-0
No files found.
dlls/cryptnet/tests/cryptnet.c
View file @
a7cfe075
...
...
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <stdio.h>
#define NONAMELESSUNION
#include <windef.h>
#include <winbase.h>
...
...
@@ -234,7 +235,143 @@ static void test_getObjectUrl(void)
}
}
static
void
make_tmp_file
(
LPSTR
path
)
{
static
char
curr
[
MAX_PATH
]
=
{
0
};
char
temp
[
MAX_PATH
];
DWORD
dwNumberOfBytesWritten
;
HANDLE
hf
;
if
(
!*
curr
)
GetCurrentDirectoryA
(
MAX_PATH
,
curr
);
GetTempFileNameA
(
curr
,
"net"
,
0
,
temp
);
lstrcpyA
(
path
,
temp
);
hf
=
CreateFileA
(
path
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_ATTRIBUTE_NORMAL
,
NULL
);
WriteFile
(
hf
,
certWithCRLDistPoint
,
sizeof
(
certWithCRLDistPoint
),
&
dwNumberOfBytesWritten
,
NULL
);
CloseHandle
(
hf
);
}
static
void
test_retrieveObjectByUrl
(
void
)
{
BOOL
ret
;
char
tmpfile
[
MAX_PATH
*
2
],
*
ptr
,
url
[
MAX_PATH
+
8
];
CRYPT_BLOB_ARRAY
*
pBlobArray
;
PCCERT_CONTEXT
cert
;
PCCRL_CONTEXT
crl
;
HCERTSTORE
store
;
CRYPT_RETRIEVE_AUX_INFO
aux
=
{
0
};
FILETIME
ft
=
{
0
};
SetLastError
(
0xdeadbeef
);
ret
=
CryptRetrieveObjectByUrlA
(
NULL
,
NULL
,
0
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %08x
\n
"
,
GetLastError
());
make_tmp_file
(
tmpfile
);
ptr
=
strchr
(
tmpfile
,
':'
);
if
(
ptr
)
ptr
+=
2
;
/* skip colon and first slash */
else
ptr
=
tmpfile
;
snprintf
(
url
,
sizeof
(
url
),
"file:///%s"
,
ptr
);
do
{
ptr
=
strchr
(
url
,
'\\'
);
if
(
ptr
)
*
ptr
=
'/'
;
}
while
(
ptr
);
pBlobArray
=
(
CRYPT_BLOB_ARRAY
*
)
0xdeadbeef
;
ret
=
CryptRetrieveObjectByUrlA
(
url
,
NULL
,
0
,
0
,
(
void
**
)
&
pBlobArray
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptRetrieveObjectByUrlA failed: %d
\n
"
,
GetLastError
());
todo_wine
ok
(
pBlobArray
&&
pBlobArray
!=
(
CRYPT_BLOB_ARRAY
*
)
0xdeadbeef
,
"Expected a valid pointer
\n
"
);
if
(
pBlobArray
&&
pBlobArray
!=
(
CRYPT_BLOB_ARRAY
*
)
0xdeadbeef
)
{
ok
(
pBlobArray
->
cBlob
==
1
,
"Expected 1 blob, got %d
\n
"
,
pBlobArray
->
cBlob
);
ok
(
pBlobArray
->
rgBlob
[
0
].
cbData
==
sizeof
(
certWithCRLDistPoint
),
"Unexpected size %d
\n
"
,
pBlobArray
->
rgBlob
[
0
].
cbData
);
CryptMemFree
(
pBlobArray
);
}
cert
=
(
PCCERT_CONTEXT
)
0xdeadbeef
;
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CERTIFICATE
,
0
,
0
,
(
void
**
)
&
cert
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
cert
&&
cert
!=
(
PCCERT_CONTEXT
)
0xdeadbeef
,
"Expected a cert
\n
"
);
if
(
cert
&&
cert
!=
(
PCCERT_CONTEXT
)
0xdeadbeef
)
CertFreeCertificateContext
(
cert
);
crl
=
(
PCCRL_CONTEXT
)
0xdeadbeef
;
SetLastError
(
0xdeadbeef
);
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CRL
,
0
,
0
,
(
void
**
)
&
crl
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_NO_MATCH
,
"Expected CRYPT_E_NO_MATCH, got %08x
\n
"
,
GetLastError
());
todo_wine
ok
(
crl
==
NULL
,
"Expected CRL to be NULL
\n
"
);
if
(
crl
&&
crl
!=
(
PCCRL_CONTEXT
)
0xdeadbeef
)
CertFreeCRLContext
(
crl
);
store
=
(
HCERTSTORE
)
0xdeadbeef
;
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CAPI2_ANY
,
0
,
0
,
(
void
**
)
&
store
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptRetrieveObjectByUrlA failed: %d
\n
"
,
GetLastError
());
if
(
store
&&
store
!=
(
HCERTSTORE
)
0xdeadbeef
)
{
DWORD
certs
=
0
;
cert
=
NULL
;
do
{
cert
=
CertEnumCertificatesInStore
(
store
,
cert
);
if
(
cert
)
certs
++
;
}
while
(
cert
);
ok
(
certs
==
1
,
"Expected 1 cert, got %d
\n
"
,
certs
);
CertCloseStore
(
store
,
0
);
}
/* Are file URLs cached? */
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CERTIFICATE
,
CRYPT_CACHE_ONLY_RETRIEVAL
,
0
,
(
void
**
)
&
cert
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
ret
,
"CryptRetrieveObjectByUrlA failed: %08x
\n
"
,
GetLastError
());
if
(
cert
&&
cert
!=
(
PCCERT_CONTEXT
)
0xdeadbeef
)
CertFreeCertificateContext
(
cert
);
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CERTIFICATE
,
0
,
0
,
(
void
**
)
&
cert
,
NULL
,
NULL
,
NULL
,
&
aux
);
todo_wine
ok
(
ret
,
"CryptRetrieveObjectByUrlA failed: %08x
\n
"
,
GetLastError
());
if
(
cert
&&
cert
!=
(
PCCERT_CONTEXT
)
0xdeadbeef
)
CertFreeCertificateContext
(
cert
);
aux
.
cbSize
=
sizeof
(
aux
);
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CERTIFICATE
,
0
,
0
,
(
void
**
)
&
cert
,
NULL
,
NULL
,
NULL
,
&
aux
);
todo_wine
ok
(
ret
,
"CryptRetrieveObjectByUrlA failed: %08x
\n
"
,
GetLastError
());
aux
.
pLastSyncTime
=
&
ft
;
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CERTIFICATE
,
0
,
0
,
(
void
**
)
&
cert
,
NULL
,
NULL
,
NULL
,
&
aux
);
todo_wine
ok
(
ft
.
dwLowDateTime
||
ft
.
dwHighDateTime
,
"Expected last sync time to be set
\n
"
);
DeleteFileA
(
tmpfile
);
/* Okay, after being deleted, are file URLs still cached? */
SetLastError
(
0xdeadbeef
);
ret
=
CryptRetrieveObjectByUrlA
(
url
,
CONTEXT_OID_CERTIFICATE
,
CRYPT_CACHE_ONLY_RETRIEVAL
,
0
,
(
void
**
)
&
cert
,
NULL
,
NULL
,
NULL
,
NULL
);
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"Expected ERROR_FILE_NOT_FOUND, got %d
\n
"
,
GetLastError
());
}
START_TEST
(
cryptnet
)
{
test_getObjectUrl
();
test_retrieveObjectByUrl
();
}
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