Add specs for Msf::Kerberos::Client::CacheCredential

bug/bundler_fix
jvazquez-r7 2014-12-21 23:47:40 -06:00
parent 7cb27408b2
commit 1f3eded4a8
2 changed files with 133 additions and 18 deletions

View File

@ -32,13 +32,13 @@ module Msf
# Builds a MIT Credential Cache principal
#
# @param opts [Hash<{Symbol => <String, Array<String>}>]
# @option opts [String] :name_type
# @param opts [Hash<{Symbol => <Fixnum, String, Array<String>}>]
# @option opts [Fixnum] :name_type
# @option opts [String] :realm
# @option opts [Array<String>] :components
# @return [Rex::Proto::Kerberos::CredentialCache::Principal]
def create_cache_principal(opts = {})
name_type = opts[:name_type] || ''
name_type = opts[:name_type] || 0
realm = opts[:realm] || ''
components = opts[:components] || ['']
@ -59,7 +59,7 @@ module Msf
# @option opts [String] :key_value
# @return [Rex::Proto::Kerberos::CredentialCache::KeyBlock]
def create_cache_key_block(opts = {})
key_type = opts[:key_type]
key_type = opts[:key_type] || 23
e_type = opts[:e_type] || 0
key_value = opts[:key_value] || ''
@ -111,15 +111,15 @@ module Msf
# @option opts [String] second_ticket
# @return [Rex::Proto::Kerberos::CredentialCache::Credential]
def create_cache_credential(opts = {})
client = opts[:client]
server = opts[:server]
key = opts[:key]
time = opts[:time]
client = opts[:client] || create_cache_principal(opts)
server = opts[:server] || create_cache_principal(opts)
key = opts[:key] || create_cache_key_block(opts)
time = opts[:time] || create_cache_times(opts)
is_skey = opts[:is_skey] || 0
tkt_flags = opts[:flags]
tkt_flags = opts[:flags] || 0
addrs = opts[:addrs] || []
auth_data = opts[:auth_data] || []
ticket = opts[:ticket]
ticket = opts[:ticket] || ''
second_ticket = opts[:second_ticket] || ''
cred = Rex::Proto::Kerberos::CredentialCache::Credential.new(

View File

@ -12,29 +12,144 @@ describe Msf::Kerberos::Client::CacheCredential do
mod
end
let(:cred_opts) do
{
:flags => 0x580000
}
end
let(:time_opts) do
{
:auth_time => 123456
}
end
let(:key_opts) do
{
:key_type => 25
}
end
let(:principal_opts) do
{
:name_type => 3
}
end
let(:cache_opts) do
{
:version => 21
}
end
describe "#create_cache_credential" do
context "when no opts" do
it "create a default Rex::Proto::Kerberos::CredentialCache::Credential" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Credential" do
expect(subject.create_cache_credential). to be_a(Rex::Proto::Kerberos::CredentialCache::Credential)
end
it "initializes the Credential with default values" do
expect(subject.create_cache_credential.client.components).to eq([''])
end
end
context "when opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Credential according to options" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Credential" do
expect(subject.create_cache_credential(cred_opts)).to be_a(Rex::Proto::Kerberos::CredentialCache::Credential)
end
it "initializes the Credential with opts when available" do
expect(subject.create_cache_credential(cred_opts).tkt_flags).to eq(0x580000)
end
end
end
describe "#create_cache_times" do
context "when no opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Time" do
expect(subject.create_cache_times).to be_a(Rex::Proto::Kerberos::CredentialCache::Time)
end
it "initializes the Time with default values" do
expect(subject.create_cache_times.auth_time).to eq(0)
end
end
context "when opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Time" do
expect(subject.create_cache_times(time_opts)).to be_a(Rex::Proto::Kerberos::CredentialCache::Time)
end
it "initializes the Time with opts when available" do
expect(subject.create_cache_times(time_opts).auth_time).to eq(123456)
end
end
end
describe "#create_cache_key_block" do
context "when no opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::KeyBlock" do
expect(subject.create_cache_key_block).to be_a(Rex::Proto::Kerberos::CredentialCache::KeyBlock)
end
it "initializes the KeyBlock with default values" do
expect(subject.create_cache_key_block.key_type).to eq(23)
end
end
context "when opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::KeyBlock" do
expect(subject.create_cache_key_block(key_opts)).to be_a(Rex::Proto::Kerberos::CredentialCache::KeyBlock)
end
it "initializes the KeyBlock with opts when available" do
expect(subject.create_cache_key_block(key_opts).key_type).to eq(25)
end
end
end
describe "#create_cache_principal" do
context "when no opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Principal" do
expect(subject.create_cache_principal).to be_a(Rex::Proto::Kerberos::CredentialCache::Principal)
end
it "initializes the Principal with default values" do
expect(subject.create_cache_principal.name_type).to eq(0)
end
end
context "when opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Principal" do
expect(subject.create_cache_principal(principal_opts)).to be_a(Rex::Proto::Kerberos::CredentialCache::Principal)
end
it "initializes the Principal with opts when available" do
expect(subject.create_cache_principal(principal_opts).name_type).to eq(3)
end
end
end
describe "#create_cache" do
end
context "when no opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Cache" do
expect(subject.create_cache).to be_a(Rex::Proto::Kerberos::CredentialCache::Cache)
end
describe "#create_cache" do
end
it "initializes the Cache with default values" do
expect(subject.create_cache.version).to eq(Rex::Proto::Kerberos::CredentialCache::VERSION)
end
end
describe "#create_cache" do
end
describe "#create_cache" do
context "when opts" do
it "creates a Rex::Proto::Kerberos::CredentialCache::Cache" do
expect(subject.create_cache(cache_opts)).to be_a(Rex::Proto::Kerberos::CredentialCache::Cache)
end
it "initializes the Cache with opts when available" do
expect(subject.create_cache(cache_opts).version).to eq(21)
end
end
end
end