Juan Lang : crypt32: Add some tests for updating decode messages.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 10 08:02:39 CDT 2007


Module: wine
Branch: master
Commit: acc0bec41ff75632442e38725e86a20f884e57fd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=acc0bec41ff75632442e38725e86a20f884e57fd

Author: Juan Lang <juan.lang at gmail.com>
Date:   Mon Jul  9 11:25:24 2007 -0700

crypt32: Add some tests for updating decode messages.

---

 dlls/crypt32/tests/msg.c |   72 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)

diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c
index 80ba79c..3c9fc7e 100644
--- a/dlls/crypt32/tests/msg.c
+++ b/dlls/crypt32/tests/msg.c
@@ -632,6 +632,77 @@ static void test_data_msg(void)
     test_data_msg_encoding();
 }
 
+static void test_decode_msg_update(void)
+{
+    HCRYPTMSG msg;
+    BOOL ret;
+    CMSG_STREAM_INFO streamInfo = { 0 };
+    DWORD i;
+
+    msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
+    /* Update with a full message in a final update */
+    ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE);
+    todo_wine
+    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    /* Can't update after a final update */
+    SetLastError(0xdeadbeef);
+    ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE);
+    todo_wine
+    ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
+     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+    CryptMsgClose(msg);
+
+    msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL);
+    /* Can't send a non-final update without streaming */
+    SetLastError(0xdeadbeef);
+    ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent),
+     FALSE);
+    todo_wine
+    ok(!ret && GetLastError() == CRYPT_E_MSG_ERROR,
+     "Expected CRYPT_E_MSG_ERROR, got %x\n", GetLastError());
+    /* A subsequent final update succeeds */
+    ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent), TRUE);
+    todo_wine
+    ok(ret, "CryptMsgUpdate failed: %x\n", GetLastError());
+    CryptMsgClose(msg);
+
+    msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo);
+    /* Updating a message that has a NULL stream callback fails */
+    SetLastError(0xdeadbeef);
+    ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent),
+     FALSE);
+    todo_wine
+    ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
+     "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError());
+    /* Changing the callback pointer after the fact yields the same error (so
+     * the message must copy the stream info, not just store a pointer to it)
+     */
+    streamInfo.pfnStreamOutput = nop_stream_output;
+    SetLastError(0xdeadbeef);
+    ret = CryptMsgUpdate(msg, dataEmptyContent, sizeof(dataEmptyContent),
+     FALSE);
+    todo_wine
+    ok(!ret && GetLastError() == STATUS_ACCESS_VIOLATION,
+     "Expected STATUS_ACCESS_VIOLATION, got %x\n", GetLastError());
+    CryptMsgClose(msg);
+
+    /* Updating the message byte by byte is legal */
+    msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, &streamInfo);
+    todo_wine {
+    for (i = 0, ret = TRUE; ret && i < sizeof(dataEmptyContent); i++)
+        ret = CryptMsgUpdate(msg, &dataEmptyContent[i], 1, FALSE);
+    ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError());
+    ret = CryptMsgUpdate(msg, NULL, 0, TRUE);
+    ok(ret, "CryptMsgUpdate failed on byte %d: %x\n", i, GetLastError());
+    }
+    CryptMsgClose(msg);
+}
+
+static void test_decode_msg(void)
+{
+    test_decode_msg_update();
+}
+
 START_TEST(msg)
 {
     /* Basic parameter checking tests */
@@ -642,4 +713,5 @@ START_TEST(msg)
 
     /* Message-type specific tests */
     test_data_msg();
+    test_decode_msg();
 }




More information about the wine-cvs mailing list