You are viewing a plain text version of this content. The canonical link for it is here.
Posted to websh-cvs@tcl.apache.org by ro...@apache.org on 2005/09/09 10:23:16 UTC
cvs commit: tcl-websh/src/tests cfg.test
ronnie 2005/09/09 01:23:16
Modified: src/tests cfg.test
Log:
- all created files with configurable permissions
- added some tests to verify that it actually works
Revision Changes Path
1.6 +111 -2 tcl-websh/src/tests/cfg.test
Index: cfg.test
===================================================================
RCS file: /home/cvs/tcl-websh/src/tests/cfg.test,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- cfg.test 17 Apr 2002 16:17:39 -0000 1.5
+++ cfg.test 9 Sep 2005 08:23:16 -0000 1.6
@@ -26,7 +26,7 @@
test cfg-1.1 {wrong subcommand} {
catch {web::config foo bar} msg
set msg
-} {bad subcommand "foo": must be uploadfilesize, encryptchain, decryptchain, cmdparam, timeparam, putxmarkup, logsubst, version, copyright, cmdurltimestamp, reset, script, server_root, document_root, or interpclass}
+} {bad subcommand "foo": must be uploadfilesize, encryptchain, decryptchain, cmdparam, timeparam, putxmarkup, logsubst, version, copyright, cmdurltimestamp, reset, script, server_root, document_root, interpclass, or filepermissions}
test cfg-1.2 {invalid value} {
@@ -74,6 +74,115 @@
lappend res [web::config putxmarkup]
} {{bad type "foo": must be brace or tag} brace tag tag brace}
+test cfg-4.1 {default filepermissions} {
+ web::config reset
+ web::config filepermissions
+} {0644}
+
+test cfg-4.2 {change filepermissions} {
+ set res [web::config filepermissions 0600]
+ lappend res [web::config filepermissions 0604]
+ lappend res [web::config filepermissions]
+ lappend res [web::config filepermissions 0644]
+ lappend res [web::config filepermissions 0600]
+ lappend res [web::config filepermissions]
+ web::config reset
+ lappend res [web::config filepermissions]
+} {0644 0600 0604 0604 0644 0600 0644}
+
+test cfg-4.3 {filecounter file permissions} {
+ catch {
+ set umask [exec umask]
+ if {$umask != 0} {
+ puts ""
+ puts "WARNING: current umask prohibits some tests from running"
+ puts "properly. Please run tests with a umask of 0, so the"
+ puts "correct file permissions can be tested."
+ puts ""
+ }
+ }
+ web::config reset
+ web::filecounter foo1 -filename foo.txt
+ foo1 nextval
+ set res [file attributes foo.txt -permissions]
+ file delete foo.txt
+ web::filecounter foo2 -filename foo.txt -perms 0600
+ foo2 nextval
+ lappend res [file attributes foo.txt -permissions]
+ file delete foo.txt
+ web::config filepermissions 0666
+ web::filecounter foo3 -filename foo.txt
+ foo3 nextval
+ lappend res [file attributes foo.txt -permissions]
+ file delete foo.txt
+ web::filecounter foo4 -filename foo.txt -perms 0604
+ foo4 nextval
+ lappend res [file attributes foo.txt -permissions]
+ file delete foo.txt
+ web::filecounter foo5 -filename foo.txt -perms 0666
+ foo5 nextval
+ lappend res [file attributes foo.txt -permissions]
+ file delete foo.txt
+ set res
+} {00644 00600 00666 00604 00666}
+
+test cfg-4.4 {formdata file upload file permissions} {
+
+ web::config uploadfilesize 500
+ global data
+ set data "--xxxx\u0d
+Content-Disposition: form-data; name=\"file\"; filename=\"test.dat\"\u0d
+Content-Type: text/html\u0d
+\u0d
+A small text file\u0d
+--xxxx--\u0d
+"
+
+ set res {}
+ foreach perms {0600 0602 0660 0640 0666 0400} {
+ web::config filepermissions $perms
+ web::formvar -unset
+ web::dispatch -querystring "" -cmd "" -postdata \#data end "multipart/form-data; boundary=xxxx"
+ set currfile [lindex [web::formvar file] 0]
+ lappend res [file attributes $currfile -permissions]
+ lappend res [file size $currfile]
+ file delete -force $currfile
+ }
+ web::config reset
+ set res
+} {00600 17 00602 17 00660 17 00640 17 00666 17 00400 17}
+
+test cfg-4.5 {session context file permissions} {
+
+ set res {}
+ foreach {ctx perm} {a 0644 b 0600 c 0640 d 0602 e 0666} {
+ web::config filepermissions $perm
+ web::filecontext $ctx -path "%d"
+ ${ctx}::new 111
+ ${ctx}::cset a 1
+ ${ctx}::commit
+ lappend res [file attributes 111 -permissions]
+ file delete 111
+ }
+ web::config reset
+ set res
+
+} {00644 00600 00640 00602 00666}
+
+
+test cfg-4.6 {log file permissions} {
+ set res {}
+ foreach perm {0644 0600 0602 0660 0640 0666 0400} {
+ web::config filepermissions $perm
+ web::logdest add *.-debug file foo.log
+ lappend res [file attributes foo.log -permissions]
+ web::logdest delete
+ file delete foo.log
+ }
+ web::config reset
+ set res
+} {00644 00600 00602 00660 00640 00666 00400}
+
# cleanup
::tcltest::cleanupTests
---------------------------------------------------------------------
To unsubscribe, e-mail: websh-cvs-unsubscribe@tcl.apache.org
For additional commands, e-mail: websh-cvs-help@tcl.apache.org