Module: wine Branch: master Commit: d2d26205bed2c3a1678af7998688ec7b80af71f7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d2d26205bed2c3a1678af79986...
Author: Aric Stewart aric@codeweavers.com Date: Tue Feb 17 10:29:08 2009 -0600
wininet: Complicated cookie value set/get tests.
---
dlls/wininet/tests/internet.c | 97 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c index f3277d3..fe3f477 100644 --- a/dlls/wininet/tests/internet.c +++ b/dlls/wininet/tests/internet.c @@ -244,6 +244,102 @@ static void test_get_cookie(void) ret ? "TRUE" : "FALSE", GetLastError()); }
+ +static void test_complicated_cookie(void) +{ + DWORD len; + BOOL ret; + + CHAR buffer[1024]; + + ret = InternetSetCookie("http://www.example.com/bar%22,NULL,%22A=B; domain=.example.com"); + ok(ret == TRUE,"InternetSetCookie failed\n"); + ret = InternetSetCookie("http://www.example.com/bar%22,NULL,%22C=D; domain=.example.com; path=/"); + ok(ret == TRUE,"InternetSetCookie failed\n"); + + /* Technically illegal! domain should require 2 dots, but native wininet accepts it */ + ret = InternetSetCookie("http://www.example.com%22,NULL,%22E=F; domain=example.com"); + ok(ret == TRUE,"InternetSetCookie failed\n"); + ret = InternetSetCookie("http://www.example.com%22,NULL,%22G=H; domain=.example.com; path=/foo"); + ok(ret == TRUE,"InternetSetCookie failed\n"); + ret = InternetSetCookie("http://www.example.com/bar.html%22,NULL,%22I=J; domain=.example.com"); + ok(ret == TRUE,"InternetSetCookie failed\n"); + ret = InternetSetCookie("http://www.example.com/bar/%22,NULL,%22K=L; domain=.example.com"); + ok(ret == TRUE,"InternetSetCookie failed\n"); + ret = InternetSetCookie("http://www.example.com/bar/%22,NULL,%22M=N; domain=.example.com; path=/foo/"); + ok(ret == TRUE,"InternetSetCookie failed\n"); + + len = 1024; + ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len); + ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); + ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); + ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); + ok(strstr(buffer,"G=H")==NULL,"G=H present\n"); + ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n"); + ok(strstr(buffer,"K=L")==NULL,"K=L present\n"); + ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); + + len = 1024; + ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len); + ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); + ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); + ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); + ok(strstr(buffer,"G=H")==NULL,"G=H present\n"); + ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n"); + ok(strstr(buffer,"K=L")==NULL,"K=L present\n"); + ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); + + len = 1024; + ret = InternetGetCookie("http://testing.example.com/foobar/", NULL, buffer, &len); + ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); + ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); + ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); + ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n"); + ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n"); + ok(strstr(buffer,"K=L")==NULL,"K=L present\n"); + ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); + + len = 1024; + ret = InternetGetCookie("http://testing.example.com/foo/bar", NULL, buffer, &len); + ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); + ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); + ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); + ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n"); + ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n"); + ok(strstr(buffer,"K=L")==NULL,"K=L present\n"); + ok(strstr(buffer,"M=N")!=NULL,"M=N missing\n"); + + len = 1024; + ret = InternetGetCookie("http://testing.example.com/barfoo", NULL, buffer, &len); + ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); + ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); + ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); + ok(strstr(buffer,"G=H")==NULL,"G=H present\n"); + ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n"); + ok(strstr(buffer,"K=L")==NULL,"K=L present\n"); + ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); + + len = 1024; + ret = InternetGetCookie("http://testing.example.com/barfoo/", NULL, buffer, &len); + ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); + ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); + ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); + ok(strstr(buffer,"G=H")==NULL,"G=H present\n"); + ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n"); + ok(strstr(buffer,"K=L")==NULL,"K=L present\n"); + ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); + + len = 1024; + ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len); + ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); + ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); + ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); + ok(strstr(buffer,"G=H")==NULL,"G=H present\n"); + ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n"); + ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n"); + ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); +} + static void test_null(void) { HINTERNET hi, hc; @@ -683,6 +779,7 @@ START_TEST(internet) test_InternetCanonicalizeUrlA(); test_InternetQueryOptionA(); test_get_cookie(); + test_complicated_cookie(); test_version(); test_null();