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
e07539d1
Commit
e07539d1
authored
Sep 07, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
Sep 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wintrust/tests: Add more tests for CryptCATOpen() file modes.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
7ec069d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
22 deletions
+54
-22
crypt.c
dlls/wintrust/tests/crypt.c
+54
-22
No files found.
dlls/wintrust/tests/crypt.c
View file @
e07539d1
...
...
@@ -401,33 +401,65 @@ static void test_calchash(void)
static
void
test_CryptCATOpen
(
void
)
{
HANDLE
hcat
;
char
empty
[
MAX_PATH
];
WCHAR
emptyW
[
MAX_PATH
];
HANDLE
file
;
WCHAR
filename
[
MAX_PATH
],
temp_path
[
MAX_PATH
];
HANDLE
cat
;
DWORD
flags
;
BOOL
ret
;
FILE
*
file
;
char
buffer
[
10
];
SetLastError
(
0xdeadbeef
);
hcat
=
pCryptCATOpen
(
NULL
,
0
,
0
,
0
,
0
);
ok
(
hcat
==
INVALID_HANDLE_VALUE
,
"CryptCATOpen succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"Expected ERROR_INVALID_PARAMETER, got %08x
\n
"
,
GetLastError
());
if
(
!
GetTempFileNameA
(
CURR_DIR
,
"cat"
,
0
,
empty
))
return
;
GetTempPathW
(
ARRAY_SIZE
(
temp_path
),
temp_path
);
GetTempFileNameW
(
temp_path
,
L"cat"
,
0
,
filename
);
file
=
CreateFileA
(
empty
,
GENERIC_WRITE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
ok
(
file
!=
INVALID_HANDLE_VALUE
,
"CreateFileA failed %u
\n
"
,
GetLastError
()
);
CloseHandle
(
file
);
MultiByteToWideChar
(
CP_ACP
,
0
,
empty
,
-
1
,
emptyW
,
MAX_PATH
);
SetLastError
(
0xdeadbeef
);
cat
=
pCryptCATOpen
(
NULL
,
0
,
0
,
0
,
0
);
ok
(
cat
==
INVALID_HANDLE_VALUE
,
"expected failure
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"got error %u
\n
"
,
GetLastError
()
);
hcat
=
pCryptCATOpen
(
emptyW
,
0
,
0
,
0
,
0
);
todo_wine
ok
(
hcat
!=
INVALID_HANDLE_VALUE
,
"Expected a correct handle
\n
"
);
for
(
flags
=
0
;
flags
<
8
;
++
flags
)
{
SetLastError
(
0xdeadbeef
);
cat
=
pCryptCATOpen
(
filename
,
flags
,
0
,
0
,
0
);
if
(
flags
==
CRYPTCAT_OPEN_EXISTING
)
{
ok
(
cat
==
INVALID_HANDLE_VALUE
,
"flags %#x: expected failure
\n
"
,
flags
);
ok
(
GetLastError
()
==
ERROR_FILE_NOT_FOUND
,
"flags %#x: got error %u
\n
"
,
flags
,
GetLastError
());
ret
=
DeleteFileW
(
filename
);
ok
(
!
ret
,
"flags %#x: expected failure
\n
"
,
flags
);
}
else
{
todo_wine
ok
(
cat
!=
INVALID_HANDLE_VALUE
,
"flags %#x: expected success
\n
"
,
flags
);
todo_wine
ok
(
!
GetLastError
(),
"flags %#x: got error %u
\n
"
,
flags
,
GetLastError
());
ret
=
pCryptCATClose
(
cat
);
todo_wine
ok
(
ret
,
"flags %#x: failed to close file
\n
"
,
flags
);
ret
=
DeleteFileW
(
filename
);
todo_wine_if
(
flags
&
(
CRYPTCAT_OPEN_ALWAYS
|
CRYPTCAT_OPEN_CREATENEW
))
ok
(
ret
,
"flags %#x: failed to delete file, error %u
\n
"
,
flags
,
GetLastError
());
}
file
=
_wfopen
(
filename
,
L"w"
);
fputs
(
"test text"
,
file
);
fclose
(
file
);
ret
=
pCryptCATClose
(
hcat
);
todo_wine
ok
(
ret
,
"CryptCATClose failed
\n
"
);
DeleteFileA
(
empty
);
SetLastError
(
0xdeadbeef
);
cat
=
pCryptCATOpen
(
filename
,
flags
,
0
,
0
,
0
);
todo_wine
ok
(
cat
!=
INVALID_HANDLE_VALUE
,
"flags %#x: expected success
\n
"
,
flags
);
todo_wine
ok
(
!
GetLastError
(),
"flags %#x: got error %u
\n
"
,
flags
,
GetLastError
());
ret
=
pCryptCATClose
(
cat
);
todo_wine
ok
(
ret
,
"flags %#x: failed to close file
\n
"
,
flags
);
file
=
_wfopen
(
filename
,
L"r"
);
ret
=
fread
(
buffer
,
1
,
sizeof
(
buffer
),
file
);
if
(
flags
&
CRYPTCAT_OPEN_CREATENEW
)
todo_wine
ok
(
!
ret
,
"flags %#x: got %s
\n
"
,
flags
,
debugstr_an
(
buffer
,
ret
));
else
ok
(
ret
==
9
&&
!
strncmp
(
buffer
,
"test text"
,
ret
),
"flags %#x: got %s
\n
"
,
flags
,
debugstr_an
(
buffer
,
ret
));
fclose
(
file
);
ret
=
DeleteFileW
(
filename
);
ok
(
ret
,
"flags %#x: failed to delete file, error %u
\n
"
,
flags
,
GetLastError
());
}
}
static
DWORD
error_area
;
...
...
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