Make Exploitation::Powershell testable

Example test
bug/bundler_fix
Meatballs 2014-04-26 13:27:25 +01:00
parent 98d2b2293b
commit 8031e50d35
No known key found for this signature in database
GPG Key ID: 5380EAF01F2F8B38
2 changed files with 21 additions and 5 deletions

View File

@ -18,9 +18,9 @@ module Powershell
#
# @param script_path [String] Path to the Script File
#
# @return [PowershellScript] PowerShellScript object
def read_script(script_path)
PowershellScript.new(script_path)
# @return [Script] Powershell Script object
def self.read_script(script_path)
Rex::Exploitation::Powershell::Script.new(script_path)
end
#
@ -32,7 +32,7 @@ module Powershell
# @param subs [Array] Substitutions to insert
#
# @return [String] Modified script file
def make_subs(script, subs)
def self.make_subs(script, subs)
if ::File.file?(script)
script = ::File.read(script)
end
@ -50,7 +50,7 @@ module Powershell
# @param subs [String] A ; seperated list of substitutions
#
# @return [Array] An array of substitutions
def process_subs(subs)
def self.process_subs(subs)
return [] if subs.nil? or subs.empty?
new_subs = []
subs.split(';').each do |set|

View File

@ -0,0 +1,16 @@
# -*- coding:binary -*-
require 'spec_helper'
require 'rex/exploitation/powershell'
describe Rex::Exploitation::Powershell do
describe "::read_script" do
it 'should create a script from a string input' do
script = described_class.read_script("parp")
script.should be_a_kind_of Rex::Exploitation::Powershell::Script
end
end
end