-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--------- Co-authored-by: Postmodern <postmodern.mod3@gmail.com>
- Loading branch information
1 parent
319b01a
commit 3883821
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
require 'spec_helper' | ||
require 'ronin/recon/builtin/net/service_id' | ||
|
||
RSpec.describe Ronin::Recon::Net::ServiceID do | ||
describe '#process' do | ||
context 'when nameserver is running on given port' do | ||
let(:port) { Ronin::Recon::Values::OpenPort.new("93.184.216.34", 53, service: 'domain') } | ||
|
||
it 'must yield Values::Nameserver' do | ||
yielded_value = nil | ||
|
||
subject.process(port) do |value| | ||
yielded_value = value | ||
end | ||
|
||
expect(yielded_value).to be_kind_of(Ronin::Recon::Values::Nameserver) | ||
expect(yielded_value.name).to eq(port.host) | ||
end | ||
end | ||
|
||
context 'when mailserver is running on given port' do | ||
let(:port) { Ronin::Recon::Values::OpenPort.new("93.184.216.34", 25, service: 'smtp') } | ||
|
||
it 'must yield Values::Mailserver' do | ||
yielded_value = nil | ||
|
||
subject.process(port) do |value| | ||
yielded_value = value | ||
end | ||
|
||
expect(yielded_value).to be_kind_of(Ronin::Recon::Values::Mailserver) | ||
expect(yielded_value.name).to eq(port.host) | ||
end | ||
end | ||
|
||
context 'when http website is running on given port' do | ||
let(:port) { Ronin::Recon::Values::OpenPort.new("93.184.216.34", 443, service: 'http') } | ||
|
||
it 'must yield Values::Website with http schema' do | ||
yielded_value = nil | ||
|
||
subject.process(port) do |value| | ||
yielded_value = value | ||
end | ||
|
||
expect(yielded_value).to be_kind_of(Ronin::Recon::Values::Website) | ||
expect(yielded_value.scheme).to eq(:http) | ||
expect(yielded_value.host).to eq(port.host) | ||
end | ||
|
||
context 'but it also has ssl enabled' do | ||
let(:port) { Ronin::Recon::Values::OpenPort.new("93.184.216.34", 80, service: 'http', ssl: true) } | ||
|
||
it 'must yield Values::Website with https schema' do | ||
yielded_value = nil | ||
|
||
subject.process(port) do |value| | ||
yielded_value = value | ||
end | ||
|
||
expect(yielded_value).to be_kind_of(Ronin::Recon::Values::Website) | ||
expect(yielded_value.scheme).to eq(:https) | ||
expect(yielded_value.host).to eq(port.host) | ||
end | ||
end | ||
end | ||
|
||
context 'when https website is running on given port' do | ||
let(:port) { Ronin::Recon::Values::OpenPort.new("93.184.216.34", 443, service: 'https', ssl: true) } | ||
|
||
it 'must yield Values::Website' do | ||
yielded_value = nil | ||
|
||
subject.process(port) do |value| | ||
yielded_value = value | ||
end | ||
|
||
expect(yielded_value).to be_kind_of(Ronin::Recon::Values::Website) | ||
expect(yielded_value.scheme).to eq(:https) | ||
expect(yielded_value.host).to eq(port.host) | ||
end | ||
end | ||
end | ||
end |