summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/custodian-parse-execute4
-rw-r--r--lib/custodian/protocoltest.rb3
-rw-r--r--lib/custodian/protocoltest/ftp.rb14
-rw-r--r--lib/custodian/protocoltest/jabber.rb15
-rw-r--r--lib/custodian/protocoltest/rsync.rb15
-rw-r--r--lib/custodian/protocoltest/smtp.rb15
-rw-r--r--lib/custodian/protocoltest/ssh.rb16
-rw-r--r--lib/custodian/protocoltest/tcp.rb16
8 files changed, 97 insertions, 1 deletions
diff --git a/bin/custodian-parse-execute b/bin/custodian-parse-execute
index 5ef48a7..22c29b8 100755
--- a/bin/custodian-parse-execute
+++ b/bin/custodian-parse-execute
@@ -38,7 +38,9 @@ end
begin
c = ProtocolTest.create( txt )
- puts "created object: #{c.to_s}"
+ puts "created object of class type #{c.class}"
+ puts ".to_s : #{c.to_s}"
+ puts ".to_json : #{c.to_json}"
if ( c.run_test )
puts "Test succeeded"
diff --git a/lib/custodian/protocoltest.rb b/lib/custodian/protocoltest.rb
index 252946f..9a843c2 100644
--- a/lib/custodian/protocoltest.rb
+++ b/lib/custodian/protocoltest.rb
@@ -1,3 +1,5 @@
+require 'json'
+
#
#
@@ -10,6 +12,7 @@
# derived class for a given line from our configuration
# file.
#
+# TODO: We also wish to create from json.
#
class ProtocolTest
diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb
index 8894de0..1d60e43 100644
--- a/lib/custodian/protocoltest/ftp.rb
+++ b/lib/custodian/protocoltest/ftp.rb
@@ -59,6 +59,20 @@ class FTPTest < TCPTest
#
+ # Convert this class to JSON such that it may be serialized.
+ #
+ def to_json
+ hash = {
+ :test_type => 'ftp',
+ :test_target => @host,
+ :test_port => @port,
+ }
+ hash.to_json
+ end
+
+
+
+
# Run the TCP-protocol test.
#
def run_test
diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb
index a9920f0..1aef8b5 100644
--- a/lib/custodian/protocoltest/jabber.rb
+++ b/lib/custodian/protocoltest/jabber.rb
@@ -58,6 +58,21 @@ class JABBERTest < TCPTest
#
+ # Convert this class to JSON such that it may be serialized.
+ #
+ def to_json
+ hash = {
+ :test_type => 'jabber',
+ :test_target => @host,
+ :test_port => @port,
+ }
+ hash.to_json
+ end
+
+
+
+
+ #
# Run the TCP-protocol test.
#
def run_test
diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb
index 3b63465..c35758e 100644
--- a/lib/custodian/protocoltest/rsync.rb
+++ b/lib/custodian/protocoltest/rsync.rb
@@ -59,6 +59,21 @@ class RSYNCTest < TCPTest
#
+ # Convert this class to JSON such that it may be serialized.
+ #
+ def to_json
+ hash = {
+ :test_type => 'rsync',
+ :test_target => @host,
+ :test_port => @port,
+ }
+ hash.to_json
+ end
+
+
+
+
+ #
# Run the protocol test.
#
def run_test
diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb
index 3a38f5a..dce5ddf 100644
--- a/lib/custodian/protocoltest/smtp.rb
+++ b/lib/custodian/protocoltest/smtp.rb
@@ -59,6 +59,21 @@ class SMTPTest < TCPTest
#
+ # Convert this class to JSON such that it may be serialized.
+ #
+ def to_json
+ hash = {
+ :test_type => 'smtp',
+ :test_target => @host,
+ :test_port => @port,
+ }
+ hash.to_json
+ end
+
+
+
+
+ #
# Run the TCP-protocol test.
#
def run_test
diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb
index ec7752f..18f13bc 100644
--- a/lib/custodian/protocoltest/ssh.rb
+++ b/lib/custodian/protocoltest/ssh.rb
@@ -60,6 +60,22 @@ class SSHTest < TCPTest
#
+ # Convert this class to JSON such that it may be
+ # serialized.
+ #
+ def to_json
+ hash = {
+ :test_type => 'ssh',
+ :test_target => @host,
+ :test_port => @port
+ }
+ hash.to_json
+ end
+
+
+
+
+ #
# Run the TCP-protocol test.
#
def run_test
diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb
index 9e141fe..5f29b7f 100644
--- a/lib/custodian/protocoltest/tcp.rb
+++ b/lib/custodian/protocoltest/tcp.rb
@@ -87,6 +87,22 @@ class TCPTest < ProtocolTest
#
+ # Convert this class to JSON such that it may be serialized.
+ #
+ def to_json
+ hash = {
+ :test_type => 'tcp',
+ :test_target => @host,
+ :test_port => @port,
+ :banner => @banner
+ }
+ hash.to_json
+ end
+
+
+
+
+ #
# Run the TCP-protocol test.
#
def run_test