spec/service_spec.rb in ruby-nmap-0.6.0 vs spec/service_spec.rb in ruby-nmap-0.7.0
- old
+ new
@@ -1,40 +1,77 @@
require 'spec_helper'
-require 'helpers/xml'
+require 'cpe_examples'
require 'nmap/xml'
require 'nmap/service'
describe Service do
- include Helpers
+ subject { @xml.hosts.first.ports.first.service }
- before(:all) do
- @xml = XML.new(Helpers::SCAN_FILE)
- @nse_xml = XML.new(Helpers::NSE_FILE)
+ describe "#name" do
+ it "should parse the name" do
+ subject.name.should == 'ssh'
+ end
end
- subject { @xml.hosts.first.ports.first.service }
+ describe "#ssl?" do
+ it "should check the tunnel attribute" do
+ pending "need a service that uses SSL"
+ end
+ end
- it "should have a name" do
- subject.name.should == 'ftp'
+ describe "#protocol" do
+ it "should parse the proto attribute" do
+ pending "need a service with the proto attribute"
+ end
end
- it "should have a fingerprint method" do
- subject.fingerprint_method.should == :table
+ describe "#product" do
+ it "should parse the product name attribute" do
+ subject.product.should == 'OpenSSH'
+ end
end
- it "should have a confidence" do
- subject.confidence.should == 3
+ describe "#version" do
+ it "should parse the version attribute" do
+ subject.version.should == '5.3p1 Debian 3ubuntu7'
+ end
end
- context "with improved detection" do
- subject { @nse_xml.hosts.first.ports.first.service }
+ describe "#extra_info" do
+ it "should parse the extrainfo attribute" do
+ subject.extra_info.should == 'protocol 2.0'
+ end
+ end
- it "should have a product name" do
- subject.product.should == 'OpenSSH'
+ describe "#hostname" do
+ it "should parse the hostname attribute" do
+ pending "need a service with the hostname attribute"
end
+ end
- it "should have a version" do
- subject.version.should == '5.1p1 Debian 6ubuntu2'
+ describe "#os_type" do
+ it "should parse the ostype attribute" do
+ subject.os_type.should == 'Linux'
end
end
+
+ describe "#device_type" do
+ it "should parse the devicetype attribute" do
+ pending "need a service with the devicetype attribute"
+ end
+ end
+
+ describe "#fingerprint_method" do
+ it "should parse the method attribute" do
+ subject.fingerprint_method.should == :probed
+ end
+ end
+
+ describe "#confidence" do
+ it "should parse the conf attribute" do
+ subject.confidence.should be_between(0,10)
+ end
+ end
+
+ it_should_behave_like "CPE"
end