TEST(UtilTest, ParseContentType6) { bstr *i = bstr_dup_c("multipart/form-data\t boundary=X"); bstr *e = bstr_dup_c("multipart/form-data\t"); bstr *ct = NULL; ASSERT_EQ(HTP_OK, htp_parse_ct_header(i, &ct)); ASSERT_TRUE(ct != NULL); ASSERT_TRUE(bstr_cmp(e, ct) == 0); bstr_free(ct); bstr_free(e); bstr_free(i); }
TEST(UtilTest, ParseHostPort1) { bstr *i = bstr_dup_c("www.example.com"); bstr *host; int port; uint64_t flags = 0; ASSERT_EQ(HTP_OK, htp_parse_hostport(i, &host, &port, &flags)); ASSERT_TRUE(bstr_cmp(i, host) == 0); ASSERT_EQ(-1, port); ASSERT_EQ(0, flags); bstr_free(host); bstr_free(i); }
TEST(UtilTest, ParseHostPort10) { bstr *i = bstr_dup_c("www.example.com:65536"); bstr *e = bstr_dup_c("www.example.com"); bstr *host = NULL; int port; uint64_t flags = 0; ASSERT_EQ(HTP_OK, htp_parse_hostport(i, &host, &port, &flags)); ASSERT_TRUE(host != NULL); ASSERT_TRUE(bstr_cmp(e, host) == 0); ASSERT_EQ(-1, port); ASSERT_TRUE(flags & HTP_HOST_INVALID); bstr_free(host); bstr_free(e); bstr_free(i); }
TEST(UtilTest, ParseHostPort6) { bstr *i = bstr_dup_c("www.example.com..:8001"); bstr *e = bstr_dup_c("www.example.com."); bstr *host = NULL; int port; uint64_t flags = 0; ASSERT_EQ(HTP_OK, htp_parse_hostport(i, &host, &port, &flags)); ASSERT_TRUE(host != NULL); ASSERT_TRUE(bstr_cmp(e, host) == 0); ASSERT_EQ(8001, port); ASSERT_EQ(0, flags); bstr_free(host); bstr_free(e); bstr_free(i); }
TEST(BstrTest, Cmp) { bstr *p1; bstr *p2; bstr *p3; bstr *p4; p1 = bstr_dup_c("arfarf"); p2 = bstr_dup_c("arfarf"); p3 = bstr_dup_c("arfArf"); p4 = bstr_dup_c("arfarf2"); EXPECT_EQ(0, bstr_cmp(p1,p1)); EXPECT_EQ(0, bstr_cmp(p1,p2)); EXPECT_EQ(0, bstr_cmp(p2,p1)); EXPECT_EQ(1, bstr_cmp(p1,p3)); EXPECT_EQ(-1, bstr_cmp(p3,p1)); EXPECT_EQ(-1, bstr_cmp(p1,p4)); EXPECT_EQ(1, bstr_cmp(p4,p1)); bstr_free(p1); bstr_free(p2); bstr_free(p3); bstr_free(p4); }
TEST_F(GUnzip, InvalidHeaderCrc) { htp_status_t rc = decompressFile("gztest-15-invalid-fhcrc.gz"); ASSERT_EQ(rc, HTP_OK); ASSERT_TRUE(output != NULL); ASSERT_TRUE(bstr_cmp(o_boxing_wizards, output) == 0); }
TEST_F(GUnzip, InvalidExtraFlags) { htp_status_t rc = decompressFile("gztest-14-invalid-xfl.gz"); ASSERT_EQ(rc, HTP_OK); ASSERT_TRUE(output != NULL); ASSERT_TRUE(bstr_cmp(o_boxing_wizards, output) == 0); }
TEST_F(GUnzip, InvalidInputSize) { htp_status_t rc = decompressFile("gztest-13-invalid-isize.gz"); ASSERT_EQ(rc, HTP_OK); ASSERT_TRUE(output != NULL); ASSERT_TRUE(bstr_cmp(o_boxing_wizards, output) == 0); }
TEST_F(GUnzip, InvalidMethod) { htp_status_t rc = decompressFile("gztest-11-invalid-method.gz.gz"); ASSERT_EQ(rc, HTP_OK); ASSERT_TRUE(output != NULL); ASSERT_TRUE(bstr_cmp(o_boxing_wizards, output) == 0); }
TEST_F(GUnzip, Multipart) { htp_status_t rc = decompressFile("gztest-10-multipart.gz"); ASSERT_EQ(rc, HTP_OK); ASSERT_TRUE(output != NULL); ASSERT_TRUE(bstr_cmp(o_boxing_wizards, output) == 0); }
TEST_F(GUnzip, FRESERVED3) { htp_status_t rc = decompressFile("gztest-09-freserved3.gz"); ASSERT_EQ(rc, HTP_OK); ASSERT_TRUE(output != NULL); ASSERT_TRUE(bstr_cmp(o_boxing_wizards, output) == 0); }
TEST_F(GUnzip, FTEXT) { htp_status_t rc = decompressFile("gztest-06-ftext.gz"); ASSERT_EQ(rc, HTP_OK); ASSERT_TRUE(output != NULL); ASSERT_TRUE(bstr_cmp(o_boxing_wizards, output) == 0); }