You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tcl.apache.org by mx...@apache.org on 2024/04/30 14:31:54 UTC
(tcl-rivet) 04/06: test scripts improved, new test for ::rivet::raw_post
This is an automated email from the ASF dual-hosted git repository.
mxmanghi pushed a commit to branch quattuor
in repository https://gitbox.apache.org/repos/asf/tcl-rivet.git
commit 26a0202a1f90f336306f767cb22d4497b5d47664
Author: Massimo Manghi <mx...@apache.org>
AuthorDate: Thu May 4 08:46:28 2023 +0200
test scripts improved, new test for ::rivet::raw_post
---
ChangeLog | 9 +++++++++
tests/apachetest/apachetest.tcl | 37 ++++++++++++++++++++++++++++---------
tests/post.rvt | 7 +++++--
tests/post.test | 9 +++++++++
tests/rivet.test | 18 +++++++++++-------
5 files changed, 62 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f0f648d..2b82f58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-05-14 Massimo Manghi <mx...@apache.org>
+ * tests/rivet.test: more contributions provided by Scott Pitcher <sc...@svptechnicalservices.com.au>)
+ * tests/apachetest/apachetest.tcl: More improvements to the test script. Now
+ handling also Apache directive IncludeOptional and enabling execution control
+ through environment variables
+ * tests/post.rvt:
+ * tests/post.test: add a test for ::rivet::raw_post
+
+ *
2023-04-11 Massimo Manghi <mx...@apache.org>
* src/mod_rivet_ng/TclWebapache.c:
* src/mod_rivet_ng/rivetCore.c:
diff --git a/tests/apachetest/apachetest.tcl b/tests/apachetest/apachetest.tcl
index d9658c8..3549b23 100644
--- a/tests/apachetest/apachetest.tcl
+++ b/tests/apachetest/apachetest.tcl
@@ -70,6 +70,12 @@ namespace eval apachetest {
variable httpd_version $::httpd_version
# this file should be in the same directory this script is.
variable templatefile [file join [file dirname [info script]] template.conf.2.tcl]
+
+ variable httpd_root
+ set httpd_root ""
+ variable server_config_file
+ set server_config_file ""
+
}
# apachetest::need_modules --
@@ -271,17 +277,21 @@ proc apachetest::gethttpdconf { binname } {
# Text of configuration files.
proc apachetest::getallincludes { conffile } {
+ variable httpd_root
if [file exists $conffile] {
- set fl [open $conffile r]
- set data [read $fl]
- close $fl
-
- set newdata {}
- foreach line [split $data \n] {
- # Look for Include lines.
- if { [regexp -line {^[^\#]*Include +(.*)} $line match file] } {
+ set fl [open $conffile r]
+ set data [read $fl]
+ close $fl
+
+ set newdata {}
+ foreach line [split $data \n] {
+ # Look for Include lines.
+ if { [regexp -line {^[^\#]*Include(?:|Optional) +(.*)} $line match file]} {
puts "including files from $file"
set file [string trim $file]
+ if {[string index $file 0] != "/"} {
+ set file [file join $httpd_root $file]
+ }
# Include directives accept as argument a file, a directory
# or a glob-style file matching pattern. Patterns usually match
@@ -338,11 +348,15 @@ proc apachetest::getallincludes { conffile } {
proc apachetest::getloadmodules { conffile needtoget } {
+ variable httpd_root
puts "checking $conffile "
set confdata [getallincludes $conffile]
set loadline [list]
regexp -line {^[^#]*(ServerRoot[\s]?[\"]?)([^\"]+)()([\"]?)} $confdata \
- match sub1 server_root_path sub2
+ match sub1 server_root_path sub2
+ if {![info exists server_root_path]} {
+ set server_root_path $httpd_root
+ }
foreach mod $needtoget {
# Look for LoadModule lines.
@@ -371,9 +385,14 @@ proc apachetest::getloadmodules { conffile needtoget } {
# Compare what's compiled in with what we need.
proc apachetest::determinemodules { binname } {
+ variable server_config_file
+ variable httpd_root
variable module_assoc
+
set compiledin [lsort [getcompiledin $binname]]
set conffile [gethttpdconf $binname]
+ set server_config_file $conffile
+ set httpd_root [file dirname $conffile]
foreach {n k} [array get module_assoc] {
lappend needed $k
diff --git a/tests/post.rvt b/tests/post.rvt
index 1257750..a887723 100644
--- a/tests/post.rvt
+++ b/tests/post.rvt
@@ -1,5 +1,5 @@
<?
-
+::rivet::load_env env
if { [ ::rivet::var number ] > 0 } {
# get/post variables 1.1
if { [ ::rivet::var exists foobar ] } {
@@ -16,6 +16,9 @@ if { [ ::rivet::var number ] > 0 } {
if { [::rivet::var exists lstvar2] } {
puts "\[::rivet::var list lstvar2\] = [::rivet::var list lstvar2]\n"
}
-}
+} elseif {[string match "POST" $env(REQUEST_METHOD)]} {
+ # Return the raw body encoded as ascii
+ puts -nonewline "\[::rivet::raw_post\] = [binary encode hex [::rivet::raw_post]]"
+}
?>
diff --git a/tests/post.test b/tests/post.test
index 8fed8dc..bb7a737 100644
--- a/tests/post.test
+++ b/tests/post.test
@@ -60,3 +60,12 @@ var_post = postarg1 val1 postarg2 val2}
set match [::http::data $page]
set match
} {OK}
+
+::tcltest::test postvariables-6.1 {::rivet::raw_post} {
+ set payload "\x00\x00\x00\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39"
+ set page [::http::geturl "${urlbase}post.rvt" \
+ -query $payload \
+ -type application/octet-stream]
+ regexp -line {^\[::rivet::raw_post\] = 00000030313233343536373839$} [ ::http::data $page ] match
+ set match
+} {[::rivet::raw_post] = 00000030313233343536373839}
diff --git a/tests/rivet.test b/tests/rivet.test
index 139a625..dbda8b8 100755
--- a/tests/rivet.test
+++ b/tests/rivet.test
@@ -30,19 +30,23 @@ set urlbase "http://localhost:8081/"
# Use this to start and stop the server:
-set TestList {rivetlib.test shorthand.test headers.test \
- cookies.test get.test post.test tclfile.test \
- env.test hello.test include.test binary.test \
- parse.test upload.test makeurl.test commands.test}
+if {[info exists ::env(TestList)]} {
+ set TestList $::env(TestList)
+} else {
+ set TestList {rivetlib.test shorthand.test headers.test \
+ cookies.test get.test post.test tclfile.test \
+ env.test hello.test include.test binary.test \
+ parse.test upload.test makeurl.test commands.test}
+}
# Test stanzas are created by giving the test a name and a
# description. The code is then executed, and the results compared
# with the desired result, which is placed after the block of code.
# See man tcltest for more information.
-set testgroup1 1
-set testgroup2 1
-set testgroup3 1
+set testgroup1 [expr [info exists ::env(testgroup1)] ? $::env(testgroup1) : 1]
+set testgroup2 [expr [info exists ::env(testgroup2)] ? $::env(testgroup2) : 1]
+set testgroup3 [expr [info exists ::env(testgroup3)] ? $::env(testgroup3) : 1]
# Run all tests against one server process.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tcl.apache.org
For additional commands, e-mail: commits-help@tcl.apache.org