crypt32: Reduce indent level of tests.

This commit is contained in:
Juan Lang 2006-09-25 20:24:44 -07:00 committed by Alexandre Julliard
parent 581c24ef4e
commit 09765f7db4
1 changed files with 460 additions and 465 deletions

View File

@ -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.
*/ */
@ -288,7 +288,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,
PCCERT_CONTEXT context, DWORD propID) PCCERT_CONTEXT context, DWORD propID)
@ -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)
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);
*/ */
@ -498,19 +497,18 @@ static void testCertProperties(void)
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);
@ -536,22 +534,21 @@ static void testDupCert(void)
} }
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)
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)
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)
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);
@ -701,7 +697,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 */
static const BYTE expiredCert[] = { 0x30, 0x82, 0x01, 0x33, 0x30, 0x81, 0xe2, static const BYTE expiredCert[] = { 0x30, 0x82, 0x01, 0x33, 0x30, 0x81, 0xe2,