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>
This commit is contained in:
parent
7ec069d85f
commit
e07539d1ce
|
@ -401,33 +401,65 @@ static void test_calchash(void)
|
||||||
|
|
||||||
static void test_CryptCATOpen(void)
|
static void test_CryptCATOpen(void)
|
||||||
{
|
{
|
||||||
HANDLE hcat;
|
WCHAR filename[MAX_PATH], temp_path[MAX_PATH];
|
||||||
char empty[MAX_PATH];
|
HANDLE cat;
|
||||||
WCHAR emptyW[MAX_PATH];
|
DWORD flags;
|
||||||
HANDLE file;
|
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
FILE *file;
|
||||||
|
char buffer[10];
|
||||||
|
|
||||||
|
GetTempPathW(ARRAY_SIZE(temp_path), temp_path);
|
||||||
|
GetTempFileNameW(temp_path, L"cat", 0, filename);
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hcat = pCryptCATOpen(NULL, 0, 0, 0, 0);
|
cat = pCryptCATOpen(NULL, 0, 0, 0, 0);
|
||||||
ok(hcat == INVALID_HANDLE_VALUE, "CryptCATOpen succeeded\n");
|
ok(cat == INVALID_HANDLE_VALUE, "expected failure\n");
|
||||||
ok(GetLastError() == ERROR_INVALID_PARAMETER,
|
ok(GetLastError() == ERROR_INVALID_PARAMETER, "got error %u\n", GetLastError());
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
|
|
||||||
|
|
||||||
if (!GetTempFileNameA(CURR_DIR, "cat", 0, empty)) return;
|
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 = CreateFileA(empty, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
file = _wfopen(filename, L"w");
|
||||||
ok(file != INVALID_HANDLE_VALUE, "CreateFileA failed %u\n", GetLastError());
|
fputs("test text", file);
|
||||||
CloseHandle(file);
|
fclose(file);
|
||||||
MultiByteToWideChar(CP_ACP, 0, empty, -1, emptyW, MAX_PATH);
|
|
||||||
|
|
||||||
hcat = pCryptCATOpen(emptyW, 0, 0, 0, 0);
|
SetLastError(0xdeadbeef);
|
||||||
todo_wine
|
cat = pCryptCATOpen(filename, flags, 0, 0, 0);
|
||||||
ok(hcat != INVALID_HANDLE_VALUE, "Expected a correct handle\n");
|
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 = pCryptCATClose(hcat);
|
file = _wfopen(filename, L"r");
|
||||||
todo_wine
|
ret = fread(buffer, 1, sizeof(buffer), file);
|
||||||
ok(ret, "CryptCATClose failed\n");
|
if (flags & CRYPTCAT_OPEN_CREATENEW)
|
||||||
DeleteFileA(empty);
|
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;
|
static DWORD error_area;
|
||||||
|
|
Loading…
Reference in New Issue