From 7e580dc91a39ad186da644fed8adf66a50970efd Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 11 Aug 2023 22:12:28 +0100 Subject: [PATCH] check identified state in Event::Client add passwordless test for event client patch bump --- Gemfile.lock | 2 +- lib/obsws/event.rb | 5 +++++ lib/obsws/version.rb | 2 +- test/obsws/test_error.rb | 10 +++++++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 095ce9e..f7987ee 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - obsws (0.5.6) + obsws (0.5.8) waitutil (~> 0.2.1) websocket-driver (~> 0.7.5) diff --git a/lib/obsws/event.rb b/lib/obsws/event.rb index 3f641e1..ed99a0e 100644 --- a/lib/obsws/event.rb +++ b/lib/obsws/event.rb @@ -71,6 +71,11 @@ module OBSWS def initialize(**kwargs) kwargs[:subs] ||= SUBS::LOW_VOLUME @base_client = Base.new(**kwargs) + unless @base_client.identified.state == :identified + err_msg = @base_client.identified.error_message + logger.error(err_msg) + raise OBSWSConnectionError.new(err_msg) + end logger.info("#{self} successfully identified with server") rescue Errno::ECONNREFUSED, WaitUtil::TimeoutError => e msg = "#{e.class.name}: #{e.message}" diff --git a/lib/obsws/version.rb b/lib/obsws/version.rb index a418a73..7b3d621 100644 --- a/lib/obsws/version.rb +++ b/lib/obsws/version.rb @@ -11,7 +11,7 @@ module OBSWS end def patch - 7 + 8 end def to_a diff --git a/test/obsws/test_error.rb b/test/obsws/test_error.rb index 1749132..a07a7ba 100644 --- a/test/obsws/test_error.rb +++ b/test/obsws/test_error.rb @@ -9,13 +9,21 @@ class OBSWSConnectionErrorTest < Minitest::Test assert_equal("Timed out waiting for successful identification (0.1 seconds elapsed)", e.message) end - def test_it_raises_an_obsws_connection_error_on_auth_enabled_but_no_password_provided + def test_it_raises_an_obsws_connection_error_on_auth_enabled_but_no_password_provided_for_request_client e = assert_raises(OBSWS::OBSWSConnectionError) do OBSWS::Requests::Client .new(host: "localhost", port: 4455, password: "") end assert_equal("auth enabled but no password provided", e.message) end + + def test_it_raises_an_obsws_connection_error_on_auth_enabled_but_no_password_provided_for_event_client + e = assert_raises(OBSWS::OBSWSConnectionError) do + OBSWS::Events::Client + .new(host: "localhost", port: 4455, password: "") + end + assert_equal("auth enabled but no password provided", e.message) + end end class OBSWSRequestErrorTest < Minitest::Test