Juan Lang : wintrust: Add tests for WVTAsn1SpcSpOpusInfoEncode.

Alexandre Julliard julliard at winehq.org
Wed Dec 10 07:41:49 CST 2008


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

Author: Juan Lang <juan.lang at gmail.com>
Date:   Tue Dec  9 15:59:56 2008 -0800

wintrust: Add tests for WVTAsn1SpcSpOpusInfoEncode.

---

 dlls/wintrust/tests/asn.c |   85 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/dlls/wintrust/tests/asn.c b/dlls/wintrust/tests/asn.c
index 0cc02dc..5fb83d5 100644
--- a/dlls/wintrust/tests/asn.c
+++ b/dlls/wintrust/tests/asn.c
@@ -786,6 +786,90 @@ static void test_decodeCatNameValue(void)
     }
 }
 
+static const WCHAR progName[] = { 'A',' ','p','r','o','g','r','a','m',0 };
+static const BYTE spOpusInfoWithProgramName[] = {
+0x30,0x16,0xa0,0x14,0x80,0x12,0x00,0x41,0x00,0x20,0x00,0x70,0x00,0x72,0x00,0x6f,
+0x00,0x67,0x00,0x72,0x00,0x61,0x00,0x6d };
+static WCHAR winehq[] = { 'h','t','t','p',':','/','/','w','i','n','e','h','q',
+ '.','o','r','g','/',0 };
+static const BYTE spOpusInfoWithMoreInfo[] = {
+0x30,0x16,0xa1,0x14,0x80,0x12,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,
+0x65,0x68,0x71,0x2e,0x6f,0x72,0x67,0x2f };
+static const BYTE spOpusInfoWithPublisherInfo[] = {
+0x30,0x16,0xa2,0x14,0x80,0x12,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x77,0x69,0x6e,
+0x65,0x68,0x71,0x2e,0x6f,0x72,0x67,0x2f };
+
+static void test_encodeSpOpusInfo(void)
+{
+    BOOL ret;
+    LPBYTE buf;
+    DWORD size;
+    SPC_SP_OPUS_INFO info;
+    SPC_LINK moreInfo;
+
+    memset(&info, 0, sizeof(info));
+    ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
+     (LPBYTE)&info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
+    todo_wine
+    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    if (ret)
+    {
+        ok(size == sizeof(emptySequence), "unexpected size %d\n", size);
+        ok(!memcmp(buf, emptySequence, size), "unexpected value\n");
+        LocalFree(buf);
+    }
+    info.pwszProgramName = progName;
+    ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
+     (LPBYTE)&info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
+    todo_wine
+    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    if (ret)
+    {
+        ok(size == sizeof(spOpusInfoWithProgramName), "unexpected size %d\n",
+         size);
+        ok(!memcmp(buf, spOpusInfoWithProgramName, size),
+         "unexpected value\n");
+        LocalFree(buf);
+    }
+    info.pwszProgramName = NULL;
+    memset(&moreInfo, 0, sizeof(moreInfo));
+    info.pMoreInfo = &moreInfo;
+    SetLastError(0xdeadbeef);
+    ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
+     (LPBYTE)&info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
+    todo_wine
+    ok(!ret && GetLastError() == E_INVALIDARG,
+     "expected E_INVALIDARG, got %08x\n", GetLastError());
+    moreInfo.dwLinkChoice = SPC_URL_LINK_CHOICE;
+    moreInfo.pwszUrl = winehq;
+    ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
+     (LPBYTE)&info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
+    todo_wine
+    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    if (ret)
+    {
+        ok(size == sizeof(spOpusInfoWithMoreInfo),
+         "unexpected size %d\n", size);
+        ok(!memcmp(buf, spOpusInfoWithMoreInfo, size),
+         "unexpected value\n");
+        LocalFree(buf);
+    }
+    info.pMoreInfo = NULL;
+    info.pPublisherInfo = &moreInfo;
+    ret = pCryptEncodeObjectEx(X509_ASN_ENCODING, SPC_SP_OPUS_INFO_STRUCT,
+     (LPBYTE)&info, CRYPT_ENCODE_ALLOC_FLAG, NULL, &buf, &size);
+    todo_wine
+    ok(ret, "CryptEncodeObjectEx failed: %08x\n", GetLastError());
+    if (ret)
+    {
+        ok(size == sizeof(spOpusInfoWithPublisherInfo),
+         "unexpected size %d\n", size);
+        ok(!memcmp(buf, spOpusInfoWithPublisherInfo, size),
+         "unexpected value\n");
+        LocalFree(buf);
+    }
+}
+
 START_TEST(asn)
 {
     HMODULE hCrypt32 = LoadLibraryA("crypt32.dll");
@@ -802,6 +886,7 @@ START_TEST(asn)
     test_decodeCatMemberInfo();
     test_encodeCatNameValue();
     test_decodeCatNameValue();
+    test_encodeSpOpusInfo();
 
     FreeLibrary(hCrypt32);
 }




More information about the wine-cvs mailing list