metasploit-framework/spec/lib/rex/powershell/script_spec.rb

49 lines
1.2 KiB
Ruby
Raw Normal View History

2014-05-05 18:01:36 +00:00
# -*- coding:binary -*-
require 'spec_helper'
require 'rex/powershell'
2014-05-05 18:01:36 +00:00
describe Rex::Powershell::Output do
2014-05-05 18:01:36 +00:00
let(:example_script) do
Rex::Text.rand_text_alpha(400)
end
let(:subject) do
Rex::Powershell::Script.new(example_script)
2014-05-05 18:01:36 +00:00
end
describe "::initialize" do
it 'should create a new script object' do
subject.should be
subject.should be_kind_of Rex::Powershell::Script
2014-05-05 18:01:36 +00:00
subject.rig.should be
subject.rig.should be_kind_of Rex::RandomIdentifierGenerator
subject.code.should be
subject.code.should be_kind_of String
2014-08-25 22:50:38 +00:00
subject.code.empty?.should be_falsey
subject.functions.empty?.should be_truthy
2014-05-05 18:01:36 +00:00
end
end
describe "::to_byte_array" do
it 'should generate a powershell byte array' do
byte_array = Rex::Powershell::Script.to_byte_array("parp")
2014-05-05 18:01:36 +00:00
byte_array.should be
byte_array.should be_kind_of String
2014-08-25 23:13:38 +00:00
byte_array.include?('[Byte[]] $').should be_truthy
2014-05-05 18:01:36 +00:00
end
end
describe "::code_modifiers" do
it 'should return an array of modifier methods' do
mods = Rex::Powershell::Script.code_modifiers
2014-05-05 18:01:36 +00:00
mods.should be
mods.should be_kind_of Array
2014-08-25 22:50:38 +00:00
mods.empty?.should be_falsey
2014-05-05 18:01:36 +00:00
end
end
end