2010-10-21 07:07:24 +02:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
describe ProjectHoneypot::Url do
|
|
|
|
describe "with honeypot response" do
|
2013-01-14 14:30:07 +01:00
|
|
|
let(:url) { ProjectHoneypot::Url.new("127.0.0.1", "127.1.63.3") }
|
2010-10-21 07:07:24 +02:00
|
|
|
|
|
|
|
it "is safe" do
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.safe?).to be false
|
2013-01-14 10:07:55 +01:00
|
|
|
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.safe?(score: 63)).to be false
|
|
|
|
expect(url.safe?(score: 64)).to be true
|
2013-01-14 10:07:55 +01:00
|
|
|
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.safe?(last_activity: 1)).to be false
|
|
|
|
expect(url.safe?(last_activity: 2)).to be true
|
2013-01-14 10:07:55 +01:00
|
|
|
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.safe?(last_activity: 2, score: 64)).to be true
|
|
|
|
expect(url.safe?(last_activity: 1, score: 64)).to be false
|
|
|
|
expect(url.safe?(last_activity: 2, score: 63)).to be false
|
2013-01-14 10:07:55 +01:00
|
|
|
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.safe?(offenses: [:comment_spammer])).to be true
|
|
|
|
expect(url.safe?(offenses: [:suspicious, :comment_spammer])).to be false
|
2010-10-21 07:07:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the correct latest activity" do
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.last_activity).to eq(1)
|
2010-10-21 07:07:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the correct score" do
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.score).to eq(63)
|
2010-10-21 07:07:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has the correct offenses" do
|
2015-05-27 11:27:00 +02:00
|
|
|
expect(url.offenses).to include(:suspicious)
|
|
|
|
expect(url.offenses).to include(:harvester)
|
|
|
|
expect(url.offenses).to_not include(:comment_spammer)
|
|
|
|
expect(url).to be_suspicious
|
|
|
|
expect(url).to be_harvester
|
|
|
|
expect(url).to_not be_comment_spammer
|
2010-10-21 07:07:24 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-14 10:07:55 +01:00
|
|
|
describe "with search engine honeypot response" do
|
2013-01-14 14:30:07 +01:00
|
|
|
subject { ProjectHoneypot::Url.new("127.0.0.1", "127.0.9.0") }
|
2013-01-14 10:07:55 +01:00
|
|
|
it { should be_safe }
|
|
|
|
it { should be_search_engine }
|
|
|
|
end
|
|
|
|
|
2010-10-21 07:07:24 +02:00
|
|
|
describe "with nil honeypot response" do
|
2013-01-14 14:30:07 +01:00
|
|
|
subject { ProjectHoneypot::Url.new("127.0.0.1", nil) }
|
2010-10-21 07:07:24 +02:00
|
|
|
it { should be_safe }
|
|
|
|
end
|
|
|
|
end
|