Skip to content

Commit

Permalink
Add specs for new {public,private}_match? methods
Browse files Browse the repository at this point in the history
  • Loading branch information
egypt committed Jan 26, 2015
1 parent 7b6c374 commit 2e644d1
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions spec/models/metasploit/credential/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -868,4 +868,84 @@

end

context 'instance methods' do
let(:core) do
FactoryGirl.build(
:metasploit_credential_core,
private: FactoryGirl.build(:metasploit_credential_password, data: "password"),
public: FactoryGirl.build(:metasploit_credential_public, username: "administrator")
)
end

context 'with both public and private' do
context '#public_match?' do
specify do
expect(core.public_match?(/admin/)).to eq(true)
end
specify do
expect(core.public_match?(/user/)).to eq(false)
end
end

context '#private_match?' do
specify do
expect(core.private_match?(/password/)).to eq(true)
end
specify do
expect(core.private_match?(/qwerty123/)).to eq(false)
end
end
end

context 'with no public' do
before(:each) do
core.public = nil
end

context '#public_match?' do
specify do
expect(core.public_match?(/admin/)).to eq(false)
end
end

context '#private_match?' do
specify do
expect(core.private_match?(/password/)).to eq(true)
end
specify do
expect(core.private_match?(/qwerty123/)).to eq(false)
end
end

end

context 'with no private' do
before(:each) do
core.private = nil
end

context '#public_match?' do
specify do
expect(core.public_match?(/admin/)).to eq(true)
end
specify do
expect(core.public_match?(/user/)).to eq(false)
end
end

context '#private_match?' do
specify do
expect(core.private_match?(/password/)).to eq(false)
end
specify do
expect(core.private_match?(/qwerty123/)).to eq(false)
end
end


end


end

end

0 comments on commit 2e644d1

Please sign in to comment.