CookieStorageTest.cc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. #include "CookieStorage.h"
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <limits>
  5. #include <cppunit/extensions/HelperMacros.h>
  6. #include "Exception.h"
  7. #include "util.h"
  8. #include "TimeA2.h"
  9. #include "RecoverableException.h"
  10. #include "File.h"
  11. #include "TestUtil.h"
  12. #include "TimerA2.h"
  13. namespace aria2 {
  14. class CookieStorageTest:public CppUnit::TestFixture {
  15. CPPUNIT_TEST_SUITE(CookieStorageTest);
  16. CPPUNIT_TEST(testStore);
  17. CPPUNIT_TEST(testParseAndStore);
  18. CPPUNIT_TEST(testCriteriaFind);
  19. CPPUNIT_TEST(testCriteriaFind_cookieOrder);
  20. CPPUNIT_TEST(testLoad);
  21. CPPUNIT_TEST(testLoad_sqlite3);
  22. CPPUNIT_TEST(testLoad_fileNotfound);
  23. CPPUNIT_TEST(testSaveNsFormat);
  24. CPPUNIT_TEST(testSaveNsFormat_fail);
  25. CPPUNIT_TEST(testCookieIsFull);
  26. CPPUNIT_TEST(testDomainIsFull);
  27. CPPUNIT_TEST(testEviction);
  28. CPPUNIT_TEST_SUITE_END();
  29. public:
  30. void setUp() {}
  31. void tearDown() {}
  32. void testStore();
  33. void testParseAndStore();
  34. void testCriteriaFind();
  35. void testCriteriaFind_cookieOrder();
  36. void testLoad();
  37. void testLoad_sqlite3();
  38. void testLoad_fileNotfound();
  39. void testSaveNsFormat();
  40. void testSaveNsFormat_fail();
  41. void testCookieIsFull();
  42. void testDomainIsFull();
  43. void testEviction();
  44. };
  45. CPPUNIT_TEST_SUITE_REGISTRATION(CookieStorageTest);
  46. namespace {
  47. std::vector<const Cookie*> dumpCookie(const CookieStorage& st)
  48. {
  49. auto res = std::vector<const Cookie*>{};
  50. st.dumpCookie(std::back_inserter(res));
  51. std::sort(res.begin(), res.end(), CookieSorter());
  52. return res;
  53. }
  54. } // namespace
  55. void CookieStorageTest::testStore()
  56. {
  57. time_t now = 1000;
  58. auto st = CookieStorage{};
  59. auto goodCookie = []() {
  60. return createCookie("k", "v", "localhost", true, "/", false);
  61. };
  62. CPPUNIT_ASSERT(st.store(goodCookie(), now));
  63. CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
  64. CPPUNIT_ASSERT(st.contains(*goodCookie()));
  65. auto anotherCookie = []() {
  66. return createCookie("k", "v", "mirror", true, "/", true);
  67. };
  68. CPPUNIT_ASSERT(st.store(anotherCookie(), now));
  69. CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
  70. CPPUNIT_ASSERT(st.contains(*anotherCookie()));
  71. CPPUNIT_ASSERT(st.contains(*goodCookie()));
  72. auto updateGoodCookie = []() {
  73. return createCookie("k", "v2", "localhost", true, "/", false);
  74. };
  75. CPPUNIT_ASSERT(st.store(updateGoodCookie(), now));
  76. CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
  77. CPPUNIT_ASSERT(st.contains(*updateGoodCookie()));
  78. CPPUNIT_ASSERT(st.contains(*anotherCookie()));
  79. auto expireGoodCookie = []() {
  80. return createCookie("k", "v3", 0, "localhost", true, "/", false);
  81. };
  82. CPPUNIT_ASSERT(!st.store(expireGoodCookie(), now));
  83. CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
  84. CPPUNIT_ASSERT(st.contains(*anotherCookie()));
  85. auto fromNumericHost = []() {
  86. return createCookie("k", "v", "192.168.1.1", true, "/", false);
  87. };
  88. CPPUNIT_ASSERT(st.store(fromNumericHost(), now));
  89. CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
  90. CPPUNIT_ASSERT(st.contains(*fromNumericHost()));
  91. }
  92. void CookieStorageTest::testParseAndStore()
  93. {
  94. auto st = CookieStorage{};
  95. time_t now = 1000;
  96. std::string localhostCookieStr = "k=v;"
  97. " expires=Fri, 01 Jan 2038 00:00:00 GMT; path=/; domain=localhost;";
  98. CPPUNIT_ASSERT
  99. (st.parseAndStore(localhostCookieStr, "localhost", "/downloads", now));
  100. CPPUNIT_ASSERT
  101. (!st.parseAndStore(localhostCookieStr, "mirror", "/downloads", now));
  102. CPPUNIT_ASSERT
  103. (!st.parseAndStore(localhostCookieStr, "127.0.0.1", "/downloads", now));
  104. std::string numericHostCookieStr = "k=v;"
  105. " expires=Fri, 01 Jan 2038 00:00:00 GMT; path=/; domain=192.168.1.1;";
  106. CPPUNIT_ASSERT
  107. (st.parseAndStore(numericHostCookieStr, "192.168.1.1", "/", now));
  108. // No domain and no path are specified.
  109. std::string noDomainPathCookieStr = "k=v";
  110. CPPUNIT_ASSERT
  111. (st.parseAndStore(noDomainPathCookieStr,
  112. "aria2.sf.net", "/downloads", now));
  113. }
  114. void CookieStorageTest::testCriteriaFind()
  115. {
  116. auto st = CookieStorage{};
  117. time_t now = 1000;
  118. auto alpha = []() {
  119. return createCookie("alpha", "ALPHA", "aria2.org", false, "/", false);
  120. };
  121. auto bravo = []() {
  122. return createCookie("bravo", "BRAVO", 1060, "aria2.org", false,
  123. "/foo", false);
  124. };
  125. auto charlie = []() {
  126. return createCookie("charlie", "CHARLIE", "aria2.org", false,
  127. "/", true);
  128. };
  129. auto delta = []() {
  130. return createCookie("delta", "DELTA", "aria2.org", false,
  131. "/foo/bar", false);
  132. };
  133. auto echo = []() {
  134. return createCookie("echo", "ECHO", "www.dl.aria2.org", false,
  135. "/", false);
  136. };
  137. auto foxtrot = []() {
  138. return createCookie("foxtrot", "FOXTROT", "sf.net", false,
  139. "/", false);
  140. };
  141. auto golf = []() {
  142. return createCookie("golf", "GOLF", "192.168.1.1", true,
  143. "/", false);
  144. };
  145. auto hotel1 = []() {
  146. return createCookie("hotel", "HOTEL1", "samename.x", false,
  147. "/", false);
  148. };
  149. auto hotel2 = []() {
  150. return createCookie("hotel", "HOTEL2", "samename.x", false,
  151. "/hotel", false);
  152. };
  153. auto hotel3 = []() {
  154. return createCookie("hotel", "HOTEL3", "samename.x", false,
  155. "/bar/wine", false);
  156. };
  157. auto hotel4 = []() {
  158. return createCookie("hotel", "HOTEL4", "samename.x", false,
  159. "/bar/", false);
  160. };
  161. auto india1 = []() {
  162. return createCookie("india", "INDIA1", "default.domain", true,
  163. "/foo", false);
  164. };
  165. auto india2 = []() {
  166. return createCookie("india", "INDIA2", "default.domain", false,
  167. "/", false);
  168. };
  169. auto juliet1 = []() {
  170. return createCookie("juliet", "JULIET1", "localhost", true,
  171. "/foo", false);
  172. };
  173. CPPUNIT_ASSERT(st.store(alpha(), now));
  174. CPPUNIT_ASSERT(st.store(bravo(), now));
  175. CPPUNIT_ASSERT(st.store(charlie(), now));
  176. CPPUNIT_ASSERT(st.store(delta(), now));
  177. CPPUNIT_ASSERT(st.store(echo(), now));
  178. CPPUNIT_ASSERT(st.store(foxtrot(), now));
  179. CPPUNIT_ASSERT(st.store(golf(), now));
  180. CPPUNIT_ASSERT(st.store(hotel1(), now));
  181. CPPUNIT_ASSERT(st.store(hotel2(), now));
  182. CPPUNIT_ASSERT(st.store(hotel3(), now));
  183. CPPUNIT_ASSERT(st.store(hotel4(), now));
  184. CPPUNIT_ASSERT(st.store(india1(), now));
  185. CPPUNIT_ASSERT(st.store(india2(), now));
  186. CPPUNIT_ASSERT(st.store(juliet1(), now));
  187. auto aria2Slash = st.criteriaFind("www.dl.aria2.org", "/", 0, false);
  188. CPPUNIT_ASSERT_EQUAL((size_t)2, aria2Slash.size());
  189. CPPUNIT_ASSERT(derefFind(aria2Slash, alpha()));
  190. CPPUNIT_ASSERT(derefFind(aria2Slash, echo()));
  191. auto aria2SlashFoo = st.criteriaFind("www.dl.aria2.org","/foo", 0, false);
  192. CPPUNIT_ASSERT_EQUAL((size_t)3, aria2SlashFoo.size());
  193. CPPUNIT_ASSERT_EQUAL(std::string("bravo"), aria2SlashFoo[0]->getName());
  194. CPPUNIT_ASSERT(derefFind(aria2SlashFoo, alpha()));
  195. CPPUNIT_ASSERT(derefFind(aria2SlashFoo, echo()));
  196. auto aria2Expires = st.criteriaFind("www.dl.aria2.org", "/foo", 1120, false);
  197. CPPUNIT_ASSERT_EQUAL((size_t)2, aria2Expires.size());
  198. CPPUNIT_ASSERT(derefFind(aria2Expires, alpha()));
  199. CPPUNIT_ASSERT(derefFind(aria2Expires, echo()));
  200. auto dlAria2 = st.criteriaFind("dl.aria2.org", "/", 0, false);
  201. CPPUNIT_ASSERT_EQUAL((size_t)1, dlAria2.size());
  202. CPPUNIT_ASSERT_EQUAL(std::string("alpha"), dlAria2[0]->getName());
  203. auto tailmatchAria2 = st.criteriaFind("myaria2.org", "/", 0, false);
  204. CPPUNIT_ASSERT(tailmatchAria2.empty());
  205. auto numericHostCookies = st.criteriaFind("192.168.1.1", "/",0, false);
  206. CPPUNIT_ASSERT_EQUAL((size_t)1, numericHostCookies.size());
  207. CPPUNIT_ASSERT_EQUAL(std::string("golf"), numericHostCookies[0]->getName());
  208. auto sameNameCookies = st.criteriaFind("samename.x", "/bar/wine", 0, false);
  209. CPPUNIT_ASSERT_EQUAL((size_t)3, sameNameCookies.size());
  210. CPPUNIT_ASSERT_EQUAL(std::string("HOTEL3"), sameNameCookies[0]->getValue());
  211. CPPUNIT_ASSERT_EQUAL(std::string("HOTEL4"), sameNameCookies[1]->getValue());
  212. CPPUNIT_ASSERT_EQUAL(std::string("HOTEL1"), sameNameCookies[2]->getValue());
  213. auto defaultDomainCookies = st.criteriaFind("default.domain", "/foo", 0,
  214. false);
  215. CPPUNIT_ASSERT_EQUAL((size_t)2, defaultDomainCookies.size());
  216. CPPUNIT_ASSERT_EQUAL(std::string("INDIA1"),
  217. defaultDomainCookies[0]->getValue());
  218. CPPUNIT_ASSERT_EQUAL(std::string("INDIA2"),
  219. defaultDomainCookies[1]->getValue());
  220. defaultDomainCookies =
  221. st.criteriaFind("sub.default.domain", "/foo", 0, false);
  222. CPPUNIT_ASSERT_EQUAL((size_t)1, defaultDomainCookies.size());
  223. CPPUNIT_ASSERT_EQUAL(std::string("INDIA2"),
  224. defaultDomainCookies[0]->getValue());
  225. // localhost.local case
  226. auto localDomainCookies = st.criteriaFind("localhost", "/foo", 0, false);
  227. CPPUNIT_ASSERT_EQUAL((size_t)1, localDomainCookies.size());
  228. CPPUNIT_ASSERT_EQUAL(std::string("JULIET1"),
  229. localDomainCookies[0]->getValue());
  230. }
  231. void CookieStorageTest::testCriteriaFind_cookieOrder()
  232. {
  233. auto st = CookieStorage{};
  234. auto a = createCookie("a", "0", "host", true, "/", false);
  235. a->setCreationTime(1000);
  236. auto b = createCookie("b", "0", "host", true, "/foo", false);
  237. b->setCreationTime(5000);
  238. auto c = createCookie("c", "0", "host", true, "/foo", false);
  239. c->setCreationTime(4000);
  240. auto d = createCookie("d", "0", "host", true, "/foo/bar", false);
  241. d->setCreationTime(6000);
  242. st.store(std::move(a), 0);
  243. st.store(std::move(b), 0);
  244. st.store(std::move(c), 0);
  245. st.store(std::move(d), 0);
  246. auto cookies = st.criteriaFind("host", "/foo/bar", 0, false);
  247. CPPUNIT_ASSERT_EQUAL((size_t)4, cookies.size());
  248. CPPUNIT_ASSERT_EQUAL(std::string("d"), cookies[0]->getName());
  249. CPPUNIT_ASSERT_EQUAL(std::string("c"), cookies[1]->getName());
  250. CPPUNIT_ASSERT_EQUAL(std::string("b"), cookies[2]->getName());
  251. CPPUNIT_ASSERT_EQUAL(std::string("a"), cookies[3]->getName());
  252. }
  253. void CookieStorageTest::testLoad()
  254. {
  255. auto st = CookieStorage{};
  256. st.load(A2_TEST_DIR"/nscookietest.txt", 1001);
  257. CPPUNIT_ASSERT_EQUAL((size_t)4, st.size());
  258. auto cookies = dumpCookie(st);
  259. auto c = cookies[0];
  260. CPPUNIT_ASSERT_EQUAL(std::string("passwd"), c->getName());
  261. CPPUNIT_ASSERT_EQUAL(std::string("secret"), c->getValue());
  262. CPPUNIT_ASSERT_EQUAL(std::numeric_limits<time_t>::max(), c->getExpiryTime());
  263. CPPUNIT_ASSERT(!c->getPersistent());
  264. CPPUNIT_ASSERT_EQUAL(std::string("/cgi-bin"), c->getPath());
  265. CPPUNIT_ASSERT_EQUAL(std::string("192.168.0.1"), c->getDomain());
  266. CPPUNIT_ASSERT(c->getHostOnly());
  267. CPPUNIT_ASSERT(!c->getSecure());
  268. c = cookies[1];
  269. CPPUNIT_ASSERT_EQUAL(std::string("novalue"), c->getName());
  270. CPPUNIT_ASSERT_EQUAL(std::string(""), c->getValue());
  271. CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c->getExpiryTime());
  272. CPPUNIT_ASSERT(c->getPersistent());
  273. CPPUNIT_ASSERT_EQUAL(std::string("/"), c->getPath());
  274. CPPUNIT_ASSERT_EQUAL(std::string("example.org"), c->getDomain());
  275. CPPUNIT_ASSERT(!c->getHostOnly());
  276. CPPUNIT_ASSERT(!c->getSecure());
  277. c = cookies[2];
  278. CPPUNIT_ASSERT_EQUAL(std::string("JSESSIONID"), c->getName());
  279. CPPUNIT_ASSERT_EQUAL(std::string("123456789"), c->getValue());
  280. CPPUNIT_ASSERT_EQUAL((time_t)2147483647, c->getExpiryTime());
  281. CPPUNIT_ASSERT_EQUAL(std::string("/"), c->getPath());
  282. CPPUNIT_ASSERT_EQUAL(std::string("localhost"), c->getDomain());
  283. CPPUNIT_ASSERT(c->getHostOnly());
  284. CPPUNIT_ASSERT(c->getSecure());
  285. c = cookies[3];
  286. CPPUNIT_ASSERT_EQUAL(std::string("TAX"), c->getName());
  287. CPPUNIT_ASSERT_EQUAL(std::string("1000"), c->getValue());
  288. CPPUNIT_ASSERT((time_t)INT32_MAX <= c->getExpiryTime());
  289. CPPUNIT_ASSERT(c->getPersistent());
  290. CPPUNIT_ASSERT_EQUAL(std::string("/"), c->getPath());
  291. CPPUNIT_ASSERT_EQUAL(std::string("overflow"), c->getDomain());
  292. CPPUNIT_ASSERT(!c->getSecure());
  293. }
  294. void CookieStorageTest::testLoad_sqlite3()
  295. {
  296. auto st = CookieStorage{};
  297. #ifdef HAVE_SQLITE3
  298. st.load(A2_TEST_DIR"/cookies.sqlite", 1000);
  299. CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
  300. auto cookies = dumpCookie(st);
  301. auto c = cookies[0];
  302. CPPUNIT_ASSERT_EQUAL(std::string("JSESSIONID"), c->getName());
  303. CPPUNIT_ASSERT_EQUAL(std::string("123456789"), c->getValue());
  304. CPPUNIT_ASSERT_EQUAL((time_t)INT32_MAX, c->getExpiryTime());
  305. CPPUNIT_ASSERT(c->getPersistent());
  306. CPPUNIT_ASSERT_EQUAL(std::string("localhost"), c->getDomain());
  307. CPPUNIT_ASSERT(c->getHostOnly());
  308. CPPUNIT_ASSERT_EQUAL(std::string("/"), c->getPath());
  309. CPPUNIT_ASSERT(c->getSecure());
  310. c = cookies[1];
  311. CPPUNIT_ASSERT_EQUAL(std::string("foo"), c->getName());
  312. CPPUNIT_ASSERT_EQUAL(std::string("bar"), c->getValue());
  313. CPPUNIT_ASSERT((time_t)INT32_MAX <= c->getExpiryTime());
  314. CPPUNIT_ASSERT(c->getPersistent());
  315. CPPUNIT_ASSERT_EQUAL(std::string("overflow.time_t.org"), c->getDomain());
  316. CPPUNIT_ASSERT(!c->getHostOnly());
  317. CPPUNIT_ASSERT_EQUAL(std::string("/path/to"), c->getPath());
  318. CPPUNIT_ASSERT(!c->getSecure());
  319. #else // !HAVE_SQLITE3
  320. CPPUNIT_ASSERT(!st.load(A2_TEST_DIR"/cookies.sqlite", 1000));
  321. #endif // !HAVE_SQLITE3
  322. }
  323. void CookieStorageTest::testLoad_fileNotfound()
  324. {
  325. auto st = CookieStorage{};
  326. CPPUNIT_ASSERT(!st.load("./aria2_CookieStorageTest_testLoad_fileNotfound",0));
  327. }
  328. void CookieStorageTest::testSaveNsFormat()
  329. {
  330. // TODO add cookie with default domain
  331. std::string filename = A2_TEST_OUT_DIR"/aria2_CookieStorageTest_testSaveNsFormat";
  332. File(filename).remove();
  333. auto st = CookieStorage{};
  334. time_t now = 1000;
  335. st.store(createCookie("favorite", "classic", "domain.org", false,
  336. "/config",true), now);
  337. st.store(createCookie("uid", "tujikawa", now, "domain.org", true,
  338. "/",false), now);
  339. CPPUNIT_ASSERT(st.saveNsFormat(filename));
  340. auto loadst = CookieStorage{};
  341. loadst.load(filename, now);
  342. CPPUNIT_ASSERT_EQUAL((size_t)2, loadst.size());
  343. auto cookies = dumpCookie(loadst);
  344. CPPUNIT_ASSERT_EQUAL((size_t)2, cookies.size());
  345. CPPUNIT_ASSERT_EQUAL(std::string("favorite"), cookies[0]->getName());
  346. CPPUNIT_ASSERT_EQUAL(std::string("uid"), cookies[1]->getName());
  347. }
  348. void CookieStorageTest::testSaveNsFormat_fail()
  349. {
  350. std::string filename =
  351. A2_TEST_OUT_DIR"/aria2_CookieStorageTest_testSaveNsFormat_fail";
  352. File f(filename);
  353. f.remove();
  354. f.mkdirs();
  355. CPPUNIT_ASSERT(f.isDir());
  356. auto st = CookieStorage{};
  357. CPPUNIT_ASSERT(!st.saveNsFormat(filename));
  358. }
  359. void CookieStorageTest::testCookieIsFull()
  360. {
  361. auto st = CookieStorage{};
  362. for(size_t i = 0; i < CookieStorage::MAX_COOKIE_PER_DOMAIN+1; ++i) {
  363. st.store(createCookie("k"+util::itos(i), "v", "aria2.org", false,
  364. "/", false), 0);
  365. }
  366. CPPUNIT_ASSERT_EQUAL((size_t)CookieStorage::MAX_COOKIE_PER_DOMAIN, st.size());
  367. }
  368. void CookieStorageTest::testDomainIsFull()
  369. {
  370. // See DOMAIN_EVICTION_TRIGGER and DOMAIN_EVICTION_RATE in
  371. // CookieStorage.cc
  372. auto st = CookieStorage{};
  373. for(size_t i = 0; i < 2001; ++i) {
  374. st.store(createCookie("k", "v", "domain"+util::itos(i), true,
  375. "/", false), 0);
  376. }
  377. CPPUNIT_ASSERT_EQUAL((size_t)1801, st.size());
  378. }
  379. void CookieStorageTest::testEviction()
  380. {
  381. auto st = CookieStorage{};
  382. auto alpha = []() {
  383. return createCookie("a", "alpha", "aria2.sf.net", false, "/", false);
  384. };
  385. auto bravo = []() {
  386. return createCookie("b", "bravo", "d.aria2.sf.net", false, "/", false);
  387. };
  388. auto charlie = []() {
  389. return createCookie("c", "charlie", "a2.github.com", false, "/", false);
  390. };
  391. auto delta = []() {
  392. return createCookie("d", "delta", "aria2.sf.net", false, "/", false);
  393. };
  394. st.store(alpha(), 0);
  395. CPPUNIT_ASSERT_EQUAL((size_t)1, st.getLruTrackerSize());
  396. st.store(bravo(), 1);
  397. CPPUNIT_ASSERT_EQUAL((size_t)2, st.getLruTrackerSize());
  398. st.store(charlie(), 2);
  399. CPPUNIT_ASSERT_EQUAL((size_t)3, st.getLruTrackerSize());
  400. st.store(delta(), 0);
  401. CPPUNIT_ASSERT_EQUAL((size_t)3, st.getLruTrackerSize());
  402. // aria2.sf.net will be evicted
  403. st.evictNode(1);
  404. CPPUNIT_ASSERT_EQUAL((size_t)2, st.getLruTrackerSize());
  405. CPPUNIT_ASSERT(!st.contains(*alpha()));
  406. CPPUNIT_ASSERT(st.contains(*bravo()));
  407. CPPUNIT_ASSERT(st.contains(*charlie()));
  408. CPPUNIT_ASSERT(!st.contains(*delta()));
  409. // d.aria2.sf.net will be evicted
  410. st.evictNode(1);
  411. CPPUNIT_ASSERT_EQUAL((size_t)1, st.getLruTrackerSize());
  412. CPPUNIT_ASSERT(!st.contains(*bravo()));
  413. CPPUNIT_ASSERT(st.contains(*charlie()));
  414. // a2.github.com will be evicted
  415. st.evictNode(1);
  416. CPPUNIT_ASSERT_EQUAL((size_t)0, st.getLruTrackerSize());
  417. CPPUNIT_ASSERT(!st.contains(*charlie()));
  418. CPPUNIT_ASSERT_EQUAL((size_t)0, st.size());
  419. CPPUNIT_ASSERT(!st.getRootNode()->hasNext());
  420. }
  421. } // namespace aria2