From c426cf32d0c4f96db0fbcedf41ebb31ce33371c6 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 Date: Thu, 18 Dec 2014 17:40:06 -0600 Subject: [PATCH] Add specs for Rex::Proto::Kerberos::CredentialCache::Principal --- .../proto/kerberos/credential_cache/cache.rb | 2 ++ .../kerberos/credential_cache/credential.rb | 2 ++ .../kerberos/credential_cache/element.rb | 2 ++ .../kerberos/credential_cache/key_block.rb | 2 ++ .../kerberos/credential_cache/principal.rb | 2 ++ .../proto/kerberos/credential_cache/time.rb | 2 ++ .../credential_cache/principal_spec.rb | 28 +++++++++++++++++++ 7 files changed, 40 insertions(+) create mode 100644 spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb diff --git a/lib/rex/proto/kerberos/credential_cache/cache.rb b/lib/rex/proto/kerberos/credential_cache/cache.rb index 7ffb37b9b5..6953050029 100644 --- a/lib/rex/proto/kerberos/credential_cache/cache.rb +++ b/lib/rex/proto/kerberos/credential_cache/cache.rb @@ -1,3 +1,5 @@ +# -*- coding: binary -*- + module Rex module Proto module Kerberos diff --git a/lib/rex/proto/kerberos/credential_cache/credential.rb b/lib/rex/proto/kerberos/credential_cache/credential.rb index 8b77e6333f..dc6fcdfb77 100644 --- a/lib/rex/proto/kerberos/credential_cache/credential.rb +++ b/lib/rex/proto/kerberos/credential_cache/credential.rb @@ -1,3 +1,5 @@ +# -*- coding: binary -*- + module Rex module Proto module Kerberos diff --git a/lib/rex/proto/kerberos/credential_cache/element.rb b/lib/rex/proto/kerberos/credential_cache/element.rb index 3c0fccdb50..459c5daa43 100644 --- a/lib/rex/proto/kerberos/credential_cache/element.rb +++ b/lib/rex/proto/kerberos/credential_cache/element.rb @@ -1,3 +1,5 @@ +# -*- coding: binary -*- + module Rex module Proto module Kerberos diff --git a/lib/rex/proto/kerberos/credential_cache/key_block.rb b/lib/rex/proto/kerberos/credential_cache/key_block.rb index e99450b337..0a58688216 100644 --- a/lib/rex/proto/kerberos/credential_cache/key_block.rb +++ b/lib/rex/proto/kerberos/credential_cache/key_block.rb @@ -1,3 +1,5 @@ +# -*- coding: binary -*- + module Rex module Proto module Kerberos diff --git a/lib/rex/proto/kerberos/credential_cache/principal.rb b/lib/rex/proto/kerberos/credential_cache/principal.rb index 1ea09b649d..fee17cec48 100644 --- a/lib/rex/proto/kerberos/credential_cache/principal.rb +++ b/lib/rex/proto/kerberos/credential_cache/principal.rb @@ -1,3 +1,5 @@ +# -*- coding: binary -*- + module Rex module Proto module Kerberos diff --git a/lib/rex/proto/kerberos/credential_cache/time.rb b/lib/rex/proto/kerberos/credential_cache/time.rb index c20613950a..2f9d586ae2 100644 --- a/lib/rex/proto/kerberos/credential_cache/time.rb +++ b/lib/rex/proto/kerberos/credential_cache/time.rb @@ -1,3 +1,5 @@ +# -*- coding: binary -*- + module Rex module Proto module Kerberos diff --git a/spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb b/spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb new file mode 100644 index 0000000000..c474ab56ca --- /dev/null +++ b/spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb @@ -0,0 +1,28 @@ +# -*- coding:binary -*- +require 'spec_helper' + +require 'rex/proto/kerberos' + +describe Rex::Proto::Kerberos::CredentialCache::Principal do + + subject(:principal) do + described_class.new + end + + let(:sample) do + "\x00\x00\x00\x01\x00\x00\x00\x01" + + "\x00\x00\x00\x0a\x44\x45\x4d\x4f" + + "\x2e\x4c\x4f\x43\x41\x4c\x00\x00" + + "\x00\x04\x6a\x75\x61\x6e" + end + + describe "#encode" do + it "encodes Rex::Proto::Kerberos::CredentialCache::Principal correctly" do + principal.name_type = 1 + principal.realm = 'DEMO.LOCAL' + principal.components = ['juan'] + + expect(principal.encode).to eq(sample) + end + end +end \ No newline at end of file