Sha256: cd9e7700e929405ae0cdfc1edb38d53cf0de5ca16c17e90ca997d99fb38b8112

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

require File.join(File.dirname(__FILE__), "..", "..", "test_helper.rb")

describe "Relevance::Tarantula::AttackHandler" do
  before do
    @handler = Relevance::Tarantula::AttackHandler.new
    attack = Relevance::Tarantula::Attack.new({:name => 'foo_name', :input => 'foo_code', :output => '<bad>'})
    @handler.stubs(:attacks).returns([attack])
  end
  
  it "lets safe documents through" do
    result = @handler.handle(Relevance::Tarantula::Result.new(:response => stub(:html? => true, :body => '<a href="/foo">good</a>')))
    result.should == nil
  end
  
  it "detects the supplied code" do
    result = @handler.handle(Relevance::Tarantula::Result.new(:response => stub(:html? => true, :body => '<a href="/foo"><bad></a>')))
    result.success.should == false
  end
end

describe "Attacks without an output specified" do
  it "never matches anything" do
    handler = Relevance::Tarantula::AttackHandler.new
    attack = Relevance::Tarantula::Attack.new({:name => 'foo_name', :input => 'foo_code'})
    Relevance::Tarantula::AttackFormSubmission.stubs(:attacks).returns([attack])
    result = handler.handle(Relevance::Tarantula::Result.new(:response => stub(:html? => true, :body => '<a href="/foo">good</a>')))
    result.should == nil
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
relevance-tarantula-0.0.5 test/relevance/tarantula/attack_handler_test.rb
relevance-tarantula-0.0.6 test/relevance/tarantula/attack_handler_test.rb
relevance-tarantula-0.0.7.1 test/relevance/tarantula/attack_handler_test.rb
relevance-tarantula-0.0.7 test/relevance/tarantula/attack_handler_test.rb
relevance-tarantula-0.0.8.0 test/relevance/tarantula/attack_handler_test.rb
relevance-tarantula-0.0.8.1 test/relevance/tarantula/attack_handler_test.rb
tarantula-0.0.5 test/relevance/tarantula/attack_handler_test.rb
tarantula-0.0.8.1 test/relevance/tarantula/attack_handler_test.rb