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 spec for HttpListener in Ronin::CLI::Commands::New #252: #255

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
40 changes: 34 additions & 6 deletions lib/ronin/cli/pattern_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,46 @@ def self.included(command)
def self.define_numeric_options(command)
command.option :number, short: '-N',
desc: 'Searches for all numbers' do
@pattern = NUMBER
end
@pattern = NUMBER
end

command.option :hex_number, short: '-X',
desc: 'Searches for all hexadecimal numbers' do
@pattern = HEX_NUMBER
end
@pattern = HEX_NUMBER
end

command.option :version_number, short: '-V',
desc: 'Searches for all version numbers' do
@pattern = VERSION_NUMBER
end
@pattern = VERSION_NUMBER
end

command.option :alpha, desc: 'Searches for all alphabetic characters' do
@pattern = /[a-zA-Z]+/
end

command.option :uppercase, desc: 'Searches for all uppercase alphabetic characters' do
@pattern = /[A-Z]+/
end

command.option :lowercase, desc: 'Searches for all lowercase alphabetic characters' do
@pattern = /[a-z]+/
end

command.option :alpha_numeric, desc: 'Searches for all alphanumeric characters' do
@pattern = /[0-9a-zA-Z]+/
end

command.option :hex, desc: 'Searches for all hexadecimal characters' do
@pattern = /[0-9a-fA-F]+/
end

command.option :uppercase_hex, desc: 'Searches for all uppercase hexadecimal characters' do
@pattern = /[0-9A-F]+/
end

command.option :lowercase_hex, desc: 'Searches for all lowercase hexadecimal characters' do
@pattern = /[0-9a-f]+/
end
end

#
Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/new/exploit_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'
require 'ronin/cli/commands/new/exploit'

describe Ronin::CLI::Commands::New::Exploit do
describe "command_name" do
subject { described_class }

it do
expect(subject.command_name).to eq('exploit')
end
end
end
12 changes: 12 additions & 0 deletions spec/cli/commands/new/http_listener_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'spec_helper'
require 'ronin/cli/commands/new/http_listener'

describe Ronin::CLI::Commands::New::HttpListener do
describe "command_name" do
subject { described_class }

it do
expect(subject.command_name).to eq('http-listener')
end
end
end
49 changes: 49 additions & 0 deletions spec/cli/pattern_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,55 @@ class TestCommand < Ronin::CLI::Command
expect(subject.options[:version_number].desc).to eq('Searches for all version numbers')
end

it "must define a '--alpha' option" do
expect(subject.options[:alpha]).to_not be(nil)
expect(subject.options[:alpha].short).to be(nil)
expect(subject.options[:alpha].value).to be(nil)
expect(subject.options[:alpha].desc).to eq('Searches for all alphabetic characters')
end

it "must define a '--uppercase' option" do
expect(subject.options[:uppercase]).to_not be(nil)
expect(subject.options[:uppercase].short).to be(nil)
expect(subject.options[:uppercase].value).to be(nil)
expect(subject.options[:uppercase].desc).to eq('Searches for all uppercase alphabetic characters')
end

it "must define a '--lowercase' option" do
expect(subject.options[:lowercase]).to_not be(nil)
expect(subject.options[:lowercase].short).to be(nil)
expect(subject.options[:lowercase].value).to be(nil)
expect(subject.options[:lowercase].desc).to eq('Searches for all lowercase alphabetic characters')
end

it "must define a '--alpha-numeric' option" do
expect(subject.options[:alpha_numeric]).to_not be(nil)
expect(subject.options[:alpha_numeric].short).to be(nil)
expect(subject.options[:alpha_numeric].value).to be(nil)
expect(subject.options[:alpha_numeric].desc).to eq('Searches for all alphanumeric characters')
end

it "must define a '--hex' option" do
expect(subject.options[:hex]).to_not be(nil)
expect(subject.options[:hex].short).to be(nil)
expect(subject.options[:hex].value).to be(nil)
expect(subject.options[:hex].desc).to eq('Searches for all hexadecimal characters')
end

it "must define a '--uppercase-hex' option" do
expect(subject.options[:uppercase_hex]).to_not be(nil)
expect(subject.options[:uppercase_hex].short).to be(nil)
expect(subject.options[:uppercase_hex].value).to be(nil)
expect(subject.options[:uppercase_hex].desc).to eq('Searches for all uppercase hexadecimal characters')
end

it "must define a '--lowercase-hex' option" do
expect(subject.options[:lowercase_hex]).to_not be(nil)
expect(subject.options[:lowercase_hex].short).to be(nil)
expect(subject.options[:lowercase_hex].value).to be(nil)
expect(subject.options[:lowercase_hex].desc).to eq('Searches for all lowercase hexadecimal characters')
end

#
# Language pattern options
#
Expand Down
Loading