httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r153934 - in httpd/test/trunk/perl-framework: c-modules/test_ssl/mod_test_ssl.c t/ssl/extlookup.t
Date Tue, 15 Feb 2005 12:41:37 GMT
Author: jorton
Date: Tue Feb 15 04:41:36 2005
New Revision: 153934

URL: http://svn.apache.org/viewcvs?view=rev&rev=153934
Log:
Add test for ssl_ext_lookup optional function.

Added:
    httpd/test/trunk/perl-framework/t/ssl/extlookup.t
Modified:
    httpd/test/trunk/perl-framework/c-modules/test_ssl/mod_test_ssl.c

Modified: httpd/test/trunk/perl-framework/c-modules/test_ssl/mod_test_ssl.c
URL: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/c-modules/test_ssl/mod_test_ssl.c?view=diff&r1=153933&r2=153934
==============================================================================
--- httpd/test/trunk/perl-framework/c-modules/test_ssl/mod_test_ssl.c (original)
+++ httpd/test/trunk/perl-framework/c-modules/test_ssl/mod_test_ssl.c Tue Feb 15 04:41:36
2005
@@ -8,6 +8,12 @@
         SSLVerifyClient require
         SSLVerifyDepth  10
     </Location>
+
+    <Location /test_ssl_ext_lookup>
+        SetHandler test-ssl-ext-lookup
+        SSLVerifyClient require
+        SSLVerifyDepth  10
+    </Location>
 </IfModule>
 
 #endif
@@ -19,15 +25,17 @@
 #include "ap_config.h"
 #include "apr_optional.h"
 
-#if 0
-/* if you have ssl installed, just need to include this file */
+#if AP_MODULE_MAGIC_AT_LEAST(20040425, 0) /* simply include mod_ssl.h if using >= 2.1.0
*/
+
 #include "mod_ssl.h"
 
-#else
+#if AP_MODULE_MAGIC_AT_LEAST(20050127, 0) /* approx. when ssl_ext_lookup was added */
+#define HAVE_SSL_EXT_LOOKUP
+static APR_OPTIONAL_FN_TYPE(ssl_ext_lookup) *ext_lookup;
+#endif
 
-/* but for testing purposes, we'll hardcode the required stuff
- * that mod_ssl.h normally would
- */
+#else
+/* For use of < 2.0.x, inline the declaration: */
 
 APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup,
                         (apr_pool_t *, server_rec *,
@@ -41,8 +49,42 @@
 static void import_ssl_var_lookup(void)
 {
     var_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
+#ifdef HAVE_SSL_EXT_LOOKUP
+    ext_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_ext_lookup);
+#endif
+}
+
+#ifdef HAVE_SSL_EXT_LOOKUP
+static int test_ssl_ext_lookup(request_rec *r)
+{
+    const char *value;
+
+    if (strcmp(r->handler, "test-ssl-ext-lookup")
+        || r->method_number != M_GET) {
+        return DECLINED;
+    }
+
+    if (!r->args) {
+        ap_rputs("no query", r);
+        return OK;
+    }
+
+    if (!ext_lookup) {
+        ap_rputs("ssl_ext_lookup not available", r);
+        return OK;
+    }
+
+    value = ext_lookup(r->pool, r->connection, 1, r->args);
+
+    if (!value) value = "NULL";
+    
+    ap_rputs(value, r);
+    
+    return OK;
 }
 
+#endif
+
 static int test_ssl_var_lookup(request_rec *r)
 {
     char *value;
@@ -83,6 +125,9 @@
 static void test_ssl_register_hooks(apr_pool_t *p)
 {
     ap_hook_handler(test_ssl_var_lookup, NULL, NULL, APR_HOOK_MIDDLE);
+#ifdef HAVE_SSL_EXT_LOOKUP
+    ap_hook_handler(test_ssl_ext_lookup, NULL, NULL, APR_HOOK_MIDDLE);
+#endif
     ap_hook_optional_fn_retrieve(import_ssl_var_lookup,
                                  NULL, NULL, APR_HOOK_MIDDLE);
 }

Added: httpd/test/trunk/perl-framework/t/ssl/extlookup.t
URL: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/t/ssl/extlookup.t?view=auto&rev=153934
==============================================================================
--- httpd/test/trunk/perl-framework/t/ssl/extlookup.t (added)
+++ httpd/test/trunk/perl-framework/t/ssl/extlookup.t Tue Feb 15 04:41:36 2005
@@ -0,0 +1,23 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil;
+
+plan tests => 2, need_module 'test_ssl', need_min_apache_version(2.1);
+
+Apache::TestRequest::scheme("https");
+
+my $oid = "2.16.840.1.113730.1.13"; # Netscape certificate comment
+
+my $r = GET("/test_ssl_ext_lookup?$oid", cert => 'client_ok');
+
+ok t_cmp($r->code, 200, "ssl_ext_lookup works");
+
+my $c = $r->content;
+
+chomp $c;
+
+ok t_cmp($c, "This Is A Comment", "Retrieve nsComment extension");
+



Mime
View raw message