add to_hash to Credential
begining of the chain to DRYing up credential reporting in the loginscannerbug/bundler_fix
parent
6a72572237
commit
374c6532fa
|
@ -90,6 +90,16 @@ module Metasploit
|
|||
self
|
||||
end
|
||||
|
||||
def to_hash
|
||||
{
|
||||
private_data: private,
|
||||
private_type: private_type,
|
||||
username: public,
|
||||
realm_key: realm_key,
|
||||
realm_value: realm
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def at_realm
|
||||
|
|
|
@ -7,6 +7,12 @@ describe Metasploit::Framework::Credential do
|
|||
described_class.new
|
||||
}
|
||||
|
||||
let(:public) { "public" }
|
||||
let(:private) { "private" }
|
||||
let(:realm) { "realm" }
|
||||
let(:realm_type) { Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN }
|
||||
let(:private_type) { :password }
|
||||
|
||||
it { should respond_to :paired }
|
||||
it { should respond_to :private }
|
||||
it { should respond_to :private_type }
|
||||
|
@ -76,10 +82,7 @@ describe Metasploit::Framework::Credential do
|
|||
|
||||
end
|
||||
|
||||
describe ".to_credential" do
|
||||
let(:public) { "public" }
|
||||
let(:private) { "private" }
|
||||
let(:realm) { "realm" }
|
||||
describe "#to_credential" do
|
||||
subject(:cred_detail) do
|
||||
described_class.new(public: public, private: private, realm: realm)
|
||||
end
|
||||
|
@ -139,4 +142,20 @@ describe Metasploit::Framework::Credential do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#to_hash' do
|
||||
subject(:cred_detail) do
|
||||
described_class.new(public: public, private: private, realm: realm, realm_key: realm_type, private_type: private_type)
|
||||
end
|
||||
it 'returns a hash in the format expect for create_credential' do
|
||||
cred_hash = {
|
||||
private_data: private,
|
||||
private_type: private_type,
|
||||
username: public,
|
||||
realm_key: realm_type,
|
||||
realm_value: realm
|
||||
}
|
||||
expect(cred_detail.to_hash).to eq cred_hash
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue