commit: r1756 - neon/trunk/test

joe at manyfish.co.uk joe at manyfish.co.uk
Mon Dec 14 15:55:43 EST 2009


Author: joe
Date: Mon Dec 14 12:55:43 2009
New Revision: 1756

Modified:
   neon/trunk/test/auth.c
   neon/trunk/test/props.c
   neon/trunk/test/redirect.c

Log:
* test/auth.c, test/redirect.c, test/props.c: Adapt to use
  session_server, proxied_session_server.


Modified: neon/trunk/test/auth.c
==============================================================================
--- neon/trunk/test/auth.c	(original)
+++ neon/trunk/test/auth.c	Mon Dec 14 12:55:43 2009
@@ -789,17 +789,15 @@
              parms->stale);
 
     if (parms->proxy) {
-        sess = ne_session_create("http", "www.example.com", 80);
-        ne_session_proxy(sess, "localhost", 7777);
+        CALL(proxied_session_server(&sess, "www.example.com", 80,
+                                    serve_digest, parms));
         ne_set_proxy_auth(sess, auth_cb, NULL);
     } 
     else {
-        sess = ne_session_create("http", "localhost", 7777);
+        CALL(session_server(&sess, serve_digest, parms));
         ne_set_server_auth(sess, auth_cb, NULL);
     }
 
-    CALL(spawn_server(7777, serve_digest, parms));
-
     do {
         CALL(any_2xx_request(sess, "/fish"));
     } while (--parms->num_requests);
@@ -1070,12 +1068,11 @@
     parms.domain = "http://localhost:7777/fish/ https://example.com /agaor /other";
     parms.num_requests = 6;
 
-    CALL(make_session(&sess, serve_digest, &parms));
+    CALL(proxied_session_server(&sess, "localhost", 7777,
+                                serve_digest, &parms));
 
     ne_set_server_auth(sess, auth_cb, NULL);
 
-    ne_session_proxy(sess, "localhost", 7777);
-
     CALL(any_2xx_request(sess, "/fish/0"));
     CALL(any_2xx_request(sess, "/outside"));
     CALL(any_2xx_request(sess, "/others"));
@@ -1101,12 +1098,11 @@
     parms.domain = "foo";
     parms.num_requests = 1;
 
-    CALL(make_session(&sess, serve_digest, &parms));
+    CALL(proxied_session_server(&sess, "www.example.com", 80,
+                                serve_digest, &parms));
 
     ne_set_server_auth(sess, auth_cb, NULL);
 
-    ne_session_proxy(sess, "localhost", 7777);
-
     any_2xx_request(sess, "/fish/0");
     
     ne_session_destroy(sess);

Modified: neon/trunk/test/props.c
==============================================================================
--- neon/trunk/test/props.c	(original)
+++ neon/trunk/test/props.c	Mon Dec 14 12:55:43 2009
@@ -1,6 +1,6 @@
 /* 
    Tests for property handling
-   Copyright (C) 2002-2008, Joe Orton <joe at manyfish.co.uk>
+   Copyright (C) 2002-2009, Joe Orton <joe at manyfish.co.uk>
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -242,13 +242,15 @@
 static int run_207_response(char *resp, const char *expected)
 {
     ne_buffer *buf = ne_buffer_create();
-    ne_session *sess = ne_session_create("http", "localhost", 7777);
+    ne_session *sess;
     ne_xml_parser *p = ne_xml_create();
     ne_207_parser *p207;
-    ne_request *req = ne_request_create(sess, "PROPFIND", "/foo");
+    ne_request *req;
     ne_uri base = {0};
     struct propctx ctx;
 
+    CALL(session_server(&sess, single_serve_string, resp));
+    req = ne_request_create(sess, "PROPFIND", "/foo");
     ne_fill_server_uri(sess, &base);
     base.path = ne_strdup("/foo");
     p207 = ne_207_create(p, &base, buf);
@@ -263,7 +265,6 @@
     ctx.p207 = p207;
     ne_xml_push_handler(p, tos_startprop, tos_cdata, tos_endprop, &ctx);
 
-    CALL(spawn_server(7777, single_serve_string, resp));
 
     ONREQ(ne_request_dispatch(req));
 
@@ -592,14 +593,14 @@
           0, PF_SIMPLE},
 
         /* whitespace handling. */
-        { MULTI_207(RESP_207("\r\nhttp://localhost:7777/alpha ",
+        { MULTI_207(RESP_207("\r\nhttp://localhost/alpha ",
                              PSTAT_207(PROPS_207(APROP_207("alpha", "beta"))
                                        "<D:status>\r\nHTTP/1.1 200 OK </D:status>"))),
           "results(/alpha,prop:[{DAV:,alpha}='beta':{200 OK}];)//",
           0, PF_SIMPLE},
         
         /* attribute handling. */
-        { MULTI_207(RESP_207("\r\nhttp://localhost:7777/alpha ",
+        { MULTI_207(RESP_207("\r\nhttp://localhost/alpha ",
                              PSTAT_207(PROPS_207("<D:alpha>"
                                                  "<D:foo D:fee='bar' bar='fee'>beta</D:foo></D:alpha>")
                                        "<D:status>\r\nHTTP/1.1 200 OK </D:status>"))),

Modified: neon/trunk/test/redirect.c
==============================================================================
--- neon/trunk/test/redirect.c	(original)
+++ neon/trunk/test/redirect.c	Mon Dec 14 12:55:43 2009
@@ -74,10 +74,19 @@
     ne_session *sess;
     const ne_uri *loc;
     char *unp;
+    char *full_expect = NULL;
     
     CALL(make_session(&sess, serve_redir, args));
     ne_redirect_register(sess);
     
+    if (expect[0] == '/') {
+        ne_uri uri = {0};
+        ne_fill_server_uri(sess, &uri);
+        uri.path = (char *)expect;
+        full_expect = ne_uri_unparse(&uri);
+        expect = full_expect;
+    }
+
     CALL(process_redir(sess, args->path, &loc));
     ONN("redirect location was NULL", loc == NULL);
 
@@ -87,6 +96,7 @@
 
     ne_session_destroy(sess);
     CALL(await_server());
+    if (full_expect) ne_free(full_expect);
 
     return OK;
 }
@@ -115,19 +125,19 @@
 static int non_absolute(void)
 {
     struct redir_args args = {302, "/foo/bar/blah", PATH};
-    return check_redir(&args, "http://localhost:7777/foo/bar/blah");
+    return check_redir(&args, "/foo/bar/blah");
 }
 
 static int relative_1(void)
 {
     struct redir_args args = {302, "norman", "/foo/bar"};
-    return check_redir(&args, "http://localhost:7777/foo/norman");
+    return check_redir(&args, "/foo/norman");
 }
     
 static int relative_2(void)
 {
     struct redir_args args = {302, "wishbone", "/foo/bar/"};
-    return check_redir(&args, "http://localhost:7777/foo/bar/wishbone");
+    return check_redir(&args, "/foo/bar/wishbone");
 }    
 
 #if 0
@@ -154,22 +164,21 @@
  * been encountered, or redirect hooks aren't registered. */
 static int no_redirect(void)
 {
-    ne_session *sess = ne_session_create("http", "localhost", 7777);
+    ne_session *sess;
     const ne_uri *loc;
 
+    CALL(session_server(&sess, single_serve_string, 
+                        "HTTP/1.1 200 OK\r\n" "Content-Length: 0\r\n\r\n"
+                        "HTTP/1.0 302 Get Ye Away\r\n"
+                        "Location: /blah\r\n" "\r\n"));
     ONN("redirect non-NULL before register", ne_redirect_location(sess));
     ne_redirect_register(sess);
     ONN("initial redirect non-NULL", ne_redirect_location(sess));
 
-    CALL(spawn_server(7777, single_serve_string, 
-                      "HTTP/1.0 200 OK\r\n\r\n\r\n"));
     ONREQ(any_request(sess, "/noredir"));
-    CALL(await_server());
 
     ONN("redirect non-NULL after non-redir req", ne_redirect_location(sess));
 
-    CALL(spawn_server(7777, single_serve_string, "HTTP/1.0 302 Get Ye Away\r\n"
-                      "Location: /blah\r\n" "\r\n"));
     CALL(process_redir(sess, "/foo", &loc));
     CALL(await_server());
 



More information about the neon-commits mailing list