spec/os_spec.rb in ruby-nmap-0.6.0 vs spec/os_spec.rb in ruby-nmap-0.7.0
- old
+ new
@@ -2,39 +2,42 @@
require 'nmap/os'
require 'cgi'
describe OS do
- let(:xml) { XML.new(Helpers::SCAN_FILE) }
+ subject { @xml.hosts.first.os }
- subject { xml.hosts.first.os }
+ describe "#classes" do
+ subject { super().classes }
- it "should parse the OS classes" do
- classes = subject.classes
+ it { should_not be_empty }
- classes.length.should == 1
- classes[0].type.should == :WAP
- classes[0].vendor.should == 'Netgear'
- classes[0].family.should == :embedded
- classes[0].accuracy.should == 100
+ it "should return OSClass objects" do
+ subject.should all_be_kind_of(OSClass)
+ end
end
- it "should parse the OS matches" do
- matches = subject.matches
+ describe "#matches" do
+ subject { super().matches.first }
- matches.length.should == 2
+ it "should parse the name" do
+ subject.name.should == 'Linux 2.6.39'
+ end
- matches[0].name.should == 'Netgear WGR614v6 wireless broadband router'
- matches[0].accuracy.should == 100
-
- matches[1].name.should == 'Netgear WGR614v7 or WPN824v2 wireless broadband router'
- matches[1].accuracy.should == 100
+ it "should parse the accuracy" do
+ subject.accuracy.should be_between(0,100)
+ end
end
- it "should parse the ports used" do
- subject.ports_used.should == [443, 21]
+ describe "#ports_used" do
+ subject { super().ports_used }
+
+ it { subject.should_not be_empty }
+ it { subject.should all_be_between(0,65535) }
end
it "should parse the OS fingerprints" do
- subject.fingerprint.should == CGI.unescapeHTML("SCAN(V=4.68%D=8/16%OT=443%CT=21%CU=%PV=Y%DS=1%G=N%M=001D7E%TM=48A77607%P=i686-pc-linux-gnu)
SEQ(SP=19%GCD=FA00%ISR=9E%TI=I%TS=1)
OPS(O1=M5B4NW0NNT11%O2=M5B4NW0NNT11%O3=M5B4NW0NNT11%O4=M5B4NW0NNT11%O5=M5B4NW0NNT11%O6=M5B4NNT11)
WIN(W1=2000%W2=2000%W3=2000%W4=2000%W5=2000%W6=2000)
ECN(R=Y%DF=N%TG=40%W=2000%O=M5B4NW0%CC=N%Q=)
T1(R=Y%DF=N%TG=40%S=O%A=S+%F=AS%RD=0%Q=)
T2(R=N)
T3(R=N)
T4(R=N)
T5(R=Y%DF=N%TG=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)
T6(R=N)
T7(R=N)
U1(R=N)
IE(R=N)
")
+ pending "scan.xml does not currently have an osfingerprint" do
+ subject.fingerprint.should == CGI.unescapeHTML("SCAN(V=4.68%D=8/16%OT=443%CT=21%CU=%PV=Y%DS=1%G=N%M=001D7E%TM=48A77607%P=i686-pc-linux-gnu)
SEQ(SP=19%GCD=FA00%ISR=9E%TI=I%TS=1)
OPS(O1=M5B4NW0NNT11%O2=M5B4NW0NNT11%O3=M5B4NW0NNT11%O4=M5B4NW0NNT11%O5=M5B4NW0NNT11%O6=M5B4NNT11)
WIN(W1=2000%W2=2000%W3=2000%W4=2000%W5=2000%W6=2000)
ECN(R=Y%DF=N%TG=40%W=2000%O=M5B4NW0%CC=N%Q=)
T1(R=Y%DF=N%TG=40%S=O%A=S+%F=AS%RD=0%Q=)
T2(R=N)
T3(R=N)
T4(R=N)
T5(R=Y%DF=N%TG=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)
T6(R=N)
T7(R=N)
U1(R=N)
IE(R=N)
")
+ end
end
end