diff options
author | juga0 <juga@riseup.net> | 2018-11-07 12:38:45 +0000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-03-26 17:41:06 +1000 |
commit | fb4a40c32c4a7e5b7175ea2c635687b6b24a29d0 (patch) | |
tree | eb65a05b0c31397123df91fd700d5cc6e44cf9d2 /src/test/test_dir_handle_get.c | |
parent | 76271347438ff03796a9424019860332f50c5134 (diff) | |
download | tor-fb4a40c32c4a7e5b7175ea2c635687b6b24a29d0.tar.gz tor-fb4a40c32c4a7e5b7175ea2c635687b6b24a29d0.zip |
test: Check bw file cache lifetime
Diffstat (limited to 'src/test/test_dir_handle_get.c')
-rw-r--r-- | src/test/test_dir_handle_get.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c index 8b2ee3ecac..6d478f6b49 100644 --- a/src/test/test_dir_handle_get.c +++ b/src/test/test_dir_handle_get.c @@ -2516,6 +2516,16 @@ test_dir_handle_get_status_vote_next_bandwidth(void* data) tt_assert(strstr(header, "Content-Encoding: identity\r\n")); tt_assert(strstr(header, "Content-Length: 167\r\n")); + /* Check cache lifetime */ + char expbuf[RFC1123_TIME_LEN+1]; + time_t now = time(NULL); + /* BANDWIDTH_CACHE_LIFETIME is defined in dircache.c. */ + format_rfc1123_time(expbuf, (time_t)(now + 30*60)); + char *expires = NULL; + /* Change to 'Cache-control: max-age=%d' if using http/1.1. */ + tor_asprintf(&expires, "Expires: %s\r\n", expbuf); + tt_assert(strstr(header, expires)); + tt_int_op(body_used, OP_EQ, strlen(body)); tt_str_op(content, OP_EQ, body); @@ -2525,6 +2535,7 @@ test_dir_handle_get_status_vote_next_bandwidth(void* data) connection_free_minimal(TO_CONN(conn)); tor_free(header); tor_free(body); + tor_free(expires); or_options_free(mock_options); mock_options = NULL; } |