Sha256: 26eb19741ca93018d5d9875d1de7970749711b70f3067895e207b9640cce66a4

Contents?: true

Size: 1.98 KB

Versions: 8

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'

require Arachni::Options.paths.lib + 'rpc/client/instance'
require Arachni::Options.paths.lib + 'rpc/server/instance'

describe Arachni::RPC::Server::ActiveOptions do
    before( :all ) do
        @utils = Arachni::Utilities
        @instance = instance_spawn
    end

    before( :each ) { @instance.service.clear_cookies }

    describe '#set' do
        it 'sets options by hash' do
            @instance.service.cookies.should be_empty

            opts = {
                'url'   =>  'http://blah.com',
                'scope' =>  {
                    'exclude_path_patterns'   => [ 'exclude me' ],
                    'include_path_patterns'   => [ 'include me' ],
                    'redundant_path_patterns' => { 'redundant' => 3 },
                },
                'datastore' => { 'key' => 'val' },
                'http'      => {
                    'cookies'       => { 'name' => 'value' },
                    'cookie_string' => 'name3=value3'
                }
            }

            @instance.options.set( opts )
            h = @instance.options.to_h

            h['url'].to_s.should == @utils.normalize_url( opts['url'] )
            h['scope']['exclude_path_patterns'].should ==
                opts['scope']['exclude_path_patterns'].map { |s| Regexp.new(s).to_s }
            h['scope']['include_path_patterns'].should ==
                opts['scope']['include_path_patterns'].map { |s| Regexp.new(s).to_s }
            h['scope']['redundant_path_patterns'].should ==
                opts['scope']['redundant_path_patterns'].
                    inject({}) { |hh, (k, v)| hh[Regexp.new(k).to_s] = v.to_s; hh }

            h['datastore'].should == opts['datastore']

            @instance.service.cookies.map { |c| Arachni::Cookie.from_rpc_data c }.should == [
                Arachni::Cookie.new( url: opts['url'], inputs: opts['http']['cookies'] ),
                Arachni::Cookie.new( url: opts['url'], inputs: { name3: 'value3' } )
            ]
        end
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arachni-1.1 spec/arachni/rpc/server/active_options_spec.rb
arachni-1.0.6 spec/arachni/rpc/server/active_options_spec.rb
arachni-1.0.5 spec/arachni/rpc/server/active_options_spec.rb
arachni-1.0.4 spec/arachni/rpc/server/active_options_spec.rb
arachni-1.0.3 spec/arachni/rpc/server/active_options_spec.rb
arachni-1.0.2 spec/arachni/rpc/server/active_options_spec.rb
arachni-1.0.1 spec/arachni/rpc/server/active_options_spec.rb
arachni-1.0 spec/arachni/rpc/server/active_options_spec.rb