Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specs for Net::ServiceID #121

Merged
merged 2 commits into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions spec/builtin/net/service_id_spec.rb
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