Page MenuHomeDevCentral

D821.diff
No OneTemporary

D821.diff

diff --git a/Tech.tcl b/Tech.tcl
--- a/Tech.tcl
+++ b/Tech.tcl
@@ -80,12 +80,26 @@
return 0
}
+proc should_log_tcl_command {arg} {
+ set noLogMatches {
+ "*sql*connect*"
+ "genpass *"
+ }
+ foreach noLogMatch $noLogMatches {
+ if {[string match $noLogMatch $arg]} {
+ return 0
+ }
+ }
+
+ return 1
+}
+
#.tcl with tech.log logging
proc dcc:tcl {handle idx arg} {
#Logs every .tcl commands, except sql connect
#You should add here any line with password.
catch {
- if ![string match "*sql*connect*" $arg] {
+ if [should_log_tcl_command $arg] {
log tech $handle $arg
}
}
diff --git a/tests/Tech.test b/tests/Tech.test
new file mode 100644
--- /dev/null
+++ b/tests/Tech.test
@@ -0,0 +1,36 @@
+package require tcltest
+namespace import ::tcltest::*
+
+###
+### Init
+###
+
+# Tested code
+source init.tcl
+source $dir/Tech.tcl
+
+###
+### Tests
+###
+
+test should_log_tcl_command_for_legit_command {} -body {
+ should_log_tcl_command "quux"
+} -result 1
+
+test should_log_tcl_command_for_empty_command {} -body {
+ should_log_tcl_command ""
+} -result 1
+
+test should_log_tcl_command_for_sql_connect {} -body {
+ should_log_tcl_command "sql connect localhost root somepassword"
+} -result 0
+
+test should_log_tcl_command_for_genpass {} -body {
+ should_log_tcl_command "genpass somepassword somedomain.tld"
+} -result 0
+
+###
+### Cleanup
+###
+
+cleanupTests

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 21, 14:01 (12 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2590388
Default Alt Text
D821.diff (1 KB)

Event Timeline