[10/10] wintrust: Add some tests.

Hans Leidekker hans at codeweavers.com
Mon Dec 22 07:20:51 CST 2008


diff --git a/dlls/wintrust/tests/crypt.c b/dlls/wintrust/tests/crypt.c
index 41cb39a..018d307 100644
--- a/dlls/wintrust/tests/crypt.c
+++ b/dlls/wintrust/tests/crypt.c
@@ -48,7 +48,7 @@ CATATTR2=0x10010001:attr2:value2
 hashme=.\winetest.cdf
 */
 
-const BYTE test_catalog[] = {
+static const BYTE test_catalog[] = {
     0x30, 0x82, 0x01, 0xbc, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0,
     0x82, 0x01, 0xad, 0x30, 0x82, 0x01, 0xa9, 0x02, 0x01, 0x01, 0x31, 0x00, 0x30, 0x82, 0x01, 0x9e,
     0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0a, 0x01, 0xa0, 0x82, 0x01, 0x8f, 0x30,
@@ -348,6 +348,7 @@ static void test_CryptCATAdminAddRemoveCatalog(void)
     static WCHAR basenameW[] = {'w','i','n','e','t','e','s','t','.','c','a','t',0};
     HCATADMIN hcatadmin;
     HCATINFO hcatinfo;
+    CATALOG_INFO info;
     WCHAR tmpfile[MAX_PATH];
     HANDLE file;
     DWORD error, written;
@@ -361,8 +362,7 @@ static void test_CryptCATAdminAddRemoveCatalog(void)
     }
 
     if (!GetTempFileNameW(current_dir, catW, 0, tmpfile)) return;
-    DeleteFileW(tmpfile);
-    file = CreateFileW(tmpfile, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
+    file = CreateFileW(tmpfile, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
     ok(file != INVALID_HANDLE_VALUE, "CreateFile failed %u\n", GetLastError());
     CloseHandle(file);
 
@@ -413,6 +413,11 @@ static void test_CryptCATAdminAddRemoveCatalog(void)
     hcatinfo = pCryptCATAdminAddCatalog(hcatadmin, tmpfile, basenameW, 0);
     ok(hcatinfo != NULL, "CryptCATAdminAddCatalog failed %u\n", GetLastError());
 
+    info.cbStruct = sizeof(info);
+    info.wszCatalogFile[0] = 0;
+    ret = CryptCATCatalogInfoFromContext(hcatinfo, &info, 0);
+    ok(ret, "CryptCATCatalogInfoFromContext failed %u\n", GetLastError());
+
     ret = pCryptCATAdminReleaseCatalogContext(hcatadmin, hcatinfo, 0);
     ok(ret, "CryptCATAdminReleaseCatalogContext failed %u\n", GetLastError());
 
@@ -425,6 +430,55 @@ static void test_CryptCATAdminAddRemoveCatalog(void)
     DeleteFileW(tmpfile);
 }
 
+static void test_catalog_properties(void)
+{
+    static const WCHAR catW[] = {'c','a','t',0};
+    static const WCHAR hashmeW[] = {'h','a','s','h','m','e',0};
+    static const GUID subject = {0xde351a42,0x8e59,0x11d0,{0x8c,0x47,0x00,0xc0,0x4f,0xc2,0x95,0xee}};
+
+    HANDLE hcat;
+    CRYPTCATMEMBER *m;
+    CRYPTCATATTRIBUTE *attr;
+    WCHAR catalogW[MAX_PATH];
+    DWORD written;
+    HANDLE file;
+    BOOL ret;
+
+    if (!GetTempFileNameW(current_dir, catW, 0, catalogW)) return;
+    file = CreateFileW(catalogW, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+    ok(file != INVALID_HANDLE_VALUE, "CreateFileW failed %u\n", GetLastError());
+    WriteFile(file, test_catalog, sizeof(test_catalog), &written, NULL);
+    CloseHandle(file);
+
+    hcat = CryptCATOpen(catalogW, 0, 0, 0, 0);
+    ok(hcat != INVALID_HANDLE_VALUE, "CryptCATOpen failed\n");
+
+    m = CryptCATEnumerateMember(hcat, NULL);
+    ok(m != NULL, "CryptCATEnumerateMember failed %u\n", GetLastError());
+
+    ok(m->cbStruct == sizeof(*m), "unexpected size\n");
+    todo_wine ok(!lstrcmpW(m->pwszReferenceTag, hashmeW), "unexpected tag\n");
+    ok(!memcmp(&m->gSubjectType, &subject, sizeof(subject)), "guid differs\n");
+    ok(!m->fdwMemberFlags, "got %x expected 0\n", m->fdwMemberFlags);
+    ok(m->dwCertVersion == 0x200, "got %x expected 0x200\n", m->dwCertVersion);
+    ok(!m->dwReserved, "got %x expected 0\n", m->dwReserved);
+    ok(m->hReserved == NULL, "got %p expected NULL\n", m->hReserved);
+
+    attr = CryptCATEnumerateAttr(hcat, m, NULL);
+    ok(attr == NULL, "CryptCATEnumerateAttr failed %u\n", GetLastError());
+
+    m = CryptCATEnumerateMember(hcat, m);
+    ok(m == NULL, "CryptCATEnumerateMember failed %u\n", GetLastError());
+
+    attr = CryptCATEnumerateAttr(hcat, m, NULL);
+    ok(attr == NULL, "CryptCATEnumerateAttr failed %u\n", GetLastError());
+
+    ret = CryptCATClose(hcat);
+    ok(ret, "CryptCATClose failed\n");
+
+    DeleteFileW(catalogW);
+}
+
 START_TEST(crypt)
 {
     int myARGC;
@@ -446,4 +500,5 @@ START_TEST(crypt)
     test_context();
     test_calchash();
     test_CryptCATAdminAddRemoveCatalog();
+    test_catalog_properties();
 }



More information about the wine-patches mailing list