Commit 09765f7d authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

crypt32: Reduce indent level of tests.

parent 581c24ef
...@@ -132,15 +132,15 @@ static const BYTE certWithUsage[] = { 0x30, 0x81, 0x93, 0x02, 0x01, 0x01, 0x30, ...@@ -132,15 +132,15 @@ static const BYTE certWithUsage[] = { 0x30, 0x81, 0x93, 0x02, 0x01, 0x01, 0x30,
static void testAddCert(void) static void testAddCert(void)
{ {
HCERTSTORE store; HCERTSTORE store;
HCERTSTORE collection;
PCCERT_CONTEXT context;
BOOL ret;
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL); CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
if (store != NULL) if (!store)
{ return;
HCERTSTORE collection;
PCCERT_CONTEXT context;
BOOL ret;
/* Weird--bad add disposition leads to an access violation in Windows. /* Weird--bad add disposition leads to an access violation in Windows.
*/ */
...@@ -287,7 +287,6 @@ static void testAddCert(void) ...@@ -287,7 +287,6 @@ static void testAddCert(void)
} }
CertCloseStore(store, 0); CertCloseStore(store, 0);
}
} }
static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID, static void checkHash(const BYTE *data, DWORD dataLen, ALG_ID algID,
...@@ -317,11 +316,6 @@ static void testCertProperties(void) ...@@ -317,11 +316,6 @@ static void testCertProperties(void)
{ {
PCCERT_CONTEXT context = CertCreateCertificateContext(X509_ASN_ENCODING, PCCERT_CONTEXT context = CertCreateCertificateContext(X509_ASN_ENCODING,
bigCert, sizeof(bigCert)); bigCert, sizeof(bigCert));
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
if (context)
{
DWORD propID, numProps, access, size; DWORD propID, numProps, access, size;
BOOL ret; BOOL ret;
BYTE hash[20] = { 0 }, hashProperty[20]; BYTE hash[20] = { 0 }, hashProperty[20];
...@@ -329,6 +323,11 @@ static void testCertProperties(void) ...@@ -329,6 +323,11 @@ static void testCertProperties(void)
CERT_KEY_CONTEXT keyContext; CERT_KEY_CONTEXT keyContext;
HCRYPTPROV csp; HCRYPTPROV csp;
ok(context != NULL, "CertCreateCertificateContext failed: %08lx\n",
GetLastError());
if (!context)
return;
/* This crashes /* This crashes
propID = CertEnumCertificateContextProperties(NULL, 0); propID = CertEnumCertificateContextProperties(NULL, 0);
*/ */
...@@ -497,20 +496,19 @@ static void testCertProperties(void) ...@@ -497,20 +496,19 @@ static void testCertProperties(void)
CryptReleaseContext(csp, 0); CryptReleaseContext(csp, 0);
CertFreeCertificateContext(context); CertFreeCertificateContext(context);
}
} }
static void testDupCert(void) static void testDupCert(void)
{ {
HCERTSTORE store; HCERTSTORE store;
PCCERT_CONTEXT context, dupContext;
BOOL ret;
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL); CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
if (store != NULL) if (!store)
{ return;
PCCERT_CONTEXT context, dupContext;
BOOL ret;
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context); bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, &context);
...@@ -535,23 +533,22 @@ static void testDupCert(void) ...@@ -535,23 +533,22 @@ static void testDupCert(void)
CertFreeCertificateContext(context); CertFreeCertificateContext(context);
} }
CertCloseStore(store, 0); CertCloseStore(store, 0);
}
} }
static void testFindCert(void) static void testFindCert(void)
{ {
HCERTSTORE store; HCERTSTORE store;
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
if (store)
{
PCCERT_CONTEXT context = NULL; PCCERT_CONTEXT context = NULL;
BOOL ret; BOOL ret;
CERT_INFO certInfo = { 0 }; CERT_INFO certInfo = { 0 };
CRYPT_HASH_BLOB blob; CRYPT_HASH_BLOB blob;
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
if (!store)
return;
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
bigCert, sizeof(bigCert), CERT_STORE_ADD_NEW, NULL); bigCert, sizeof(bigCert), CERT_STORE_ADD_NEW, NULL);
ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n", ok(ret, "CertAddEncodedCertificateToStore failed: %08lx\n",
...@@ -602,7 +599,7 @@ static void testFindCert(void) ...@@ -602,7 +599,7 @@ static void testFindCert(void)
if (context) if (context)
{ {
context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
CERT_FIND_ISSUER_NAME, &certInfo.Subject, context); CERT_FIND_SUBJECT_NAME, &certInfo.Subject, context);
ok(context == NULL, "Expected one cert only\n"); ok(context == NULL, "Expected one cert only\n");
} }
...@@ -623,7 +620,7 @@ static void testFindCert(void) ...@@ -623,7 +620,7 @@ static void testFindCert(void)
if (context) if (context)
{ {
context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
CERT_FIND_ISSUER_NAME, &certInfo.Subject, context); CERT_FIND_SUBJECT_CERT, &certInfo.Subject, context);
ok(context == NULL, "Expected one cert only\n"); ok(context == NULL, "Expected one cert only\n");
} }
...@@ -637,26 +634,25 @@ static void testFindCert(void) ...@@ -637,26 +634,25 @@ static void testFindCert(void)
if (context) if (context)
{ {
context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0, context = CertFindCertificateInStore(store, X509_ASN_ENCODING, 0,
CERT_FIND_ISSUER_NAME, &certInfo.Subject, context); CERT_FIND_SHA1_HASH, &certInfo.Subject, context);
ok(context == NULL, "Expected one cert only\n"); ok(context == NULL, "Expected one cert only\n");
} }
CertCloseStore(store, 0); CertCloseStore(store, 0);
}
} }
static void testGetSubjectCert(void) static void testGetSubjectCert(void)
{ {
HCERTSTORE store; HCERTSTORE store;
PCCERT_CONTEXT context1, context2;
CERT_INFO info = { 0 };
BOOL ret;
store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0, store = CertOpenStore(CERT_STORE_PROV_MEMORY, 0, 0,
CERT_STORE_CREATE_NEW_FLAG, NULL); CERT_STORE_CREATE_NEW_FLAG, NULL);
ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError()); ok(store != NULL, "CertOpenStore failed: %ld\n", GetLastError());
if (store != NULL) if (!store)
{ return;
PCCERT_CONTEXT context1, context2;
CERT_INFO info = { 0 };
BOOL ret;
ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING, ret = CertAddEncodedCertificateToStore(store, X509_ASN_ENCODING,
bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL); bigCert, sizeof(bigCert), CERT_STORE_ADD_ALWAYS, NULL);
...@@ -700,7 +696,6 @@ static void testGetSubjectCert(void) ...@@ -700,7 +696,6 @@ static void testGetSubjectCert(void)
CertFreeCertificateContext(context1); CertFreeCertificateContext(context1);
CertCloseStore(store, 0); CertCloseStore(store, 0);
}
} }
/* This expires in 1970 or so */ /* This expires in 1970 or so */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment