From fe31fe8bf0ff8028123698d3097347ffdff3c214 Mon Sep 17 00:00:00 2001 From: Bertrand Paquet Date: Sun, 8 Jul 2012 02:00:31 +0200 Subject: [PATCH] Add tests on user info --- test.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/test.c b/test.c index f7dfcfe..a9fc05f 100644 --- a/test.c +++ b/test.c @@ -51,6 +51,7 @@ struct message { char body[MAX_ELEMENT_SIZE]; size_t body_size; const char *host; + const char *userinfo; uint16_t port; int num_headers; enum { NONE=0, FIELD, VALUE } last_header_element; @@ -631,6 +632,7 @@ const struct message requests[] = ,.fragment= "" ,.request_path= "" ,.request_url= "http://hypnotoad.org?hail=all" + ,.host= "hypnotoad.org" ,.num_headers= 0 ,.headers= { } ,.body= "" @@ -873,6 +875,28 @@ const struct message requests[] = ,.body= "" } +#define PROXY_WITH_BASIC_AUTH 33 +, {.name= "host:port and basic_auth" + ,.type= HTTP_REQUEST + ,.raw= "GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1\r\n" + "\r\n" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.fragment= "" + ,.request_path= "/toto" + ,.request_url= "http://a%12:b!&*$@hypnotoad.org:1234/toto" + ,.host= "hypnotoad.org" + ,.userinfo= "a%12:b!&*$" + ,.port= 1234 + ,.num_headers= 0 + ,.headers= { } + ,.body= "" + } + + , {.name= NULL } /* sentinel */ }; @@ -1801,6 +1825,10 @@ message_eq (int index, const struct message *expected) MESSAGE_CHECK_URL_EQ(&u, expected, m, host, UF_HOST); } + if (expected->userinfo) { + MESSAGE_CHECK_URL_EQ(&u, expected, m, userinfo, UF_USERINFO); + } + m->port = (u.field_set & (1 << UF_PORT)) ? u.port : 0; @@ -2170,6 +2198,25 @@ const struct url_test url_tests[] = ,.rv=0 } +, {.name="complex URL with basic auth from node js url parser doc" + ,.url="http://a:b@host.com:8080/p/a/t/h?query=string#hash" + ,.is_connect=0 + ,.u= + {.field_set= (1<