39
39
CPPUNIT_ASSERT_EQUAL((size_t)3, cookies.size());
41
41
const Cookie& localhost = cookies[0];
42
CPPUNIT_ASSERT_EQUAL(std::string("localhost.local"), localhost.getDomain());
43
CPPUNIT_ASSERT_EQUAL(std::string("/"), localhost.getPath());
44
42
CPPUNIT_ASSERT_EQUAL(std::string("JSESSIONID"), localhost.getName());
45
43
CPPUNIT_ASSERT_EQUAL(std::string("123456789"), localhost.getValue());
46
CPPUNIT_ASSERT_EQUAL((time_t)INT32_MAX, localhost.getExpiry());
47
CPPUNIT_ASSERT_EQUAL(true, localhost.isSecureCookie());
44
CPPUNIT_ASSERT_EQUAL((time_t)INT32_MAX, localhost.getExpiryTime());
45
CPPUNIT_ASSERT(localhost.getPersistent());
46
CPPUNIT_ASSERT_EQUAL(std::string("localhost"), localhost.getDomain());
47
CPPUNIT_ASSERT(localhost.getHostOnly());
48
CPPUNIT_ASSERT_EQUAL(std::string("/"), localhost.getPath());
49
CPPUNIT_ASSERT(localhost.getSecure());
50
CPPUNIT_ASSERT_EQUAL((time_t)3000, localhost.getLastAccessTime());
51
CPPUNIT_ASSERT_EQUAL((time_t)3000, localhost.getCreationTime());
49
53
const Cookie& nullValue = cookies[1];
50
CPPUNIT_ASSERT_EQUAL(std::string(".null_value.com"), nullValue.getDomain());
51
CPPUNIT_ASSERT_EQUAL(std::string("/path/to"), nullValue.getPath());
52
54
CPPUNIT_ASSERT_EQUAL(std::string("uid"), nullValue.getName());
53
55
CPPUNIT_ASSERT_EQUAL(std::string(""), nullValue.getValue());
54
CPPUNIT_ASSERT_EQUAL((time_t)0, nullValue.getExpiry());
55
CPPUNIT_ASSERT_EQUAL(false, nullValue.isSecureCookie());
56
CPPUNIT_ASSERT_EQUAL((time_t)0, nullValue.getExpiryTime());
57
CPPUNIT_ASSERT(nullValue.getPersistent());
58
CPPUNIT_ASSERT_EQUAL(std::string("null_value.com"), nullValue.getDomain());
59
CPPUNIT_ASSERT(!nullValue.getHostOnly());
60
CPPUNIT_ASSERT_EQUAL(std::string("/path/to"), nullValue.getPath());
61
CPPUNIT_ASSERT(!nullValue.getSecure());
57
63
// See row id=3 has no name, so it is skipped.
59
65
const Cookie& overflowTime = cookies[2];
60
CPPUNIT_ASSERT_EQUAL(std::string(".overflow.time_t.org"),
66
CPPUNIT_ASSERT_EQUAL(std::string("foo"), overflowTime.getName());
67
CPPUNIT_ASSERT_EQUAL(std::string("bar"), overflowTime.getValue());
68
CPPUNIT_ASSERT((time_t)INT32_MAX <= overflowTime.getExpiryTime());
69
CPPUNIT_ASSERT(overflowTime.getPersistent());
70
CPPUNIT_ASSERT_EQUAL(std::string("overflow.time_t.org"),
61
71
overflowTime.getDomain());
72
CPPUNIT_ASSERT(!overflowTime.getHostOnly());
62
73
CPPUNIT_ASSERT_EQUAL(std::string("/path/to"), overflowTime.getPath());
63
CPPUNIT_ASSERT_EQUAL(std::string("foo"), overflowTime.getName());
64
CPPUNIT_ASSERT_EQUAL(std::string("bar"), overflowTime.getValue());
65
CPPUNIT_ASSERT_EQUAL((time_t)INT32_MAX, overflowTime.getExpiry());
66
CPPUNIT_ASSERT_EQUAL(false, overflowTime.isSecureCookie());
74
CPPUNIT_ASSERT(!overflowTime.getSecure());
76
// See row id=5 has bad path, so it is skipped.
69
79
void Sqlite3CookieParserTest::testMozParse_fileNotFound()
97
107
Sqlite3ChromiumCookieParser parser("chromium_cookies.sqlite");
98
108
std::vector<Cookie> cookies;
99
109
parser.parse(cookies);
110
CPPUNIT_ASSERT_EQUAL((size_t)3, cookies.size());
100
112
const Cookie& sfnet = cookies[0];
101
CPPUNIT_ASSERT_EQUAL(std::string(".aria2.sourceforge.net"),
113
CPPUNIT_ASSERT_EQUAL(std::string("mykey"), sfnet.getName());
114
CPPUNIT_ASSERT_EQUAL(std::string("pass"), sfnet.getValue());
115
CPPUNIT_ASSERT_EQUAL((time_t)12345679, sfnet.getExpiryTime());
116
CPPUNIT_ASSERT(sfnet.getPersistent());
117
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sourceforge.net"),
102
118
sfnet.getDomain());
119
CPPUNIT_ASSERT(!sfnet.getHostOnly());
103
120
CPPUNIT_ASSERT_EQUAL(std::string("/"), sfnet.getPath());
104
CPPUNIT_ASSERT_EQUAL(std::string("mykey"), sfnet.getName());
105
CPPUNIT_ASSERT_EQUAL(std::string("pass"), sfnet.getValue());
106
CPPUNIT_ASSERT_EQUAL((time_t)12345679, sfnet.getExpiry());
107
CPPUNIT_ASSERT_EQUAL(false, sfnet.isSecureCookie());
121
CPPUNIT_ASSERT(!sfnet.getSecure());
109
123
const Cookie& sfjp = cookies[1];
110
CPPUNIT_ASSERT_EQUAL(std::string(".aria2.sourceforge.jp"), sfjp.getDomain());
111
CPPUNIT_ASSERT_EQUAL(std::string("/profile"), sfjp.getPath());
112
124
CPPUNIT_ASSERT_EQUAL(std::string("myseckey"), sfjp.getName());
113
125
CPPUNIT_ASSERT_EQUAL(std::string("pass2"), sfjp.getValue());
114
CPPUNIT_ASSERT_EQUAL((time_t)0, sfjp.getExpiry());
115
CPPUNIT_ASSERT_EQUAL(true, sfjp.isSecureCookie());
126
CPPUNIT_ASSERT_EQUAL((time_t)0, sfjp.getExpiryTime());
127
CPPUNIT_ASSERT(sfjp.getPersistent());
128
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sourceforge.jp"), sfjp.getDomain());
129
CPPUNIT_ASSERT(sfjp.getHostOnly());
130
CPPUNIT_ASSERT_EQUAL(std::string("/profile"), sfjp.getPath());
131
CPPUNIT_ASSERT(sfjp.getSecure());
133
const Cookie& localnet = cookies[2];
134
CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), localnet.getDomain());
135
CPPUNIT_ASSERT(sfjp.getHostOnly());
136
CPPUNIT_ASSERT_EQUAL((time_t)3000, localnet.getLastAccessTime());
137
CPPUNIT_ASSERT_EQUAL((time_t)3000, localnet.getCreationTime());
118
140
} // namespace aria2