Jacek Caban : crypt32: Added more cert duplicate and link tests.
Alexandre Julliard
julliard at winehq.org
Thu Oct 17 13:51:49 CDT 2013
Module: wine
Branch: master
Commit: e7eeef49ff884e41178f4c2a969dfedb2608cce0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e7eeef49ff884e41178f4c2a969dfedb2608cce0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Oct 17 11:06:59 2013 +0200
crypt32: Added more cert duplicate and link tests.
---
dlls/crypt32/tests/cert.c | 77 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/dlls/crypt32/tests/cert.c b/dlls/crypt32/tests/cert.c
index dfb6921..a96a75f 100644
--- a/dlls/crypt32/tests/cert.c
+++ b/dlls/crypt32/tests/cert.c
@@ -680,8 +680,8 @@ static void testCreateCert(void)
static void testDupCert(void)
{
- HCERTSTORE store;
- PCCERT_CONTEXT context, dupContext;
+ PCCERT_CONTEXT context, dupContext, storeContext, storeContext2, context2;
+ HCERTSTORE store, store2;
BOOL ret;
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
@@ -719,11 +719,83 @@ static void testDupCert(void)
}
CertCloseStore(store, 0);
+ context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
+ ok(context != NULL, "CertCreateCertificateContext failed\n");
+
+ dupContext = CertDuplicateCertificateContext(context);
+ ok(dupContext == context, "context != dupContext\n");
+
+ CertFreeCertificateContext(dupContext);
+
+ store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
+ ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+
+ ret = CertAddCertificateContextToStore(store, context, CERT_STORE_ADD_NEW, &storeContext);
+ ok(ret, "CertAddCertificateContextToStore failed\n");
+ ok(storeContext != NULL && storeContext != context, "unexpected storeContext\n");
+ ok(storeContext->hCertStore == store, "unexpected hCertStore\n");
+
+ ok(storeContext->pbCertEncoded != context->pbCertEncoded, "unexpected pbCertEncoded\n");
+ ok(storeContext->cbCertEncoded == context->cbCertEncoded, "unexpected cbCertEncoded\n");
+ ok(storeContext->pCertInfo != context->pCertInfo, "unexpected pCertInfo\n");
+
+ store2 = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
+ ok(store2 != NULL, "CertOpenStore failed: %d\n", GetLastError());
+
+ ret = CertAddCertificateContextToStore(store2, storeContext, CERT_STORE_ADD_NEW, &storeContext2);
+ ok(ret, "CertAddCertificateContextToStore failed\n");
+ ok(storeContext2 != NULL && storeContext2 != storeContext, "unexpected storeContext\n");
+ ok(storeContext2->hCertStore == store2, "unexpected hCertStore\n");
+
+ ok(storeContext2->pbCertEncoded != storeContext->pbCertEncoded, "unexpected pbCertEncoded\n");
+ ok(storeContext2->cbCertEncoded == storeContext->cbCertEncoded, "unexpected cbCertEncoded\n");
+ ok(storeContext2->pCertInfo != storeContext->pCertInfo, "unexpected pCertInfo\n");
+
+ CertFreeCertificateContext(storeContext2);
+ CertFreeCertificateContext(storeContext);
+
+ context2 = CertCreateCertificateContext(X509_ASN_ENCODING, certWithUsage, sizeof(certWithUsage));
+ ok(context2 != NULL, "CertCreateCertificateContext failed\n");
+
+ ok(context2->hCertStore == context->hCertStore, "Unexpected hCertStore\n");
+
+ CertFreeCertificateContext(context2);
+ CertFreeCertificateContext(context);
+
+ CertCloseStore(store, 0);
+ CertCloseStore(store2, 0);
+
SetLastError(0xdeadbeef);
context = CertDuplicateCertificateContext(NULL);
ok(context == NULL, "Expected context to be NULL\n");
}
+static void testLinkCert(void)
+{
+ const CERT_CONTEXT *context, *link;
+ HCERTSTORE store;
+ BOOL ret;
+
+ context = CertCreateCertificateContext(X509_ASN_ENCODING, bigCert, sizeof(bigCert));
+ ok(context != NULL, "CertCreateCertificateContext failed\n");
+
+ store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, CERT_STORE_CREATE_NEW_FLAG, NULL);
+ ok(store != NULL, "CertOpenStore failed: %d\n", GetLastError());
+
+ ret = CertAddCertificateLinkToStore(store, context, CERT_STORE_ADD_NEW, &link);
+ ok(ret, "CertAddCertificateContextToStore failed\n");
+ ok(link != NULL && link != context, "unexpected storeContext\n");
+ ok(link->hCertStore == store, "unexpected hCertStore\n");
+
+ ok(link->pbCertEncoded == context->pbCertEncoded, "unexpected pbCertEncoded\n");
+ ok(link->cbCertEncoded == context->cbCertEncoded, "unexpected cbCertEncoded\n");
+ ok(link->pCertInfo == context->pCertInfo, "unexpected pCertInfo\n");
+
+ CertFreeCertificateContext(link);
+
+ CertCloseStore(store, 0);
+}
+
static BYTE subjectName3[] = { 0x30, 0x15, 0x31, 0x13, 0x30, 0x11, 0x06,
0x03, 0x55, 0x04, 0x03, 0x13, 0x0a, 0x52, 0x6f, 0x62, 0x20, 0x20, 0x4c, 0x61,
0x6e, 0x67, 0x00 };
@@ -3902,6 +3974,7 @@ START_TEST(cert)
testFindCert();
testGetSubjectCert();
testGetIssuerCert();
+ testLinkCert();
testCryptHashCert();
testCertSigs();
More information about the wine-cvs
mailing list