Add specs for Msf::Jmx::MBean::ServerConnection
parent
7e2f9b32b3
commit
2ef57d6172
|
@ -36,7 +36,7 @@ module Msf
|
|||
# @option opts [String] :obj_id the jmx endpoint ObjId
|
||||
# @option opts [String] :name the name of the MBean
|
||||
# @return [Rex::Java::Serialization::Model::Stream]
|
||||
def get_object_instance_stream(opts)
|
||||
def get_object_instance_stream(opts = {})
|
||||
obj_id = opts[:obj_id] || "\x00" * 22
|
||||
name = opts[:name] || ''
|
||||
|
||||
|
@ -69,7 +69,7 @@ module Msf
|
|||
# @option opts [String] :method the method name to invoke
|
||||
# @option opts [String] :args the arguments of the method to invoke
|
||||
# @return [Rex::Java::Serialization::Model::Stream]
|
||||
def invoke_stream(opts)
|
||||
def invoke_stream(opts = {})
|
||||
obj_id = opts[:obj_id] || "\x00" * 22
|
||||
object_name = opts[:object] || ''
|
||||
method_name = opts[:method] || ''
|
||||
|
@ -131,7 +131,7 @@ module Msf
|
|||
#
|
||||
# @param args [Hash] the arguments of the method to invoke
|
||||
# @return [Rex::Java::Serialization::Model::Stream]
|
||||
def invoke_arguments_stream(args)
|
||||
def invoke_arguments_stream(args = {})
|
||||
builder = Rex::Java::Serialization::Builder.new
|
||||
|
||||
new_array = builder.new_array(
|
||||
|
|
|
@ -12,7 +12,10 @@ describe Msf::Jmx::MBean::ServerConnection do
|
|||
mod
|
||||
end
|
||||
|
||||
let(:mbean_name) { 'MBeanSample' }
|
||||
let(:mbean_sample) { 'MBeanSample' }
|
||||
let(:sample_args) do
|
||||
{'arg1' => 'java.lang.String'}
|
||||
end
|
||||
|
||||
describe "#create_mbean_stream" do
|
||||
it "returns a Rex::Java::Serialization::Model::Stream" do
|
||||
|
@ -27,9 +30,64 @@ describe Msf::Jmx::MBean::ServerConnection do
|
|||
|
||||
context "when opts" do
|
||||
it "builds a stream having opts into account" do
|
||||
expect(mod.create_mbean_stream(name: 'MBeanSample').contents[1].contents).to eq('MBeanSample')
|
||||
expect(mod.create_mbean_stream(name: mbean_sample).contents[1].contents).to eq(mbean_sample)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#get_object_instance_stream" do
|
||||
it "returns a Rex::Java::Serialization::Model::Stream" do
|
||||
expect(mod.get_object_instance_stream).to be_a(Rex::Java::Serialization::Model::Stream)
|
||||
end
|
||||
|
||||
context "when no opts" do
|
||||
it "builds a default stream" do
|
||||
expect(mod.get_object_instance_stream.contents[2].contents).to eq('')
|
||||
end
|
||||
end
|
||||
|
||||
context "when opts" do
|
||||
it "builds a stream having opts into account" do
|
||||
expect(mod.get_object_instance_stream(name: mbean_sample).contents[2].contents).to eq(mbean_sample)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#invoke_stream" do
|
||||
it "returns a Rex::Java::Serialization::Model::Stream" do
|
||||
expect(mod.invoke_stream).to be_a(Rex::Java::Serialization::Model::Stream)
|
||||
end
|
||||
|
||||
context "when no opts" do
|
||||
it "builds a default stream" do
|
||||
expect(mod.invoke_stream.contents[2].contents).to eq('')
|
||||
end
|
||||
end
|
||||
|
||||
context "when opts" do
|
||||
it "builds a stream having opts into account" do
|
||||
expect(mod.invoke_stream(object: mbean_sample).contents[2].contents).to eq(mbean_sample)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#invoke_arguments_stream" do
|
||||
it "returns a Rex::Java::Serialization::Model::Stream" do
|
||||
expect(mod.invoke_arguments_stream).to be_a(Rex::Java::Serialization::Model::Stream)
|
||||
end
|
||||
|
||||
context "when no opts" do
|
||||
it "builds a default stream" do
|
||||
expect(mod.invoke_arguments_stream.contents[0].values.length).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context "when opts" do
|
||||
it "builds a stream having opts into account" do
|
||||
expect(mod.invoke_arguments_stream(sample_args).contents[0].values[0].contents).to eq(sample_args['arg1'])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue