PROTON-1696: [go,ruby] Skip extended SASL tests if no saslpasswd2 found

Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/dc90e617
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/dc90e617
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/dc90e617

Branch: refs/heads/go1
Commit: dc90e617bbe05274fcf63c38819550eb4740143c
Parents: b6436ff
Author: Alan Conway <acon...@redhat.com>
Authored: Tue Mar 27 10:25:39 2018 -0400
Committer: Alan Conway <acon...@redhat.com>
Committed: Tue Mar 27 10:26:44 2018 -0400

----------------------------------------------------------------------
 .../src/qpid.apache.org/electron/auth_test.go   |  8 ++++----
 .../bindings/ruby/tests/test_container_sasl.rb  | 20 ++++++++++++++------
 2 files changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/dc90e617/proton-c/bindings/go/src/qpid.apache.org/electron/auth_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/electron/auth_test.go 
b/proton-c/bindings/go/src/qpid.apache.org/electron/auth_test.go
index 77b033c..162b366 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/electron/auth_test.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/electron/auth_test.go
@@ -123,10 +123,10 @@ func (s extendedSASLState) teardown() {
 }
 
 func (s extendedSASLState) startTest(t *testing.T) {
-       if SASLExtended() {
-               fatalIf(t, extendedSASL.err)
-       } else {
-               t.Skip()
+       if !SASLExtended() {
+               t.Skipf("Extended SASL not enabled")
+       } else if extendedSASL.err != nil {
+               t.Skipf("Extended SASL setup error: %v", extendedSASL.err)
        }
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/dc90e617/proton-c/bindings/ruby/tests/test_container_sasl.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/tests/test_container_sasl.rb 
b/proton-c/bindings/ruby/tests/test_container_sasl.rb
index 8888c1b..85a32c2 100644
--- a/proton-c/bindings/ruby/tests/test_container_sasl.rb
+++ b/proton-c/bindings/ruby/tests/test_container_sasl.rb
@@ -60,7 +60,7 @@ class ContainerSASLTest < MiniTest::Test
   # Generate SASL server configuration files and database, initialize proton 
SASL
   class SASLConfig
     include Qpid::Proton
-    attr_reader :conf_dir, :conf_file, :conf_name, :database
+    attr_reader :conf_dir, :conf_file, :conf_name, :database, :error
 
     def initialize()
       if SASL.extended? # Configure cyrus SASL
@@ -76,12 +76,14 @@ class ContainerSASLTest < MiniTest::Test
           f.write("
 sasldb_path: #{database}
 mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
-                  ")
+            ")
         end
         # Tell proton library to use the new configuration
         SASL.config_path =  conf_dir
         SASL.config_name = conf_name
       end
+    rescue => e
+      @error = e
     end
 
     private
@@ -91,9 +93,15 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN 
ANONYMOUS
     def make_user(user, password, realm=nil)
       realm_opt = (realm ? "-u #{realm}" : "")
       cmd = "echo '#{password}' | #{SASLPASSWD} -c -p -f #{database} 
#{realm_opt} #{user}"
-      system(cmd) or raise RuntimeError.new("saslpasswd2 failed: 
#{makepw_cmd}")
+      system(cmd) or raise RuntimeError.new("saslpasswd2 failed: #{cmd}")
     end
-    DEFAULT = SASLConfig.new
+
+    INSTANCE = SASLConfig.new
+  end
+
+  def begin_extended_test
+    skip("Extended SASL not enabled") unless SASL.extended?
+    skip("Extended SASL setup error: #{SASLConfig::INSTANCE.error}") if 
SASLConfig::INSTANCE.error
   end
 
   def test_sasl_anonymous()
@@ -103,7 +111,7 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN 
ANONYMOUS
   end
 
   def test_sasl_plain_url()
-    skip unless SASL.extended?
+    begin_extended_test
     # Use default realm with URL, should authenticate with "default_password"
     opts = {:sasl_allowed_mechs => "PLAIN", :sasl_allow_insecure_mechs => true}
     s = SASLHandler.new("amqp://user:default_password@",  opts)
@@ -113,7 +121,7 @@ mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN 
ANONYMOUS
   end
 
   def test_sasl_plain_options()
-    skip unless SASL.extended?
+    begin_extended_test
     # Use default realm with connection options, should authenticate with 
"default_password"
     opts = {:sasl_allowed_mechs => "PLAIN",:sasl_allow_insecure_mechs => true,
             :user => 'user', :password => 'default_password' }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to