aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dir_handle_get.c
diff options
context:
space:
mode:
authorjuga0 <juga@riseup.net>2018-11-07 12:40:51 +0000
committerteor <teor@torproject.org>2019-03-26 17:41:09 +1000
commita4bf3be8bce662c77422fb88072e4685083e90b2 (patch)
treefafdf5df4ec005b1f11fc5333101c2a4d03e8d8b /src/test/test_dir_handle_get.c
parentfb4a40c32c4a7e5b7175ea2c635687b6b24a29d0 (diff)
downloadtor-a4bf3be8bce662c77422fb88072e4685083e90b2.tar.gz
tor-a4bf3be8bce662c77422fb88072e4685083e90b2.zip
test: check that .../bandwidth.z is compressed
Diffstat (limited to 'src/test/test_dir_handle_get.c')
-rw-r--r--src/test/test_dir_handle_get.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/test_dir_handle_get.c b/src/test/test_dir_handle_get.c
index 6d478f6b49..0cd7e1050a 100644
--- a/src/test/test_dir_handle_get.c
+++ b/src/test/test_dir_handle_get.c
@@ -2529,6 +2529,25 @@ test_dir_handle_get_status_vote_next_bandwidth(void* data)
tt_int_op(body_used, OP_EQ, strlen(body));
tt_str_op(content, OP_EQ, body);
+ tor_free(header);
+ tor_free(body);
+
+ /* Request the file using compression, the result should be the same. */
+ tt_int_op(0, OP_EQ, directory_handle_command_get(conn,
+ GET("/tor/status-vote/next/bandwidth.z"), NULL, 0));
+
+ fetch_from_buf_http(TO_CONN(conn)->outbuf, &header, MAX_HEADERS_SIZE,
+ &body, &body_used, strlen(content)+1, 0);
+
+ tt_assert(header);
+ tt_ptr_op(strstr(header, "HTTP/1.0 200 OK\r\n"), OP_EQ, header);
+ tt_assert(strstr(header, "Content-Encoding: deflate\r\n"));
+
+ /* Since using connection_write_to_buf_mock instead of mocking
+ * connection_buf_add_compress, the content is not actually compressed.
+ * If it would, the size and content would be different than the original.
+ */
+
done:
UNMOCK(get_options);
UNMOCK(connection_write_to_buf_impl_);