[CRYPT32_WINETEST] Sync with Wine Staging 2.9. CORE-13362
[reactos.git] / rostests / winetests / crypt32 / crl.c
index b2831a3..4a15498 100644 (file)
@@ -120,6 +120,7 @@ static void testCreateCRL(void)
 static void testDupCRL(void)
 {
     PCCRL_CONTEXT context, dupContext;
+    BOOL res;
 
     context = CertDuplicateCRLContext(NULL);
     ok(context == NULL, "expected NULL\n");
@@ -128,18 +129,26 @@ static void testDupCRL(void)
     dupContext = CertDuplicateCRLContext(context);
     ok(dupContext != NULL, "expected a context\n");
     ok(dupContext == context, "expected identical context addresses\n");
-    CertFreeCRLContext(dupContext);
-    CertFreeCRLContext(context);
+
+    res = CertFreeCRLContext(dupContext);
+    ok(res, "CertFreeCRLContext failed\n");
+
+    res = CertFreeCRLContext(context);
+    ok(res, "CertFreeCRLContext failed\n");
+
+    res = CertFreeCRLContext(NULL);
+    ok(res, "CertFreeCRLContext failed\n");
 }
 
 static void testAddCRL(void)
 {
     HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
      CERT_STORE_CREATE_NEW_FLAG, NULL);
-    PCCRL_CONTEXT context;
+    PCCRL_CONTEXT context, context2;
     BOOL ret;
     DWORD GLE;
 
+    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
     if (!store) return;
 
     /* Bad CRL encoding type */
@@ -221,6 +230,24 @@ static void testAddCRL(void)
     ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
 
     CertCloseStore(store, 0);
+
+    store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
+    ok(store != NULL, "CertOpenStore failed\n");
+
+    context = CertCreateCRLContext(X509_ASN_ENCODING, CRL, sizeof(CRL));
+    ok(context != NULL, "CertCreateCRLContext failed\n");
+
+    ret = CertAddCRLContextToStore(store, context, CERT_STORE_ADD_NEW, &context2);
+    ok(ret, "CertAddCRLContextToStore failed\n");
+    ok(context2 != NULL && context2 != context, "unexpected context2\n");
+
+    ok(context->pbCrlEncoded != context2->pbCrlEncoded, "Unexpected pbCrlEncoded\n");
+    ok(context->cbCrlEncoded == context2->cbCrlEncoded, "Unexpected cbCrlEncoded\n");
+    ok(context->pCrlInfo != context2->pCrlInfo, "Unexpected pCrlInfo\n");
+
+    CertFreeCRLContext(context2);
+    CertFreeCRLContext(context);
+    CertCloseStore(store, 0);
 }
 
 static const BYTE v1CRLWithIssuerAndEntry[] = { 0x30, 0x44, 0x30, 0x02, 0x06,
@@ -399,21 +426,24 @@ static const BYTE rootSignedCRL[] = {
 
 static void testFindCRL(void)
 {
-    HCERTSTORE store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
-     CERT_STORE_CREATE_NEW_FLAG, NULL);
+    HCERTSTORE store;
     PCCRL_CONTEXT context;
     PCCERT_CONTEXT cert, endCert, rootCert;
     CRL_FIND_ISSUED_FOR_PARA issuedForPara = { NULL, NULL };
     DWORD count, revoked_count;
     BOOL ret;
 
-    if (!store) return;
     if (!pCertFindCRLInStore || !pCertFindCertificateInCRL)
     {
         win_skip("CertFindCRLInStore or CertFindCertificateInCRL not available\n");
         return;
     }
 
+    store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
+                          CERT_STORE_CREATE_NEW_FLAG, NULL);
+    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
+    if (!store) return;
+
     ret = CertAddEncodedCRLToStore(store, X509_ASN_ENCODING, signedCRL,
      sizeof(signedCRL), CERT_STORE_ADD_ALWAYS, NULL);
     ok(ret, "CertAddEncodedCRLToStore failed: %08x\n", GetLastError());
@@ -757,6 +787,7 @@ static void testGetCRLFromStore(void)
     DWORD flags;
     BOOL ret;
 
+    ok(store != NULL, "CertOpenStore failed: %08x\n", GetLastError());
     if (!store) return;
 
     /* Crash