Sha256: 004199b8d87c418388a44d8abebf2fa378a60f53ef9ce51f0d77f1819272a7b4

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'
require 'helpers/xml'

require 'nmap/xml'

describe XML do
  include Helpers

  before(:all) do
    @xml = XML.new(Helpers::SCAN_FILE)
  end

  it "should have a version" do
    @xml.version.should == '1.02'
  end

  it "should parse the scanner version" do
    @xml.scanner.version == '4.68'
  end

  it "should parse the scanner name" do
    @xml.scanner.name.should == 'nmap'
  end

  it "should parse the scanner arguments" do
    @xml.scanner.arguments.should == 'nmap -v -oX samples/backspace.xml -O -P0 -sS 192.168.5.*'
  end

  it "should parse the scanner start time" do
    @xml.scanner.start_time.should == Time.at(1218934249)
  end

  it "should parse the scan information" do
    scan_info = @xml.scan_info

    scan_info.length.should == 1
    scan_info.first.type.should == :syn
    scan_info.first.protocol.should == :tcp
  end

  it "should parse the verbose level" do
    @xml.verbose.should == 1
  end

  it "should parse the debugging level" do
    @xml.debugging.should == 0
  end

  it "should parse the scan tasks" do
    tasks = @xml.tasks

    tasks.should_not be_empty

    tasks.each do |task|
      task.name.should_not be_nil
      task.name.should_not be_empty

      task.start_time.should > Time.at(0)

      task.end_time.should > Time.at(0)
      task.end_time.should >= task.start_time
    end
  end

  it "should parse the hosts" do
    @xml.hosts.length.should == 10
  end

  it "should convert to a String" do
    @xml.to_s.should == Helpers::SCAN_FILE
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-nmap-0.4.0 spec/xml_spec.rb
ruby-nmap-0.3.0 spec/xml_spec.rb
ruby-nmap-0.2.0 spec/xml_spec.rb