summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-08-08 23:09:33 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2016-08-08 23:09:33 (GMT)
commit54860ee6b8fe1ad33977eca490200929ea9cfac5 (patch)
tree5d022700b69f4d091473af00b160329f66991168
parent5830a4c0402da9acdcf20b62b359d762dd8c235b (diff)
downloadnetsurf-54860ee6b8fe1ad33977eca490200929ea9cfac5.tar.gz
netsurf-54860ee6b8fe1ad33977eca490200929ea9cfac5.tar.bz2
add cookie database load and restore unit test
-rw-r--r--test/data/cookies38
-rw-r--r--test/urldbtest.c15
2 files changed, 50 insertions, 3 deletions
diff --git a/test/data/cookies b/test/data/cookies
new file mode 100644
index 0000000..739618e
--- a/dev/null
+++ b/test/data/cookies
@@ -0,0 +1,38 @@
+# >/home/vince/.config/netsurf/Cookies
+# NetSurf cookies file.
+#
+# Lines starting with a '#' are comments, blank lines are ignored.
+#
+# All lines prior to "Version: 102" are discarded.
+#
+# Version Domain Domain from Set-Cookie Path Path from Set-Cookie Secure HTTP-Only Expires Last used No destroy Name Value Value was quoted Scheme URL Comment
+Version: 102
+0 .theguardian.com 1 / 1 0 0 1476054669 1468278669 0 GU_mvt_id 439080 0 unused unused
+0 .reddit.com 1 / 1 0 1 1499814590 1468278656 0 __cfduid d2c9a13e6ed171f4318aabcf558fcc6661468278590 0 unused unused
+0 www.reddit.com 0 / 1 1 0 1531350591 1468278656 0 loid lLGqu0nblR8T852T20 0 https https://www.reddit.com/
+0 www.reddit.com 0 / 1 1 0 1531350591 1468278656 0 loidcreated 2016-07-11T23%3A09%3A50.925Z 0 https https://www.reddit.com/
+0 .giffgaff.com 1 / 1 0 0 1503402870 1440407964 0 visid_incap_456843 MSQtdY7lSvK9UJiZDP3daK0S2lUAAAAAQUIPAAAAAAAudOMnRSt1V9mQN5dPPA+R 0 unused unused
+0 .google.com 1 / 1 0 0 1497632093 1470493285 0 SID DQAAAMoAAACuniK1mc17JMX-o-sfAVqvl0EWP0kiNpQg4lWeslWBnU_km8BK6Eww-1mC6zvnm7Jiv2vft4BOwWiAOmRzN66pbzxGNxKKGzSz2GNdWrcwvuYyQHkevwrtwmKmZGDKsgLljofq6NyNf0AP5xGXfHj18awhbbnymmv5UaDqypGx7FvptGQSMQkj_1hY6NJ5pfmO6LX8ezViJMABtqGPoO8Y8r8-eFRzLlsfbhCqM2OHkDRfoofXJCtIvDMi7Xyzoh6D5PsXbrfFZhcLSlfZpBtP 0 unused unused
+0 .google.com 1 / 1 0 1 1497632093 1470493285 0 HSID A1rFmKHX-G1exnHNv 0 unused unused
+0 .google.com 1 / 1 1 1 1497632093 1470493285 0 SSID A4wVZcYgXrCrwWns8 0 unused unused
+0 .google.com 1 / 1 0 0 1497632093 1470493285 0 APISID IeJTJt20VmceF7bS/AACvc5cSFPpX8FJMj 0 unused unused
+0 .google.com 1 / 1 1 0 1497632093 1470493285 0 SAPISID baCIIjpj-o3XQCkH/A-WEZgPvnNnguijDQ 0 unused unused
+0 accounts.google.com 0 / 1 1 1 1497632093 0 0 GAPS 1:-F43DfTc9MQPBnPFtQw7SBXNDYxGRw:-byarQeQN13vrH8I 0 https https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1
+0 accounts.google.com 0 / 1 1 1 1497632093 0 0 LSID mail|o.mail.google.com|s.GB|ss:DQAAAMwAAADuReoJNLFTfcVkka4Mpznq77VRSAgK_50UNJQeyKZS6zdAktvmMi42CsHIKCA_qkMe373-3PwvTioyn8OGHoKi8a2tas-mS1US4KPOXsp6GrewaR6bwkvkAudNj5H97wu9p9uek5EMljgPSIcFHyTRDwGghHc918-Z5-QVQMYswD9fA8DObnL4iFPrYJyYsz2MJcYKOMTdgBc9cutZ-zgRVJLVV1IJiluuTeQb5pjfpX4ROfo8kf4M_boTxfuwO19fn_zp5jT9qdPr4jDBM9lM 0 https https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1
+0 accounts.google.com 0 / 1 1 1 1497632093 0 0 ACCOUNT_CHOOSER AFx_qI5IqJoq6XeRvabQu34G7bErRw0LzimzBZXUqP_9H8Zh2kqTpBc-jooLHKNNCggYdxTq_ENRPogKK0V35Ap5s9N-88xwKmZLX7xXnZ25EBl-8FHjjvfMxKIj2-_xnpyKtWa5fWac 0 https https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1
+0 mail.google.com 0 / 1 1 1 1497632093 1435272960 0 OSID DQAAANsAAABjm3QWm7iyror5Q-r_twvLnU2MeBpDTpzoY-d-4pEomtilsx1VjIp_SphmVJcv084Ilg4o1COlySeuNAVSkeYn6qPyK93aIKN7MOmQxKvYQXIAlPiBAXD7bVX2HoAQpDXKc1BQZUfL2wLIjCwns0NQVGawofTWf8gve_FAwp6hXF9hXHrZRTU9lgt3N0yBpjElda_UiyNkhUIZP27zSS1LpXh7GaYcUgM69IUrczTnfkfIX_XunEaXBT59fmc49pbFEYlMMURG3ydiPjIhGdN9eHO27V9JhxqhuYUryTM8kg 0 https https://mail.google.com/accounts/SetOSID?continue=https%3A%2F%2Faccounts.google.co.uk%2Faccounts%2FSetSID%3Fssdc%3D1%26sidt%3DALWU2ctR9Uxp0qhL0HVYNURm01UOebegtyVV3GH%252BiVgIY9WIfqGs5NmqjVyX2IzkD0jDdGMV%252BgDLYwi9XrR%252FWsOIdwC4OO803V%252FimpsuKeLB7lk3%252FV10vr4C6wTc20A0I3ep6BLOe%252FQZgYJjfrcjzRiV2zT6fOiYXka1QrtyPIugR3R%252FaSWI%252Fau79w9hvBc%252FqqATVRi7F%252FDHv%252Be3cHMLPNOYoKwwUSOA9ORjKsyc5bCpnWM6X%252BrjsfzEEqlV5iui3EPKbBvTvCnfdF7UJjMg4EfWyMhVZaeytZdvGqJ2DfvPNmm2toULDQd4rcAAkfRZJQ95ySI4fq1ifZkfA0dhr7xnBQ0cl3%252BYTdl0yp%252BXjztO8YivQb%252Feip7gihmjfE9yRXoEboirDW8lIscN6cDDsuxzD07npdjHjRUX2wYrG4V3MLI4luHO52mwY%252BHZMN3O681HumCIBYvX%26continue%3Dhttps%253A%252F%252Fmail.google.com%252Fmail%252F%253Fauth%253DDQAAAL8AAABzUu3D7vQTObQbtiQU-X_6NnwgrsDnQe_7yXrUrFrniwP5j04Q9jVgc203CAd7rwHnO0tvXTI8MSlRISJz3tGutyOc_uw5khR4FHviJuyTEuxKJZPUmQXnIWxZf_CQoJXGGaxn1kT0scUyrxiBjTfXllUWBVa5iuEzL2lgbAINKmSlLmyg3BaTFb-l0nmDdqGznAJMDgspYtD8iBTcPnOWpGkHXUVtkE0C6KK_3z1eULl0wEne4aU0LNJhlhUa8Xk&osidt=ALWU2cvhIheonCPoG5pecDWKf0i1a-AsQKBMvxay9B54taUbBKAxr9vzwWXg2UJDvM3oYcjYFVDxpERiv9sed5ZQXUKh9UPV5epNA25PUuVZwNDOkePm6agrIhUGR9wVz4x7I6-uU0uF4VHDwS1KDpWZvQY6tMw5vti1qF2bVdLMO_UTLcEW9mdV7Oze8OZXWxFsppfVGSxHN8N1rH8xRMCj3A5QjC-OU5h-pS3N4-AI4A5LwrMj_zvtwS0BW5otNhVmt503yBBXKIIkF5i4gGXiQGVVhCFlBeosv7KbWx97PEPTzeqf59R0ZgY9p1cd_jQWi0gYUmTn
+0 mail.google.com 0 /mail 1 1 1 1497632094 1435272960 0 GX DQAAAMoAAADuReoJNLFTfcVkka4MpznqQGgtWpCWbF9qPINtXVzsE62rPcFtkl_t5MhqS9Ab1zrEmWlZefvaR2bknrPqFsBfVZAtMoThXQxvoQQ7K2A1XTWfEeX09w0dJvN0A8SXsjAEebTY93dZkJr5fMomABLkbizqoRqSkv6sh4x7Ysat6VGX6m6eTg81aiCjuBHzLwlAKx63On5joEI1qYhXvKF1JMc3oEzaETTv9mw-vXHt_J-YYlPQi_nG4jQKoDFJ-XCx1fjVVGlqBsPj5Pf1-SGT 0 https https://mail.google.com/mail/?auth=DQAAAL8AAABzUu3D7vQTObQbtiQU-X_6NnwgrsDnQe_7yXrUrFrniwP5j04Q9jVgc203CAd7rwHnO0tvXTI8MSlRISJz3tGutyOc_uw5khR4FHviJuyTEuxKJZPUmQXnIWxZf_CQoJXGGaxn1kT0scUyrxiBjTfXllUWBVa5iuEzL2lgbAINKmSlLmyg3BaTFb-l0nmDdqGznAJMDgspYtD8iBTcPnOWpGkHXUVtkE0C6KK_3z1eULl0wEne4aU0LNJhlhUa8Xk
+0 www.ccrexplorers.com 0 / 1 0 0 1499619054 1468082755 0 bb_lastvisit 1468083054 0 http http://www.ccrexplorers.com/forumdisplay.php?f=17
+0 .theregister.co.uk 1 / 1 0 1 1471944077 1468278443 0 __cfduid dbda67dd4386142349a936c252ebac7391440408077 0 unused unused
+0 nir.theregister.co.uk 0 / 1 0 0 1470697643 0 0 c 1/front.front.578426ab 0 http http://nir.theregister.co.uk/?g=c&g=sa&s=c/front.front
+0 nir.theregister.co.uk 0 / 1 0 0 1499814443 0 0 sa 1 0 http http://nir.theregister.co.uk/?g=c&g=sa&s=c/front.front
+0 .regmedia.co.uk 1 / 1 0 1 1471944079 1468278443 0 __cfduid d82e13431caf77499b09ccf54c21999941440408079 0 unused unused
+0 .google.co.uk 1 / 1 0 0 1497632093 1468278489 0 SID DQAAAMkAAACuniK1mc17JMX-o-sfAVqvl0EWP0kiNpQg4lWeslWBnU_km8BK6Eww-1mC6zvnm7Jiv2vft4BOwWiAOmRzN66pbzxGNxKKGzSz2GNdWrcwvuYyQHkevwrtwmKmZGDKsgLljofq6NyNf0AP5xGXfHj18awhbbnymmv5UaDqypGx7FvptGQSMQkj_1hY6NJ5pflIfSnKeEn0Y2mEVyhc1qUiGcJhVKqIRd6xaGKk7l235kOpqxjGK7I4_jTQaORZbp2-RWozAg7SHESSaOpxQ0ZT 0 unused unused
+0 .google.co.uk 1 / 1 0 1 1497632093 1468278489 0 HSID ANVWylWAbjjzFxKxI 0 unused unused
+0 .google.co.uk 1 / 1 1 1 1497632093 1468278489 0 SSID ANtGv1CSBG3CWbdtr 0 unused unused
+0 .google.co.uk 1 / 1 0 0 1497632093 1468278489 0 APISID IeJTJt20VmceF7bS/AACvc5cSFPpX8FJMj 0 unused unused
+0 .google.co.uk 1 / 1 1 0 1497632093 1468278489 0 SAPISID baCIIjpj-o3XQCkH/A-WEZgPvnNnguijDQ 0 unused unused
+0 .google.co.uk 1 / 1 0 1 1484089690 0 0 NID 81=BGSfpwd63LrhVNUii2KYHfuyCUKzQv2Zg2ik1H_byGynWUgd9_q-kY48oCRapIewLtzMNYtf2KzYBk0_5OoAtNrD-0YSqXDzKalLWfQ8Vxwyywy79YDvAaX_3tprJzjp 0 unused unused
+0 .bbc.co.uk 1 / 1 0 0 1595541997 1470493359 0 BBC-UID 35e7d9a5837b2e9d026d30f521339ac6826814226444c1ee4a2134fef248fe180NetSurf/3.6%20(Linux) 0 unused unused
+0 news.bbc.co.uk 0 / 1 0 0 1500933997 1469574171 0 BBC-UID 25a73995333b5e9d8ea88a16a17c7b8beea45e555eb863e913853a4de2dcbdb80NetSurf%2f3%2e6%20%28Linux%29 0 http http://news.bbc.co.uk/
+0 en.wikipedia.org 0 / 1 1 1 1473249600 1470493303 0 WMF-Last-Access 06-Aug-2016 0 http http://en.wikipedia.org/wiki/Main_Page
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 0b4853c..faf6d6e 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -37,10 +37,12 @@
#include "utils/nsurl.h"
#include "utils/nsoption.h"
#include "netsurf/url_db.h"
+#include "netsurf/cookie_db.h"
#include "content/urldb.h"
#include "desktop/cookie_manager.h"
const char *test_urldb_path = "test/data/urldb";
+const char *test_cookies_path = "test/data/cookies";
struct netsurf_table *guit = NULL;
@@ -139,6 +141,7 @@ static void urldb_create_loaded(void)
res = urldb_load(test_urldb_path);
ck_assert_int_eq(res, NSERROR_OK);
+ urldb_load_cookies(test_cookies_path);
}
static void urldb_lwc_iterator(lwc_string *str, void *pw)
@@ -401,17 +404,23 @@ START_TEST(urldb_session_test)
res = urldb_load(test_urldb_path);
ck_assert_int_eq(res, NSERROR_OK);
+ urldb_load_cookies(test_cookies_path);
+
/* write database out */
outnam = tmpnam(NULL);
res = urldb_save(outnam);
ck_assert_int_eq(res, NSERROR_OK);
+ /* remove test output */
+ unlink(outnam);
+
+ /* write cookies out */
+ urldb_save_cookies(outnam);
+
/* finalise options */
res = nsoption_finalise(NULL, NULL);
ck_assert_int_eq(res, NSERROR_OK);
- /* remove test output */
- unlink(outnam);
}
END_TEST
@@ -460,7 +469,7 @@ START_TEST(urldb_auth_details_test)
nsurl *url;
const char *res;
const char *auth = "mooooo";
-
+
url = make_url("http://www.wikipedia.org/");
urldb_set_auth_details(url, "tree", auth);