From e1430f5e43d3a23da1c5f17309e589a6be15768e Mon Sep 17 00:00:00 2001 From: Jack Walker Date: Wed, 27 May 2020 19:01:54 +1000 Subject: [PATCH] Tightened up some of the test cases. --- .../core/main/autorun_engine/autorun_engine_spec.rb | 8 ++------ .../core/main/handlers/browser_details_handler_spec.rb | 10 +++------- spec/beef/extensions/websocket_hooked_browser_spec.rb | 8 ++------ spec/beef/modules/debug/test_beef_debugs_spec.rb | 2 +- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb index 7ad30dd14..7fcdcbec4 100644 --- a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb +++ b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb @@ -123,11 +123,7 @@ RSpec.describe 'AutoRunEngine Test', :run_on_browserstack => true do it 'AutoRunEngine is working' do begin - if @hooks['hooked-browsers']['online'].empty? - expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script("return window.beef.session.get_hook_session_id()"))).to eq true - else - expect(@hooks['hooked-browsers']['online']).not_to be_empty - end + expect(@hooks['hooked-browsers']['online']).not_to be_empty rescue => exception print_info "Exception: #{exception}" print_info "Exception Class: #{exception.class}" @@ -136,7 +132,7 @@ RSpec.describe 'AutoRunEngine Test', :run_on_browserstack => true do exception.class == NoMethodError exit 1 else - exit 0 + expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script("return window.beef.session.get_hook_session_id()"))).to eq true end end end diff --git a/spec/beef/core/main/handlers/browser_details_handler_spec.rb b/spec/beef/core/main/handlers/browser_details_handler_spec.rb index f48f70837..8ecf73303 100644 --- a/spec/beef/core/main/handlers/browser_details_handler_spec.rb +++ b/spec/beef/core/main/handlers/browser_details_handler_spec.rb @@ -100,7 +100,7 @@ RSpec.describe 'Browser Details Handler', :run_on_browserstack => true do @hook_request = RestClient.get "#{RESTAPI_HOOKS}?token=#{@token}" @hooks = JSON.parse(@hook_request) @session = @hooks['hooked-browsers']['online'][0]['session'] - + rescue => exception print_info "Exception: #{exception}" print_info "Exception Class: #{exception.class}" @@ -120,11 +120,7 @@ RSpec.describe 'Browser Details Handler', :run_on_browserstack => true do it 'can successfully hook a browser' do begin - if @hooks['hooked-browsers']['online'].empty? - expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script("return window.beef.session.get_hook_session_id()"))).to eq true - else - expect(@hooks['hooked-browsers']['online']).not_to be_empty - end + expect(@hooks['hooked-browsers']['online']).not_to be_empty rescue => exception print_info "Exception: #{exception}" print_info "Exception Class: #{exception.class}" @@ -133,7 +129,7 @@ RSpec.describe 'Browser Details Handler', :run_on_browserstack => true do exception.class == NoMethodError exit 1 else - exit 0 + expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script("return window.beef.session.get_hook_session_id()"))).to eq true end end end diff --git a/spec/beef/extensions/websocket_hooked_browser_spec.rb b/spec/beef/extensions/websocket_hooked_browser_spec.rb index 9197e6ec0..2cdbdfb54 100644 --- a/spec/beef/extensions/websocket_hooked_browser_spec.rb +++ b/spec/beef/extensions/websocket_hooked_browser_spec.rb @@ -120,11 +120,7 @@ RSpec.describe 'Browser hooking with Websockets', :run_on_browserstack => true d it 'can successfully hook a browser' do begin - if @hooks['hooked-browsers']['online'].empty? - expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script("return window.beef.session.get_hook_session_id()"))).to eq true - else - expect(@hooks['hooked-browsers']['online']).not_to be_empty - end + expect(@hooks['hooked-browsers']['online']).not_to be_empty rescue => exception print_info "Exception: #{exception}" print_info "Exception Class: #{exception.class}" @@ -133,7 +129,7 @@ RSpec.describe 'Browser hooking with Websockets', :run_on_browserstack => true d exception.class == NoMethodError exit 1 else - exit 0 + expect(BeEF::Filters.is_valid_hook_session_id?(@driver.execute_script("return window.beef.session.get_hook_session_id()"))).to eq true end end end diff --git a/spec/beef/modules/debug/test_beef_debugs_spec.rb b/spec/beef/modules/debug/test_beef_debugs_spec.rb index 569aac970..df799a59b 100644 --- a/spec/beef/modules/debug/test_beef_debugs_spec.rb +++ b/spec/beef/modules/debug/test_beef_debugs_spec.rb @@ -278,7 +278,7 @@ RSpec.describe 'BeEF Debug Command Modules:', :run_on_browserstack => true do exception.class == NoMethodError exit 1 else - exit 0 + true end end end