Skip to content

Commit

Permalink
response: add http tunneling test case
Browse files Browse the repository at this point in the history
This test case shows unexpected state transitions when processing http
tunnels and the emission of body data.
  • Loading branch information
cccs-sadugas committed Jun 6, 2024
1 parent 202be0f commit 559667a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/files/101-connect-tunnel.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
>>>
CONNECT www.ssllabs.com:443 HTTP/1.0
Host: www.ssllabs.com:443

abcdef

<<<
HTTP/1.1 200 OK
Server: Apache/2.2

ABCDEF
ABCDEF

>>>
abcdef
abcdef

<<<
ABCDEF
ABCDEF
29 changes: 29 additions & 0 deletions test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2145,4 +2145,33 @@ TEST_F(ConnectionParsing, ResponseBodyData) {

delete user_data;
}

TEST_F(ConnectionParsing, ConnectTunnel) {
htp_config_register_response_body_data(cfg, callback_RESPONSE_BODY_DATA);

int rc = test_run(home, "101-connect-tunnel.t", cfg, &connp);
ASSERT_GE(rc, 0);

ASSERT_EQ(1, htp_list_size(connp->conn->transactions));

htp_tx_t *tx = (htp_tx_t *) htp_list_get(connp->conn->transactions, 0);
ASSERT_TRUE(tx != NULL);

EXPECT_TRUE(htp_tx_is_complete(tx));

EXPECT_EQ(0, bstr_cmp_c(tx->request_method, "CONNECT"));

EXPECT_EQ(200, tx->response_status_number);
EXPECT_EQ(0, tx->request_entity_len);
EXPECT_EQ(0, tx->request_message_len);
EXPECT_EQ(-1, tx->request_content_length);
EXPECT_EQ(0, tx->response_entity_len);
EXPECT_EQ(0, tx->response_message_len);
EXPECT_EQ(-1, tx->response_content_length);

struct ResponseBodyDataCallback *user_data = (struct ResponseBodyDataCallback *) htp_tx_get_user_data(tx);
ASSERT_TRUE(user_data);
ASSERT_EQ(0, user_data->data.size());
}

#endif

0 comments on commit 559667a

Please sign in to comment.