You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2018/10/21 08:00:20 UTC

svn commit: r1844467 - in /httpd/test/framework/trunk/t: conf/extra.conf.in htdocs/modules/usertrack/ htdocs/modules/usertrack/bar.html htdocs/modules/usertrack/foo.html modules/usertrack.t

Author: jailletc36
Date: Sun Oct 21 08:00:20 2018
New Revision: 1844467

URL: http://svn.apache.org/viewvc?rev=1844467&view=rev
Log:
Basic tests for mod_usertrack.

(inspired by mod_unique_id)

Added:
    httpd/test/framework/trunk/t/htdocs/modules/usertrack/
    httpd/test/framework/trunk/t/htdocs/modules/usertrack/bar.html
    httpd/test/framework/trunk/t/htdocs/modules/usertrack/foo.html
    httpd/test/framework/trunk/t/modules/usertrack.t
Modified:
    httpd/test/framework/trunk/t/conf/extra.conf.in

Modified: httpd/test/framework/trunk/t/conf/extra.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/extra.conf.in?rev=1844467&r1=1844466&r2=1844467&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/extra.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/extra.conf.in Sun Oct 21 08:00:20 2018
@@ -1293,6 +1293,14 @@ LimitRequestFields    32
    </Directory>
 </IfModule>
 
+<IfModule mod_usertrack.c>
+   <Directory @SERVERROOT@/htdocs/modules/usertrack/>
+      CookieTracking on
+      CookieName usertrack_test
+      CookieExpires "60 seconds"
+   </Directory>
+</IfModule>
+
 <IfModule mod_speling.c>
    <Directory @SERVERROOT@/htdocs/modules/speling/nocase/>
       CheckSpelling on

Added: httpd/test/framework/trunk/t/htdocs/modules/usertrack/bar.html
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/modules/usertrack/bar.html?rev=1844467&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/htdocs/modules/usertrack/bar.html (added)
+++ httpd/test/framework/trunk/t/htdocs/modules/usertrack/bar.html Sun Oct 21 08:00:20 2018
@@ -0,0 +1 @@
+bar

Added: httpd/test/framework/trunk/t/htdocs/modules/usertrack/foo.html
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/modules/usertrack/foo.html?rev=1844467&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/htdocs/modules/usertrack/foo.html (added)
+++ httpd/test/framework/trunk/t/htdocs/modules/usertrack/foo.html Sun Oct 21 08:00:20 2018
@@ -0,0 +1 @@
+foo

Added: httpd/test/framework/trunk/t/modules/usertrack.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/usertrack.t?rev=1844467&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/modules/usertrack.t (added)
+++ httpd/test/framework/trunk/t/modules/usertrack.t Sun Oct 21 08:00:20 2018
@@ -0,0 +1,62 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+use Apache::TestRequest;
+
+my @testcases = (
+    ['/modules/usertrack/foo.html'],
+    ['/modules/usertrack/bar.html'],
+    ['/modules/usertrack/foo.html'],
+    ['/modules/usertrack/bar.html'],
+);
+
+my $iters = 100;
+my %cookiex = ();
+
+plan tests => (scalar (@testcases) * 2 + 2) * $iters + 1, need 'mod_usertrack';
+
+foreach (1..$iters) {
+    my $nb_req = 1;
+    my $cookie = "";
+    
+    foreach my $t (@testcases) {
+        ## 
+        my $r = GET($t->[0], "Cookie" => $cookie);
+
+        # Checking for return code
+        ok t_cmp($r->code, 200, "Checking return code is '200'");
+
+        # Checking for content
+        my $setcookie = $r->header('Set-Cookie');
+
+        # Only the first and third requests of an iteration must have a Set-Cookie
+        if ((($nb_req == 1) || ($nb_req == 3)) && (defined $setcookie)) {
+            ok defined $setcookie;
+
+            print "Set-Cookie: " . $setcookie . "\n";
+            # Copy the cookie in order to send it back in the next requests
+            $cookie = substr($setcookie, 0, index($setcookie, ";") );
+            print "Cookie: " . $cookie . "\n";
+
+            # This cookie must not have been already seen
+            ok !exists($cookiex{$cookie});
+            $cookiex{$cookie} = 1;
+        }
+        else {
+            ok !(defined $setcookie);
+        }
+
+        # After the 2nd request, we lie and send a modified cookie.
+        # So the 3rd request whould receive a new cookie
+        if ($nb_req == 2) {
+            $cookie = "X" . $cookie;
+        }
+
+        $nb_req++;
+    }
+}
+
+# Check the overall number of cookies generated
+ok ((scalar (%cookiex)) == ($iters * 2));