bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch/* Valid IMAP URL tests */
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmodystatic const struct valid_imap_url_test valid_url_tests[] = {
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://%68endri%6B;AUTH=GSS%41PI@%65%78%61%6d%70%6c%65.com",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://beelzebub@666.4example.com:999",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Trash/..",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Trash/../",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Trash/../..",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX%3BTrash",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX;UIDVALIDITY=1341",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/;UIDVALIDITY=23423",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Drafts;UIDVALIDITY=6567",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .mailbox = "INBOX/Drafts", .uidvalidity = 6567 }
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Drafts;UIDVALIDITY=788/;UID=16",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .mailbox = "INBOX/Drafts", .uidvalidity = 788,
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Drafts;UIDVALIDITY=788/;UID=16/..",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .mailbox = "INBOX/Drafts", .uidvalidity = 788,
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Drafts;UIDVALIDITY=788/;UID=16/../..",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Junk;UIDVALIDITY=27667/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";UID=434/;SECTION=HEADER",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .mailbox = "INBOX/Junk", .uidvalidity = 27667,
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Important/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";UID=437/;SECTION=1.2.MIME",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Important/;UID=56/;SECTION=AA/BB",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Important/;UID=56/;SECTION=AA/BB/..",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Important/;UID=56/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";SECTION=AA/BB/../..",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Important/;UID=234/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";SECTION=HEADER.FIELDS%20(%22To%22%20%22From%22)",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .uid = 234, .section = "HEADER.FIELDS (\"To\" \"From\")" }
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/Important/;UID=234/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";PARTIAL=10.250",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .uid = 234, .section = NULL, .partial_offset = 10, .partial_size = 250 }
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://hendrik@example.com/INBOX/Important/;UID=34534/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";SECTION=1.3.TEXT/;PARTIAL=0.34254",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://hendrik@example.com/INBOX/Sent"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";UIDVALIDITY=534?SUBJECT%20%22Frop?%22",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .mailbox = "INBOX/Accounts/user@example.com" }
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "../../%23news;UIDVALIDITY=546/;UID=456",
62aa68310d6f42467ca26880f678173bf1d26a83Stephan Bosch .have_partial = TRUE, .partial_offset = 1024, .partial_size = 1024 },
62aa68310d6f42467ca26880f678173bf1d26a83Stephan Bosch .have_partial = TRUE, .partial_offset = 1024, .partial_size = 1024 }
62aa68310d6f42467ca26880f678173bf1d26a83Stephan Bosch .have_partial = TRUE, .partial_offset = 1024, .partial_size = 1024 },
62aa68310d6f42467ca26880f678173bf1d26a83Stephan Bosch .have_partial = TRUE, .partial_offset = 1024, .partial_size = 1024 }
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .have_partial = TRUE, .partial_offset = 0, .partial_size = 1024 },
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .have_partial = TRUE, .partial_offset = 1024, .partial_size = 1024 }
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .have_partial = TRUE, .partial_offset = 1024, .partial_size = 1024 },
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .have_partial = TRUE, .partial_offset = 0, .partial_size = 512 }
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/;UID=377;URLAUTH=anonymous",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .uauth_rumpurl = "imap://user@example.com/INBOX/;UID=377"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/;UID=377"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous:internal:4142434445464748494A4B4C4D4E4F5051525354",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .uauth_rumpurl = "imap://user@example.com/INBOX/;UID=377"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .uauth_token = (const unsigned char *)"ABCDEFGHIJKLMNOPQRST",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/;UID=377"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";EXPIRE=2011-02-12T12:45:14+01:00"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=user+frop:internal:4142434445464748494A4B4C4D4E4F5051525354",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .uauth_rumpurl = "imap://user@example.com/INBOX/;UID=377"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";EXPIRE=2011-02-12T12:45:14+01:00;URLAUTH=user+frop",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .uauth_token = (const unsigned char *)"ABCDEFGHIJKLMNOPQRST",
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmodystatic const unsigned int valid_url_test_count = N_ELEMENTS(valid_url_tests);
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch unsigned int i;
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch for (i = 0; i < valid_url_test_count; i++) T_BEGIN {
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch enum imap_url_parse_flags flags = valid_url_tests[i].flags;
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmody const struct imap_url *urlt = &valid_url_tests[i].url_parsed;
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmody const struct imap_url *urlb = &valid_url_tests[i].url_base;
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch test_begin(t_strdup_printf("imap url valid [%d]", i));
639bb36b12b9f9bb54c8bb1be50eac623622f8a0Timo Sirainen if (imap_url_parse(url, urlb, flags, &urlp, &error) < 0)
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch test_out_reason(t_strdup_printf("imap_url_parse(%s)",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch valid_url_tests[i].url), urlp != NULL, error);
66134fbce11778241ca9f8458ee2a0488a05bde0Stephan Bosch if (urlp->host.name == NULL || urlt->host.name == NULL) {
66134fbce11778241ca9f8458ee2a0488a05bde0Stephan Bosch test_out_quiet(t_strdup_printf("url->host.name = %s", urlp->host.name),
66134fbce11778241ca9f8458ee2a0488a05bde0Stephan Bosch test_out_quiet(t_strdup_printf("url->host.name = %s", urlp->host.name),
66134fbce11778241ca9f8458ee2a0488a05bde0Stephan Bosch strcmp(urlp->host.name, urlt->host.name) == 0);
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->userid == NULL || urlt->userid == NULL) {
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->userid = %s", urlp->userid),
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->userid = %s", urlp->userid),
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->auth_type == NULL || urlt->auth_type == NULL) {
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->auth_type = %s", urlp->auth_type),
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->auth_type = %s", urlp->auth_type),
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody strcmp(urlp->auth_type, urlt->auth_type) == 0);
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->port = %u", urlp->port),
66134fbce11778241ca9f8458ee2a0488a05bde0Stephan Bosch test_out_quiet("url->host.ip = (unspecified)",
66134fbce11778241ca9f8458ee2a0488a05bde0Stephan Bosch urlp->host.ip.family == urlt->host.ip.family);
66134fbce11778241ca9f8458ee2a0488a05bde0Stephan Bosch urlp->host.ip.family == urlt->host.ip.family);
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->mailbox == NULL || urlt->mailbox == NULL) {
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->mailbox = %s", urlp->mailbox),
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->mailbox = %s", urlp->mailbox),
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->uidvalidity = %u", urlp->uidvalidity),
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->uid = %u", urlp->uid),
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->section == NULL || urlt->section == NULL) {
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->section = %s", urlp->section),
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->section = %s", urlp->section),
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->partial = %"PRIuUOFF_T".%"PRIuUOFF_T,
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody urlp->partial_offset == urlt->partial_offset &&
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->search_program == NULL || urlt->search_program == NULL) {
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody "url->search_program = %s", urlp->search_program),
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody "url->search_program = %s", urlp->search_program),
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody strcmp(urlp->search_program, urlt->search_program) == 0);
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody "url->uauth_rumpurl = %s", urlp->uauth_rumpurl), FALSE);
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody "url->uauth_rumpurl = %s", urlp->uauth_rumpurl),
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody strcmp(urlp->uauth_rumpurl, urlt->uauth_rumpurl) == 0);
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->uauth_access_application = %s",
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody urlp->uauth_access_application == urlt->uauth_access_application);
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->uauth_access_application = %s",
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->uauth_access_user = %s",
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody urlp->uauth_access_user == urlt->uauth_access_user);
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->uauth_access_user = %s",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->uauth_mechanism == NULL || urlt->uauth_mechanism == NULL) {
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody "url->uauth_mechanism = %s", urlp->uauth_mechanism),
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody urlp->uauth_mechanism == urlt->uauth_mechanism);
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch "url->uauth_mechanism = %s", urlp->uauth_mechanism),
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody strcmp(urlp->uauth_mechanism, urlt->uauth_mechanism) == 0);
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->uauth_token == NULL || urlt->uauth_token == NULL) {
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch bool equal = urlp->uauth_token_size == urlt->uauth_token_size;
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody "url->uauth_token_size = %"PRIuSIZE_T, urlp->uauth_token_size),
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch for (i = 0; i < urlp->uauth_token_size; i++) {
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch if (urlp->uauth_token[i] != urlt->uauth_token[i]) {
e87b25495e78a6f61f236b188bfd68070eff3295Phil Carmody test_out_quiet(t_strdup_printf("url->uauth_token [index=%d]", (int)i),
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmodystatic const struct invalid_imap_url_test invalid_url_tests[] = {
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/;UID=377/;SECTION=TEXT?ALL"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user@example.com/INBOX/#Fragment"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://[v08.234:232:234:234:2221]/INBOX"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://user;AUTH=frop;friep@example.com"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX;UIDVALIDITY=23423;FROP=friep/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX;UIDVALIDITY=0/;UID=377"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX;UIDVALIDITY=/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX;UIDVALIDITY=33a/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;FROP=friep/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=35/;SECTION=ALL;FROP=43/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=35/;SECTION=/"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=34/;PARTIAL="
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=34/;PARTIAL=0."
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=34/;PARTIAL=0.e10"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=34/;PARTIAL=.3"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=34/;PARTIAL=5t4.3"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=34/;PARTIAL=0.0"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=34/;PARTIAL=0.23409823409820938409823"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377/;FROP=34"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;FROP=34"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;EXPIRE=2010-02-02T12:00:12Z"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous:internal:0ad89fafd79f54afe4523f45aadf2afe"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;EXPIRE=2011-15-02T00:00:00Z"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous:internal:0ad89fafd79f54afe4523f45aadf2afe",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;EXPIRE=2011-10-02T00:00:00Z",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "/INBOX/;UID=377;EXPIRE=2011-10-02T00:00:00Z"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous:internal:0ad89fafd79f54afe4523f45aadf2afe",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;URLAUTH=",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=:internal:0ad89fafd79f54afe4523f45aadf2afe",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=user+:internal:0ad89fafd79f54afe4523f45aadf2afe",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=+frop:internal:0ad89fafd79f54afe4523f45aadf2afe",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;URLAUTH=anonymous:",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous::0ad89fafd79f54afe4523f45aadf2afe",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;URLAUTH=anonymous:internal:",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous:internal:fd79f54afe4523",
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch .url = "imap://example.com/INBOX/;UID=377;EXPIRE=2011-10-02T00:00:00Z"
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch ";URLAUTH=anonymous:internal:0ad89fafd79f54afe4523q45aadf2afe",
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmodystatic const unsigned int invalid_url_test_count = N_ELEMENTS(invalid_url_tests);
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch unsigned int i;
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch for (i = 0; i < invalid_url_test_count; i++) T_BEGIN {
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch enum imap_url_parse_flags flags = invalid_url_tests[i].flags;
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmody const struct imap_url *urlb = &invalid_url_tests[i].url_base;
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch test_begin(t_strdup_printf("imap url invalid [%d]", i));
639bb36b12b9f9bb54c8bb1be50eac623622f8a0Timo Sirainen if (imap_url_parse(url, urlb, flags, &urlp, &error) < 0)
6ae6496c225238a2c55a8cd96744ad976c44a726Stephan Bosch test_out_reason(t_strdup_printf("parse %s", url), urlp == NULL, error);
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://10.0.0.1/",
17c29e3e2246972c3d988e05d91b9286398a624fStephan Bosch "imap://[::1]/",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user@host.example.com/",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user@host.example.com:993/",
4c8646ca7a1bfe3e5a43f1f3e329f8ff8c24d851Stephan Bosch "imap://su%3auser@host.example.com/",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX/;UID=5",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX;UIDVALIDITY=15/;UID=5",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX;UIDVALIDITY=15/;UID=5"
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "/;SECTION=TEXT",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX;UIDVALIDITY=15/;UID=5"
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "/;SECTION=TEXT/;PARTIAL=1",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX;UIDVALIDITY=15/;UID=5"
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "/;SECTION=TEXT/;PARTIAL=1.14",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX;UIDVALIDITY=15/;UID=5"
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "/;SECTION=TEXT/;PARTIAL=1.14;URLAUTH=anonymous",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX;UIDVALIDITY=15/;UID=5"
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "/;SECTION=TEXT/;PARTIAL=1.14;URLAUTH=user+username",
62aa68310d6f42467ca26880f678173bf1d26a83Stephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX?SUBJECT%20%22Frop?%22",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user%3ba@host.example.com/",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user%40example.com@host.example.com/",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user%40example.com;AUTH=STR%23ANGE@host.example.com/",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user;AUTH=PLAIN@host.example.com/INBOX/Important%3bWork",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user@host.example.com/%23shared/news",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user@host.example.com/INBOX;UIDVALIDITY=15/;UID=5"
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "/;SECTION=HEADER.FIELDS%20(DATE%20FROM)",
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "imap://user@host.example.com/INBOX;UIDVALIDITY=15/;UID=5"
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch "/;SECTION=TEXT/;PARTIAL=1.14;URLAUTH=user+user%3bname",
e9c433c5b8ef9a1b4246ebe10beb90fa01e05cafPhil Carmodystatic const unsigned int parse_create_url_test_count = N_ELEMENTS(parse_create_url_tests);
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch unsigned int i;
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch for (i = 0; i < parse_create_url_test_count; i++) T_BEGIN {
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch test_begin(t_strdup_printf("imap url parse/create [%d]", i));
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch (url, NULL, IMAP_URL_PARSE_ALLOW_URLAUTH, &urlp, &error) < 0)
4d955db590c3d76a631dfc5d37bcdf578a43e55aStephan Bosch test_out_reason(t_strdup_printf("parse %s", url), urlp != NULL, error);
289ce1246b1c7511f8ceec02344316064ffbe546Phil Carmody ("create %s", urlnew), strcmp(url, urlnew) == 0);
baf3e87e186453fda13bd21f7cbcb2efc8492e8bTimo Sirainen static void (*const test_functions[])(void) = {