Commit f8f446ed authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

http: test case for quoted token value extraction

parent 68bb513b
......@@ -159,6 +159,27 @@ static time_t parse_date(const char *str)
return t1;
}
static const char *check_realm(const char *line, const char *realm)
{
struct vlc_http_msg *m;
char *value;
m = vlc_http_resp_create(401);
assert(m != NULL);
assert(vlc_http_msg_add_header(m, "WWW-Authenticate", "%s", line) == 0);
value = vlc_http_msg_get_basic_realm(m);
if (realm == NULL)
assert(value == NULL);
else
{
assert(value != NULL);
assert(!strcmp(value, realm));
free(value);
}
vlc_http_msg_destroy(m);
return realm;
}
int main(void)
{
struct vlc_http_msg *m;
......@@ -202,6 +223,15 @@ int main(void)
assert(parse_date("Sun, 06 Bug 1994 08:49:37 GMT") == -1);
assert(parse_date("bogus") == -1);
assert(check_realm("Basic realm=\"kingdom\"", "kingdom"));
assert(check_realm("BaSiC REALM= \"kingdom\"", "kingdom"));
assert(check_realm("basic Realm\t=\"kingdom\"", "kingdom"));
assert(check_realm("Basic charset=\"utf-8\", realm=\"kingdom\"",
"kingdom"));
assert(check_realm("Basic realm=\"Realm is \\\"Hello world!\\\"\"",
"Realm is \"Hello world!\""));
assert(check_realm("Basic", NULL) == NULL);
m = vlc_http_req_create("PRI", "https", "*", NULL);
assert(m != NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment