Skip to content

Commit

Permalink
Add /db/model specs
Browse files Browse the repository at this point in the history
  • Loading branch information
moozzi committed May 13, 2024
1 parent 4e143f5 commit 73b44ab
Show file tree
Hide file tree
Showing 4 changed files with 384 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ gem 'ronin-repos', '~> 0.2', github: 'ronin-rb/ronin-repos',

group :development do
gem 'rake', require: false
gem 'rack-test', '~> 2.1', require: false

gem 'rubygems-tasks', '~> 0.2'

gem 'rspec', '~> 3.0', require: false
gem 'simplecov', '~> 0.20', require: false
gem 'capybara', '~> 3.40', require: false

gem 'kramdown', '~> 2.0', require: false
gem 'kramdown-man', '~> 1.0', require: false
Expand Down
373 changes: 373 additions & 0 deletions spec/routes/db_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,373 @@
require 'spec_helper'
require './app'

describe App, type: :feature do
context 'GET /db' do
let(:paths) do
[
'/db/host_names',
'/db/asns',
'/db/ip_addresses',
'/db/mac_addresses',
'/db/open_ports',
'/db/ports',
'/db/services',
'/db/vulns',
'/db/urls',
'/db/url_schemes',
'/db/passwords',
'/db/credentials',
'/db/advisories',
'/db/software',
'/db/software_vendors',
'/db/oses',
'/db/phone_numbers',
'/db/street_addresses',
'/db/organizations',
'/db/people'
]
end

it 'must return status 200 and include links to models' do
visit '/db'

expect(page.status_code).to eq(200)
paths.each do |path|
expect(page).to have_xpath("//a[@href='#{path}']")
end
end
end

context 'GET /db/host_names' do
let!(:host_name) { Ronin::DB::HostName.find_or_import('example.com') }
let(:xpath) { "//a[text()='#{host_name}'][@href='/db/host_names/#{host_name.id}']" }

it 'must return status 200 and include link to a host name in the body' do
visit '/db/host_names'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/host_names/:id' do
end

context 'GET /db/asns' do
let!(:asn) { Ronin::DB::ASN.find_or_create_by(version: 4, range_start: '1.2.3.4', range_end: '1.2.3.4', number: 1234) }
let(:xpath) { "//a[text()='#{asn}'][@href='/db/asns/#{asn.id}']" }

it 'must return status 200 and include link to a asn in the body' do
visit '/db/asns'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/asns/:id' do
end

context 'GET /db/ip_addresses' do
let!(:ip_address) { Ronin::DB::IPAddress.find_or_import('1.2.3.4') }
let(:xpath) { "//a[text()='#{ip_address}'][@href='/db/ip_addresses/#{ip_address.id}']" }

it 'must return status 200 and include link to a ip address in the body' do
visit '/db/ip_addresses'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/ip_addresses/:id' do
end

context 'GET /db/mac_addresses' do
let!(:mac_address) { Ronin::DB::MACAddress.find_or_import('01:23:45:67:89:ab') }
let(:xpath) { "//a[text()='#{mac_address}'][@href='/db/mac_addresses/#{mac_address.id}']" }

it 'must return status 200 and include link to a mac address in the body' do
visit '/db/mac_addresses'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/mac_addresses/:id' do
end

context 'GET /db/open_ports' do
end

context 'GET /db/open_ports/:id' do
end

context 'GET /db/ports' do
let!(:port) { Ronin::DB::Port.find_or_create_by(number: 11) }
let(:xpath) { "//a[text()='#{port}'][@href='/db/ports/#{port.id}']" }

it 'must return status 200 and include link to a port in the body' do
visit '/db/ports'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/ports/:id' do
end

context 'GET /db/services' do
let!(:service) { Ronin::DB::Service.find_or_import('https') }
let(:xpath) { "//a[text()='#{service}'][@href='/db/services/#{service.id}']" }

it 'must return status 200 and include link to a services in the body' do
visit '/db/services'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/services/:id' do
end

context 'GET /db/urls' do
let!(:url) { Ronin::DB::URL.find_or_import('http://example.com') }
let(:xpath) { "//a[text()='#{url}'][@href='/db/urls/#{url.id}']" }

it 'must return status 200 and include link to a url in the body' do
visit '/db/urls'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/urls/:id' do
end

context 'GET /db/url_schemes' do
let!(:url_scheme) { Ronin::DB::URLScheme.find_or_create_by(name: 'https') }
let(:xpath) { "//a[text()='#{url_scheme}'][@href='/db/url_schemes/#{url_scheme.id}']" }

it 'must return status 200 and include link to a url scheme in the body' do
visit '/db/url_schemes'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/url_schemes/:id' do
end

context 'GET /db/url_query_param_names' do
let!(:url_query_param_names) { Ronin::DB::URLQueryParamName.find_or_create_by(name: 'cat') }
let(:xpath) { "//a[text()='#{url_query_param_names}'][@href='/db/url_query_param_names/#{url_query_param_names.id}']" }

it 'must return status 200 and include link to a url query param name in the body' do
visit '/db/url_query_param_names'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/url_query_param_names/:id' do
end

context 'GET /db/email_addresses' do
let!(:email_address) { Ronin::DB::EmailAddress.find_or_import('[email protected]') }
let(:xpath) { "//a[text()='#{email_address}'][@href='/db/email_addresses/#{email_address.id}']" }

it 'must return status 200 and include link to an email address in the body' do
visit '/db/email_addresses'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/email_addresses/:id' do
end

context 'GET /db/user_names' do
let!(:user_name) { Ronin::DB::UserName.find_or_import('user_name') }
let(:xpath) { "//a[text()='#{user_name}'][@href='/db/user_names/#{user_name.id}']" }

it 'must return status 200 and include link to an user name in the body' do
visit '/db/user_names'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/user_names/:id' do
end

context 'GET /db/passwords' do
let!(:password) { Ronin::DB::Password.find_or_import('password') }
let(:xpath) { "//a[text()='#{password}'][@href='/db/passwords/#{password.id}']" }

it 'must return status 200 and include link to a passwords in the body' do
visit '/db/passwords'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/passwords/:id' do
end

context 'GET /db/credentials' do
let!(:credential) { Ronin::DB::Credential.find_or_import('user:password') }
let(:xpath) { "//a[text()='#{credential}'][@href='/db/credentials/#{credential.id}']" }

it 'must return status 200 and include link to a credential in the body' do
visit '/db/credentials'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/credentials/:id' do
end

context 'GET /db/advisories' do
let!(:advisory) { Ronin::DB::Advisory.find_or_import('ABC-2023:12-34') }
let(:xpath) { "//a[text()='#{advisory}'][@href='/db/advisories/#{advisory}']" }

it 'must return status 200 and include link to a advisory in the body' do
visit '/db/advisories'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/advisories/:id' do
end

context 'GET /db/software' do
let!(:software) { Ronin::DB::Software.find_or_create_by(name: 'software', version: 1) }
let(:xpath) { "//a[text()='#{software}'][@href='/db/software/#{software.id}']" }

it 'must return status 200 and include link to a software in the body' do
visit '/db/software'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/software/:id' do
end

context 'GET /db/software_vendors' do
let!(:software_vendor) { Ronin::DB::SoftwareVendor.find_or_create_by(name: 'software vendor') }
let(:xpath) { "//a[text()='#{software_vendor}'][@href='/db/software_vendors/#{software_vendor.id}']" }

it 'must return status 200 and include link to a software vendor in the body' do
visit '/db/software_vendors'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/software_vendors/:id' do
end

context 'GET /db/oses' do
let!(:os) { Ronin::DB::OS.find_or_create_by(name: 'os', version: 1) }
let(:xpath) { "//a[text()='#{os}'][@href='/db/oses/#{os.id}']" }

it 'must return status 200 and include link to a os in the body' do
visit '/db/oses'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/oses/:id' do
end

context 'GET /db/vulns' do
end

context 'GET /db/vulns/:id' do
end

context 'GET /db/phone_numbers' do
let!(:phone_number) { Ronin::DB::PhoneNumber.find_or_import('+1 123-456-7890') }
let(:xpath) { "//a[text()='#{phone_number}'][@href='/db/phone_numbers/#{phone_number.id}']" }

it 'must return status 200 and include link to a phone number in the body' do
visit '/db/phone_numbers'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/phone_numbers/:id' do
end

context 'GET /db/street_addresses' do
let!(:street_addresses) { Ronin::DB::StreetAddress.find_or_create_by(address: 'Address', city: 'City', state: 'State', zipcode: '00-000', country: 'Country') }
let(:xpath) { "//a[text()='#{street_addresses}'][@href='/db/street_addresses/#{street_addresses.id}']" }

it 'must return status 200 and include link to a street address in the body' do
visit '/db/street_addresses'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/street_addresses/:id' do
end

context 'GET /db/organizations' do
let!(:organization) { Ronin::DB::Organization.find_or_import('org_name') }
let(:xpath) { "//a[text()='#{organization}'][@href='/db/organizations/#{organization.id}']" }

it 'must return status 200 and include link to a organization in the body' do
visit '/db/organizations'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/organizations/:id' do
end

context 'GET /db/organization_members/:id' do
end

context 'GET /db/organization_departments/:id' do
end

context 'GET /db/people' do
let!(:person) { Ronin::DB::Person.find_or_import('full name') }
let(:xpath) { "//a[text()='#{person}'][@href='/db/people/#{person.id}']" }

it 'must return status 200 and include link to a person in the body' do
visit '/db/people'

expect(page.status_code).to eq(200)
expect(page).to have_xpath(xpath)
end
end

context 'GET /db/people/:id' do
end
end
Empty file added spec/routes/scanning_spec.rb
Empty file.
Loading

0 comments on commit 73b44ab

Please sign in to comment.