From 0935f0fe8a8ef2d544b415af61cae1a3852c2041 Mon Sep 17 00:00:00 2001 From: adfoster-r7 Date: Wed, 11 Dec 2024 18:23:15 +0000 Subject: [PATCH] Improve acceptance test namespace --- spec/acceptance/command_shell_spec.rb | 8 ++++---- spec/acceptance/meterpreter_spec.rb | 10 +++++----- spec/acceptance_spec_helper.rb | 3 ++- spec/support/acceptance/command_shell.rb | 2 ++ spec/support/acceptance/command_shell/cmd.rb | 4 ++-- spec/support/acceptance/command_shell/powershell.rb | 4 ++-- .../acceptance/command_shell/{linux.rb => unix.rb} | 4 ++-- spec/support/acceptance/meterpreter.rb | 2 ++ .../acceptance/{session => meterpreter}/java.rb | 4 ++-- .../acceptance/{session => meterpreter}/mettle.rb | 4 ++-- .../support/acceptance/{session => meterpreter}/php.rb | 4 ++-- .../acceptance/{session => meterpreter}/python.rb | 4 ++-- .../{session => meterpreter}/windows_meterpreter.rb | 4 ++-- 13 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 spec/support/acceptance/command_shell.rb rename spec/support/acceptance/command_shell/{linux.rb => unix.rb} (98%) create mode 100644 spec/support/acceptance/meterpreter.rb rename spec/support/acceptance/{session => meterpreter}/java.rb (99%) rename spec/support/acceptance/{session => meterpreter}/mettle.rb (99%) rename spec/support/acceptance/{session => meterpreter}/php.rb (99%) rename spec/support/acceptance/{session => meterpreter}/python.rb (99%) rename spec/support/acceptance/{session => meterpreter}/windows_meterpreter.rb (99%) diff --git a/spec/acceptance/command_shell_spec.rb b/spec/acceptance/command_shell_spec.rb index 63c0a985f9d0e..e4533ba187777 100644 --- a/spec/acceptance/command_shell_spec.rb +++ b/spec/acceptance/command_shell_spec.rb @@ -4,12 +4,12 @@ RSpec.describe 'CommandShell' do include_context 'wait_for_expect' - # Tests to ensure that CMD/Powershell/Linux is consistent across all implementations/operation systems + # Tests to ensure that CMD/Powershell/unix is consistent across all implementations/operation systems COMMAND_SHELL_PAYLOADS = Acceptance::Session.with_session_name_merged( { - powershell: Acceptance::Session::POWERSHELL, - cmd: Acceptance::Session::CMD, - linux: Acceptance::Session::LINUX + powershell: Acceptance::CommandShell::PowerShell::TESTS, + cmd: Acceptance::CommandShell::PowerShell::TESTS, + unix: Acceptance::CommandShell::Unix::TESTS, } ) diff --git a/spec/acceptance/meterpreter_spec.rb b/spec/acceptance/meterpreter_spec.rb index 3bca9b2d91288..256950087e4ca 100644 --- a/spec/acceptance/meterpreter_spec.rb +++ b/spec/acceptance/meterpreter_spec.rb @@ -7,11 +7,11 @@ # Tests to ensure that Meterpreter is consistent across all implementations/operation systems METERPRETER_PAYLOADS = Acceptance::Session.with_session_name_merged( { - python: Acceptance::Session::PYTHON_METERPRETER, - php: Acceptance::Session::PHP_METERPRETER, - java: Acceptance::Session::JAVA_METERPRETER, - mettle: Acceptance::Session::METTLE_METERPRETER, - windows_meterpreter: Acceptance::Session::WINDOWS_METERPRETER + python: Acceptance::Meterpreter::Python::TESTS, + php: Acceptance::Meterpreter::Php::TESTS, + java: Acceptance::Meterpreter::Java::TESTS, + mettle: Acceptance::Meterpreter::Mettle::TESTS, + windows_meterpreter: Acceptance::Meterpreter::WindowsMeterpreter::TESTS } ) diff --git a/spec/acceptance_spec_helper.rb b/spec/acceptance_spec_helper.rb index b4df9dff80812..7d5ca1e382247 100644 --- a/spec/acceptance_spec_helper.rb +++ b/spec/acceptance_spec_helper.rb @@ -5,7 +5,8 @@ acceptance_support_glob = File.expand_path(File.join(File.dirname(__FILE__), 'support', 'acceptance', '**', '*.rb')) shared_contexts_glob = File.expand_path(File.join(File.dirname(__FILE__), 'support', 'shared', 'contexts', '**', '*.rb')) -Dir[acceptance_support_glob, shared_contexts_glob].each do |f| +Dir[acceptance_support_glob, shared_contexts_glob].sort.each do |f| + puts f require f end diff --git a/spec/support/acceptance/command_shell.rb b/spec/support/acceptance/command_shell.rb new file mode 100644 index 0000000000000..0eaaa419b4172 --- /dev/null +++ b/spec/support/acceptance/command_shell.rb @@ -0,0 +1,2 @@ +module Acceptance::CommandShell +end diff --git a/spec/support/acceptance/command_shell/cmd.rb b/spec/support/acceptance/command_shell/cmd.rb index 8f9fca7f68cff..4fd0c537cddf0 100644 --- a/spec/support/acceptance/command_shell/cmd.rb +++ b/spec/support/acceptance/command_shell/cmd.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - CMD = { +module Acceptance::CommandShell::Cmd + TESTS = { payloads: [ { name: 'windows/x64/shell_reverse_tcp', diff --git a/spec/support/acceptance/command_shell/powershell.rb b/spec/support/acceptance/command_shell/powershell.rb index f941057eccd43..2c79df934451d 100644 --- a/spec/support/acceptance/command_shell/powershell.rb +++ b/spec/support/acceptance/command_shell/powershell.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - POWERSHELL = { +module Acceptance::CommandShell::PowerShell + TESTS = { payloads: [ { name: 'cmd/windows/powershell_reverse_tcp', diff --git a/spec/support/acceptance/command_shell/linux.rb b/spec/support/acceptance/command_shell/unix.rb similarity index 98% rename from spec/support/acceptance/command_shell/linux.rb rename to spec/support/acceptance/command_shell/unix.rb index 3eb40744ec55a..14df6375c5814 100644 --- a/spec/support/acceptance/command_shell/linux.rb +++ b/spec/support/acceptance/command_shell/unix.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - LINUX = { +module Acceptance::CommandShell::Unix + TESTS = { payloads: [ { name: "cmd/unix/reverse_bash", diff --git a/spec/support/acceptance/meterpreter.rb b/spec/support/acceptance/meterpreter.rb new file mode 100644 index 0000000000000..40e324b99545f --- /dev/null +++ b/spec/support/acceptance/meterpreter.rb @@ -0,0 +1,2 @@ +module Acceptance::Meterpreter +end diff --git a/spec/support/acceptance/session/java.rb b/spec/support/acceptance/meterpreter/java.rb similarity index 99% rename from spec/support/acceptance/session/java.rb rename to spec/support/acceptance/meterpreter/java.rb index 029ce6e672f06..4571c99d41c38 100644 --- a/spec/support/acceptance/session/java.rb +++ b/spec/support/acceptance/meterpreter/java.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - JAVA_METERPRETER = { +module Acceptance::Meterpreter::Java + TESTS = { payloads: [ { name: "java/meterpreter/reverse_tcp", diff --git a/spec/support/acceptance/session/mettle.rb b/spec/support/acceptance/meterpreter/mettle.rb similarity index 99% rename from spec/support/acceptance/session/mettle.rb rename to spec/support/acceptance/meterpreter/mettle.rb index 182a0d3706100..5167512277211 100644 --- a/spec/support/acceptance/session/mettle.rb +++ b/spec/support/acceptance/meterpreter/mettle.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - METTLE_METERPRETER = { +module Acceptance::Meterpreter::Mettle + TESTS = { payloads: [ { name: "linux/x64/meterpreter/reverse_tcp", diff --git a/spec/support/acceptance/session/php.rb b/spec/support/acceptance/meterpreter/php.rb similarity index 99% rename from spec/support/acceptance/session/php.rb rename to spec/support/acceptance/meterpreter/php.rb index 0cc3fb666858a..fa10a7b332753 100644 --- a/spec/support/acceptance/session/php.rb +++ b/spec/support/acceptance/meterpreter/php.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - PHP_METERPRETER = { +module Acceptance::Meterpreter::Php + TESTS = { payloads: [ { name: "php/meterpreter_reverse_tcp", diff --git a/spec/support/acceptance/session/python.rb b/spec/support/acceptance/meterpreter/python.rb similarity index 99% rename from spec/support/acceptance/session/python.rb rename to spec/support/acceptance/meterpreter/python.rb index eb2870c0eb7c1..c92f0a097d84b 100644 --- a/spec/support/acceptance/session/python.rb +++ b/spec/support/acceptance/meterpreter/python.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - PYTHON_METERPRETER = { +module Acceptance::Meterpreter::Python + TESTS = { payloads: [ { name: "python/meterpreter_reverse_tcp", diff --git a/spec/support/acceptance/session/windows_meterpreter.rb b/spec/support/acceptance/meterpreter/windows_meterpreter.rb similarity index 99% rename from spec/support/acceptance/session/windows_meterpreter.rb rename to spec/support/acceptance/meterpreter/windows_meterpreter.rb index 7784ab66d2fa4..44e1929cd9719 100644 --- a/spec/support/acceptance/session/windows_meterpreter.rb +++ b/spec/support/acceptance/meterpreter/windows_meterpreter.rb @@ -1,5 +1,5 @@ -module Acceptance::Session - WINDOWS_METERPRETER = { +module Acceptance::Meterpreter::WindowsMeterpreter + TESTS = { payloads: [ { name: "windows/meterpreter/reverse_tcp",