Files
metasploit-gs/spec/lib/rex/powershell/script_spec.rb
T

49 lines
1.3 KiB
Ruby
Raw Normal View History

2014-05-05 19:01:36 +01:00
# -*- coding:binary -*-
require 'spec_helper'
require 'rex/powershell'
2014-05-05 19:01:36 +01:00
2015-10-16 15:57:04 -05:00
RSpec.describe Rex::Powershell::Output do
2014-05-05 19:01:36 +01:00
let(:example_script) do
Rex::Text.rand_text_alpha(400)
end
let(:subject) do
Rex::Powershell::Script.new(example_script)
2014-05-05 19:01:36 +01:00
end
describe "::initialize" do
it 'should create a new script object' do
2015-10-20 14:37:18 -05:00
expect(subject).to be
expect(subject).to be_kind_of Rex::Powershell::Script
expect(subject.rig).to be
expect(subject.rig).to be_kind_of Rex::RandomIdentifierGenerator
expect(subject.code).to be
expect(subject.code).to be_kind_of String
expect(subject.code.empty?).to be_falsey
expect(subject.functions.empty?).to be_truthy
2014-05-05 19:01:36 +01: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")
2015-10-20 14:37:18 -05:00
expect(byte_array).to be
expect(byte_array).to be_kind_of String
expect(byte_array.include?('[Byte[]] $')).to be_truthy
2014-05-05 19:01:36 +01:00
end
end
describe "::code_modifiers" do
it 'should return an array of modifier methods' do
mods = Rex::Powershell::Script.code_modifiers
2015-10-20 14:37:18 -05:00
expect(mods).to be
expect(mods).to be_kind_of Array
expect(mods.empty?).to be_falsey
2014-05-05 19:01:36 +01:00
end
end
end