summaryrefslogtreecommitdiff
path: root/src/transport/test_http_common.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-01-18 11:16:19 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-01-18 11:16:19 +0000
commit2d610f41a9ab136f63f08bb8029d4c68d6a53f80 (patch)
tree7afb53048a0cd3b195d8b93208850e0b30d6b7bb /src/transport/test_http_common.c
parentdc8ac5f2e7117530a72cb972405aa7aea15d8a06 (diff)
change
Diffstat (limited to 'src/transport/test_http_common.c')
-rw-r--r--src/transport/test_http_common.c285
1 files changed, 37 insertions, 248 deletions
diff --git a/src/transport/test_http_common.c b/src/transport/test_http_common.c
index 05c4adb64..d7a203336 100644
--- a/src/transport/test_http_common.c
+++ b/src/transport/test_http_common.c
@@ -113,280 +113,69 @@ check (struct SplittedHTTPAddress *addr,
}
void
-test_hostname ()
+check_pass (char *src,
+ char * protocol,
+ char * host,
+ int port,
+ char * path)
{
- struct SplittedHTTPAddress * spa;
- spa = http_split_address ("http://test.local");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, ""))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://test.local");
+ struct SplittedHTTPAddress * spa;
+ spa = http_split_address (src);
if (NULL == spa)
{
GNUNET_break (0);
}
else
{
- if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, ""))
+ if (GNUNET_OK != check(spa, protocol, host, port, path))
{
GNUNET_break (0);
}
clean (spa);
}
+}
+void
+test_hostname ()
+{
+ check_pass("http://test.local", "http", "test.local", HTTP_DEFAULT_PORT, "");
+ check_pass("http://test.local/", "http", "test.local", HTTP_DEFAULT_PORT, "/");
+ check_pass("http://test.local/path", "http", "test.local", HTTP_DEFAULT_PORT, "/path");
+ check_pass("http://test.local/path/", "http", "test.local", HTTP_DEFAULT_PORT, "/path/");
+ check_pass("http://test.local:81", "http", "test.local", 81, "");
+ check_pass("http://test.local:81/", "http", "test.local", 81, "/");
+ check_pass("http://test.local:81/path", "http", "test.local", 81, "/path");
+ check_pass("http://test.local:81/path/", "http", "test.local", 81, "/path/");
- spa = http_split_address ("http://test.local/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://test.local/path");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "/path"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://test.local/path/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "test.local", HTTP_DEFAULT_PORT, "/path/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
-
-
- }
-
- spa = http_split_address ("http://test.local:1000/path/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "test.local", 1000, "/path/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
}
void
test_ipv4 ()
{
- struct SplittedHTTPAddress * spa;
- spa = http_split_address ("http://127.0.0.1");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, ""))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://127.0.0.1");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, ""))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
-
- spa = http_split_address ("http://127.0.0.1/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://127.0.0.1/path");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://127.0.0.1/path/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
-
-
- }
-
- spa = http_split_address ("http://127.0.0.1:1000/path/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "127.0.0.1", 1000, "/path/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
+ check_pass("http://127.0.0.1", "http", "127.0.0.1", HTTP_DEFAULT_PORT, "");
+ check_pass("http://127.0.0.1/", "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/");
+ check_pass("http://127.0.0.1/path", "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path");
+ check_pass("http://127.0.0.1/path/", "http", "127.0.0.1", HTTP_DEFAULT_PORT, "/path/");
+ check_pass("http://127.0.0.1:81", "http", "127.0.0.1", 81, "");
+ check_pass("http://127.0.0.1:81/", "http", "127.0.0.1", 81, "/");
+ check_pass("http://127.0.0.1:81/path", "http", "127.0.0.1", 81, "/path");
+ check_pass("http://127.0.0.1:81/path/", "http", "127.0.0.1", 81, "/path/");
}
void
test_ipv6 ()
{
- struct SplittedHTTPAddress * spa;
- spa = http_split_address ("http://[::1]");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, ""))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://[::1]");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, ""))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
-
- spa = http_split_address ("http://[::1]/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://[::1]/path");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "/path"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-
- spa = http_split_address ("http://[::1]/path/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "[::1]", HTTP_DEFAULT_PORT, "/path/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
+ check_pass("http://[::1]", "http", "[::1]", HTTP_DEFAULT_PORT, "");
+ check_pass("http://[::1]/", "http", "[::1]", HTTP_DEFAULT_PORT, "/");
+ check_pass("http://[::1]/path", "http", "[::1]", HTTP_DEFAULT_PORT, "/path");
+ check_pass("http://[::1]/path/", "http", "[::1]", HTTP_DEFAULT_PORT, "/path/");
+ check_pass("http://[::1]:81", "http", "[::1]", 81, "");
+ check_pass("http://[::1]:81/", "http", "[::1]", 81, "/");
+ check_pass("http://[::1]:81/path", "http", "[::1]", 81, "/path");
+ check_pass("http://[::1]:81/path/", "http", "[::1]", 81, "/path/");
+}
- }
-
- spa = http_split_address ("http://[::1]:1000/path/");
- if (NULL == spa)
- {
- GNUNET_break (0);
- }
- else
- {
- if (GNUNET_OK != check(spa, "http", "[::1]", 1000, "/path/"))
- {
- GNUNET_break (0);
- }
- clean (spa);
- }
-}
int
main (int argc, char *argv[])