ronin 1.0.0 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +0 -1
- data/ChangeLog.md +67 -3
- data/Gemfile +20 -12
- data/README.md +3 -5
- data/gemspec.yml +5 -5
- data/lib/ronin/address.rb +8 -3
- data/lib/ronin/arch.rb +39 -14
- data/lib/ronin/author.rb +2 -0
- data/lib/ronin/auto_load.rb +67 -0
- data/lib/ronin/campaign.rb +15 -2
- data/lib/ronin/class_methods.rb +7 -1
- data/lib/ronin/config.rb +5 -0
- data/lib/ronin/credential.rb +14 -3
- data/lib/ronin/database/database.rb +38 -12
- data/lib/ronin/database/migrations.rb +3 -1
- data/lib/ronin/database/migrations/add_created_at_column_to_targets_table.rb +48 -0
- data/lib/ronin/database/migrations/add_updated_at_column_to_campaigns_table.rb +47 -0
- data/lib/ronin/database/migrations/create_licenses_table.rb +1 -1
- data/lib/ronin/database/migrations/create_passwords_table.rb +1 -1
- data/lib/ronin/database/migrations/{create_cached_files_table.rb → create_script_paths_table.rb} +4 -4
- data/lib/ronin/database/migrations/migration.rb +3 -6
- data/lib/ronin/database/migrations/migrations.rb +3 -3
- data/lib/ronin/email_address.rb +20 -3
- data/lib/ronin/environment.rb +0 -3
- data/lib/ronin/host_name.rb +20 -6
- data/lib/ronin/host_name_ip_address.rb +2 -3
- data/lib/ronin/installation.rb +92 -23
- data/lib/ronin/ip_address.rb +31 -8
- data/lib/ronin/ip_address_mac_address.rb +2 -3
- data/lib/ronin/license.rb +1 -1
- data/lib/ronin/mac_address.rb +6 -4
- data/lib/ronin/model/class_methods.rb +4 -0
- data/lib/ronin/model/has_authors/class_methods.rb +4 -0
- data/lib/ronin/model/has_authors/has_authors.rb +4 -0
- data/lib/ronin/model/has_description/class_methods.rb +2 -0
- data/lib/ronin/model/has_description/has_description.rb +2 -0
- data/lib/ronin/model/has_license/class_methods.rb +2 -0
- data/lib/ronin/model/has_license/has_license.rb +4 -0
- data/lib/ronin/model/has_name/class_methods.rb +2 -0
- data/lib/ronin/model/has_name/has_name.rb +4 -0
- data/lib/ronin/model/has_title/class_methods.rb +2 -0
- data/lib/ronin/model/has_title/has_title.rb +2 -0
- data/lib/ronin/model/has_unique_name/class_methods.rb +2 -0
- data/lib/ronin/model/has_unique_name/has_unique_name.rb +7 -1
- data/lib/ronin/model/has_version/class_methods.rb +4 -0
- data/lib/ronin/model/has_version/has_version.rb +2 -0
- data/lib/ronin/model/model.rb +2 -0
- data/lib/ronin/model/types.rb +1 -7
- data/lib/ronin/model/types/description.rb +2 -0
- data/lib/ronin/network/mixins/esmtp.rb +40 -25
- data/lib/ronin/network/mixins/http.rb +336 -73
- data/lib/ronin/network/mixins/imap.rb +38 -25
- data/lib/ronin/network/mixins/pop3.rb +34 -21
- data/lib/ronin/network/mixins/smtp.rb +40 -25
- data/lib/ronin/network/mixins/tcp.rb +66 -41
- data/lib/ronin/network/mixins/telnet.rb +43 -30
- data/lib/ronin/network/mixins/udp.rb +59 -40
- data/lib/ronin/open_port.rb +12 -5
- data/lib/ronin/organization.rb +1 -2
- data/lib/ronin/os.rb +10 -3
- data/lib/ronin/os_guess.rb +2 -3
- data/lib/ronin/password.rb +11 -3
- data/lib/ronin/port.rb +7 -2
- data/lib/ronin/{engine/exceptions/deploy_failed.rb → repositories.rb} +4 -6
- data/lib/ronin/repository.rb +110 -37
- data/lib/ronin/ronin.rb +4 -3
- data/lib/ronin/{engine.rb → script.rb} +2 -1
- data/lib/ronin/{engine → script}/buildable.rb +43 -29
- data/lib/ronin/script/class_methods.rb +84 -0
- data/lib/ronin/{engine → script}/deployable.rb +61 -40
- data/lib/ronin/{engine → script}/exceptions.rb +4 -3
- data/lib/ronin/script/exceptions/deploy_failed.rb +27 -0
- data/lib/ronin/{engine/exceptions/not_built.rb → script/exceptions/exception.rb} +2 -2
- data/lib/ronin/{engine/exceptions/verification_failed.rb → script/exceptions/not_built.rb} +4 -2
- data/lib/ronin/script/exceptions/test_failed.rb +27 -0
- data/lib/ronin/script/instance_methods.rb +217 -0
- data/lib/ronin/script/path.rb +277 -0
- data/lib/ronin/{engine/engine.rb → script/script.rb} +52 -15
- data/lib/ronin/{engine/verifiable.rb → script/testable.rb} +97 -68
- data/lib/ronin/service.rb +1 -2
- data/lib/ronin/service_credential.rb +1 -2
- data/lib/ronin/software.rb +3 -2
- data/lib/ronin/spec/database.rb +0 -4
- data/lib/ronin/target.rb +11 -3
- data/lib/ronin/tcp_port.rb +3 -2
- data/lib/ronin/udp_port.rb +2 -0
- data/lib/ronin/ui/cli/cli.rb +6 -0
- data/lib/ronin/ui/cli/command.rb +48 -12
- data/lib/ronin/ui/cli/commands/campaigns.rb +3 -3
- data/lib/ronin/ui/cli/commands/console.rb +2 -1
- data/lib/ronin/ui/cli/commands/creds.rb +3 -3
- data/lib/ronin/ui/cli/commands/database.rb +1 -17
- data/lib/ronin/ui/cli/commands/emails.rb +3 -3
- data/lib/ronin/ui/cli/commands/hosts.rb +3 -7
- data/lib/ronin/ui/cli/commands/ips.rb +3 -7
- data/lib/ronin/ui/cli/commands/repos.rb +5 -17
- data/lib/ronin/ui/cli/commands/urls.rb +3 -3
- data/lib/ronin/ui/cli/model_command.rb +82 -97
- data/lib/ronin/ui/cli/resources_command.rb +89 -0
- data/lib/ronin/ui/cli/script_command.rb +115 -0
- data/lib/ronin/ui/console.rb +17 -3
- data/lib/ronin/ui/output/helpers.rb +18 -0
- data/lib/ronin/ui/output/output.rb +20 -1
- data/lib/ronin/ui/output/terminal/color.rb +10 -0
- data/lib/ronin/ui/output/terminal/raw.rb +10 -0
- data/lib/ronin/ui/shell.rb +2 -0
- data/lib/ronin/url.rb +47 -12
- data/lib/ronin/url_query_param.rb +4 -0
- data/lib/ronin/url_scheme.rb +3 -3
- data/lib/ronin/user_name.rb +2 -0
- data/lib/ronin/version.rb +1 -1
- data/lib/ronin/web_credential.rb +6 -3
- data/spec/arch_spec.rb +3 -3
- data/spec/classes/my_script.rb +21 -0
- data/spec/helpers/repos/{test1 → installed}/ronin.yml +1 -1
- data/spec/helpers/repos/{hello/cache → installed/scripts}/.keep +0 -0
- data/spec/helpers/repos/local/lib/init.rb +1 -0
- data/spec/helpers/repos/{hello → local}/lib/stuff/another_test.rb +0 -0
- data/spec/helpers/repos/{hello → local}/lib/stuff/test.rb +0 -0
- data/spec/helpers/repos/{random → local}/ronin.yml +1 -1
- data/spec/helpers/repos/{random/cache → local/scripts}/.keep +0 -0
- data/spec/helpers/repos/{hello → remote}/ronin.yml +1 -1
- data/spec/helpers/repos/remote/scripts/.keep +0 -0
- data/spec/helpers/repos/{test2 → scripts}/ronin.yml +0 -0
- data/spec/helpers/repos/scripts/scripts/cached/cached.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/missing.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/modified.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/cached/unmodified.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/failures/exceptions.rb +11 -0
- data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/load_errors.rb +3 -1
- data/spec/helpers/repos/{test2/cache/cacheable_model → scripts/scripts/failures}/name_errors.rb +1 -0
- data/spec/helpers/repos/scripts/scripts/failures/no_method_errors.rb +10 -0
- data/spec/helpers/repos/scripts/scripts/failures/syntax_errors.rb +11 -0
- data/spec/helpers/repos/scripts/scripts/failures/validation_errors.rb +11 -0
- data/spec/helpers/repos/scripts/scripts/my_scripts/test.rb +16 -0
- data/spec/model/spec_helper.rb +0 -2
- data/spec/repository_spec.rb +61 -81
- data/spec/ronin_spec.rb +2 -2
- data/spec/{engine → script}/buildable_spec.rb +9 -9
- data/spec/script/classes/buildable_class.rb +15 -0
- data/spec/script/classes/deployable_class.rb +13 -0
- data/spec/{engine/classes/engine_class.rb → script/classes/script_class.rb} +3 -3
- data/spec/{engine/classes/verifiable_class.rb → script/classes/testable_class.rb} +5 -5
- data/spec/{engine → script}/deployable_spec.rb +10 -10
- data/spec/{cached_file_spec.rb → script/path_spec.rb} +33 -72
- data/spec/script/script_spec.rb +130 -0
- data/spec/script/testable_spec.rb +117 -0
- data/spec/spec_helper.rb +15 -13
- metadata +114 -139
- data/lib/ronin/cached_file.rb +0 -247
- data/lib/ronin/engine/class_methods.rb +0 -135
- data/lib/ronin/engine/instance_methods.rb +0 -97
- data/lib/ronin/model/cacheable.rb +0 -21
- data/lib/ronin/model/cacheable/cacheable.rb +0 -273
- data/lib/ronin/model/cacheable/class_methods.rb +0 -60
- data/lib/ronin/ui/cli/engine_command.rb +0 -106
- data/spec/engine/classes/buildable_class.rb +0 -15
- data/spec/engine/classes/deployable_class.rb +0 -13
- data/spec/engine/engine_spec.rb +0 -55
- data/spec/engine/verifiable_spec.rb +0 -117
- data/spec/helpers/repos/hello/lib/init.rb +0 -1
- data/spec/helpers/repos/test1/cache/cacheable_model/one.rb +0 -15
- data/spec/helpers/repos/test2/cache/cacheable_model/exceptions.rb +0 -7
- data/spec/helpers/repos/test2/cache/cacheable_model/no_method_errors.rb +0 -9
- data/spec/helpers/repos/test2/cache/cacheable_model/syntax_errors.rb +0 -7
- data/spec/helpers/repos/test2/cache/cacheable_model/two.rb +0 -15
- data/spec/helpers/repos/test2/cache/cacheable_model/validation_errors.rb +0 -9
- data/spec/model/cacheable_spec.rb +0 -96
- data/spec/model/models/cacheable_model.rb +0 -13
@@ -17,66 +17,103 @@
|
|
17
17
|
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'ronin/
|
21
|
-
require 'ronin/
|
20
|
+
require 'ronin/script/instance_methods'
|
21
|
+
require 'ronin/script/class_methods'
|
22
|
+
require 'ronin/script/path'
|
22
23
|
require 'ronin/model/model'
|
23
24
|
require 'ronin/model/has_name'
|
24
25
|
require 'ronin/model/has_description'
|
25
26
|
require 'ronin/model/has_version'
|
26
27
|
require 'ronin/model/has_license'
|
27
28
|
require 'ronin/model/has_authors'
|
28
|
-
require 'ronin/model/cacheable'
|
29
29
|
require 'ronin/ui/output/helpers'
|
30
30
|
|
31
|
+
require 'object_loader'
|
32
|
+
require 'data_paths/finders'
|
31
33
|
require 'parameters'
|
32
34
|
|
33
35
|
module Ronin
|
34
|
-
|
36
|
+
#
|
37
|
+
# @since 1.1.0
|
38
|
+
#
|
39
|
+
module Script
|
35
40
|
include UI::Output::Helpers
|
36
41
|
|
37
42
|
#
|
38
43
|
# Adds the following to the Class.
|
39
44
|
#
|
40
|
-
# * {
|
45
|
+
# * {Script::InstanceMethods}
|
41
46
|
# * {Model}
|
42
47
|
# * {Model::HasName}
|
43
48
|
# * {Model::HasDescription}
|
44
49
|
# * {Model::HasVersion}
|
45
50
|
# * {Model::HasLicense}
|
46
51
|
# * {Model::HasAuthors}
|
47
|
-
# *
|
52
|
+
# * [ObjectLoader](http://rubydoc.info/gems/object_loader)
|
53
|
+
# * [DataPaths::Finders](http://rubydoc.info/gems/data_paths)
|
48
54
|
# * [Parameters](http://rubydoc.info/gems/parameters)
|
49
55
|
# * {ClassMethods}
|
50
56
|
#
|
57
|
+
# @api semipublic
|
58
|
+
#
|
51
59
|
def self.included(base)
|
52
|
-
base.send :include,
|
60
|
+
base.send :include, InstanceMethods,
|
53
61
|
Model,
|
54
62
|
Model::HasName,
|
55
63
|
Model::HasDescription,
|
56
64
|
Model::HasVersion,
|
57
65
|
Model::HasLicense,
|
58
66
|
Model::HasAuthors,
|
59
|
-
|
67
|
+
ObjectLoader,
|
68
|
+
DataPaths::Finders,
|
60
69
|
Parameters
|
61
70
|
|
62
71
|
base.send :extend, ClassMethods
|
72
|
+
|
73
|
+
base.module_eval do
|
74
|
+
# The class-name of the cached object
|
75
|
+
property :type, DataMapper::Property::Discriminator
|
76
|
+
|
77
|
+
# The cached file of the object
|
78
|
+
belongs_to :script_path, Ronin::Script::Path, :required => false
|
79
|
+
end
|
80
|
+
|
81
|
+
Path.has 1, base.relationship_name, base, :child_key => [:script_path_id]
|
63
82
|
end
|
64
83
|
|
65
84
|
#
|
66
|
-
# Loads a
|
85
|
+
# Loads a script from a file.
|
67
86
|
#
|
68
87
|
# @param [String] path
|
69
88
|
# The path to the file.
|
70
89
|
#
|
71
|
-
# @return [
|
72
|
-
# The loaded
|
90
|
+
# @return [Script]
|
91
|
+
# The loaded script.
|
73
92
|
#
|
74
|
-
# @see
|
93
|
+
# @see Cacheable.load_from
|
75
94
|
#
|
76
|
-
# @since 1.
|
95
|
+
# @since 1.1.0
|
77
96
|
#
|
78
|
-
|
79
|
-
|
97
|
+
# @api public
|
98
|
+
#
|
99
|
+
def Script.load_from(path)
|
100
|
+
path = File.expand_path(path)
|
101
|
+
script = ObjectLoader.load_objects(path).find do |obj|
|
102
|
+
obj.class < Script
|
103
|
+
end
|
104
|
+
|
105
|
+
unless script
|
106
|
+
raise("No cacheable object defined in #{path.dump}")
|
107
|
+
end
|
108
|
+
|
109
|
+
script.instance_variable_set('@script_loaded',true)
|
110
|
+
script.script_path = Path.new(
|
111
|
+
:path => path,
|
112
|
+
:timestamp => File.mtime(path),
|
113
|
+
:class_name => script.class.to_s
|
114
|
+
)
|
115
|
+
|
116
|
+
return script
|
80
117
|
end
|
81
118
|
end
|
82
119
|
end
|
@@ -17,82 +17,95 @@
|
|
17
17
|
# along with Ronin. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
#
|
19
19
|
|
20
|
-
require 'ronin/
|
20
|
+
require 'ronin/script/exceptions/test_failed'
|
21
|
+
require 'ronin/ui/output/helpers'
|
21
22
|
|
22
23
|
module Ronin
|
23
|
-
module
|
24
|
+
module Script
|
24
25
|
#
|
25
|
-
# Adds
|
26
|
+
# Adds testing methods to an {Script}.
|
26
27
|
#
|
27
|
-
|
28
|
+
# @since 1.1.0
|
29
|
+
#
|
30
|
+
module Testable
|
31
|
+
include UI::Output::Helpers
|
32
|
+
|
28
33
|
#
|
29
|
-
# Initializes the
|
34
|
+
# Initializes the testable script.
|
30
35
|
#
|
31
36
|
# @param [Hash] attributes
|
32
|
-
# Additional attributes for the
|
37
|
+
# Additional attributes for the script.
|
33
38
|
#
|
34
|
-
# @since 1.
|
39
|
+
# @since 1.1.0
|
40
|
+
#
|
41
|
+
# @api semipublic
|
35
42
|
#
|
36
43
|
def initialize(attributes={})
|
37
44
|
super(attributes)
|
38
45
|
|
39
|
-
@
|
46
|
+
@test_blocks = []
|
40
47
|
end
|
41
48
|
|
42
49
|
#
|
43
|
-
#
|
50
|
+
# Tests that the script is properly configured.
|
44
51
|
#
|
45
52
|
# @return [true]
|
46
53
|
# The exploit is built and ready for deployment.
|
47
54
|
#
|
48
|
-
# @see
|
55
|
+
# @see test
|
56
|
+
#
|
57
|
+
# @since 1.1.0
|
49
58
|
#
|
50
|
-
# @
|
59
|
+
# @api semipublic
|
51
60
|
#
|
52
|
-
def
|
53
|
-
print_info "
|
61
|
+
def test!
|
62
|
+
print_info "Testing #{script_type} ..."
|
54
63
|
|
55
|
-
@
|
64
|
+
@test_blocks.each { |block| block.call() }
|
56
65
|
|
57
|
-
print_info "#{
|
66
|
+
print_info "#{script_type} tested!"
|
58
67
|
return true
|
59
68
|
end
|
60
69
|
|
61
70
|
protected
|
62
71
|
|
63
72
|
#
|
64
|
-
# Flunks the
|
73
|
+
# Flunks the testing process.
|
65
74
|
#
|
66
75
|
# @param [String] message
|
67
|
-
# The message on why the
|
76
|
+
# The message on why the testing failed.
|
68
77
|
#
|
69
|
-
# @raise [
|
70
|
-
# The
|
78
|
+
# @raise [TestFailed]
|
79
|
+
# The testing failure message.
|
71
80
|
#
|
72
|
-
# @since 1.
|
81
|
+
# @since 1.1.0
|
82
|
+
#
|
83
|
+
# @api public
|
73
84
|
#
|
74
85
|
def flunk(message)
|
75
|
-
raise(
|
86
|
+
raise(TestFailed,message)
|
76
87
|
end
|
77
88
|
|
78
89
|
#
|
79
|
-
# Registers a given block to be called when the
|
90
|
+
# Registers a given block to be called when the script is tested.
|
80
91
|
#
|
81
92
|
# @yield []
|
82
|
-
# The given block will be called when the
|
93
|
+
# The given block will be called when the script is being tested.
|
94
|
+
#
|
95
|
+
# @return [Script]
|
96
|
+
# The script.
|
83
97
|
#
|
84
|
-
# @
|
85
|
-
# The engine.
|
98
|
+
# @since 1.1.0
|
86
99
|
#
|
87
|
-
# @
|
100
|
+
# @api public
|
88
101
|
#
|
89
|
-
def
|
90
|
-
@
|
102
|
+
def test(&block)
|
103
|
+
@test_blocks << block
|
91
104
|
return self
|
92
105
|
end
|
93
106
|
|
94
107
|
#
|
95
|
-
#
|
108
|
+
# Tests whether an expression is true.
|
96
109
|
#
|
97
110
|
# @param [String] message
|
98
111
|
# The failure message if the expression was not true.
|
@@ -103,17 +116,19 @@ module Ronin
|
|
103
116
|
# @return [true]
|
104
117
|
# The expression was true.
|
105
118
|
#
|
106
|
-
# @raise [
|
119
|
+
# @raise [TestFailed]
|
107
120
|
# The expression was not true.
|
108
121
|
#
|
109
|
-
# @since 1.
|
122
|
+
# @since 1.1.0
|
123
|
+
#
|
124
|
+
# @api public
|
110
125
|
#
|
111
|
-
def
|
112
|
-
|
126
|
+
def test?(message,&block)
|
127
|
+
test { flunk(message) unless block.call() }
|
113
128
|
end
|
114
129
|
|
115
130
|
#
|
116
|
-
#
|
131
|
+
# Tests whether a method has the expected value.
|
117
132
|
#
|
118
133
|
# @param [Symbol] name
|
119
134
|
# The method to call.
|
@@ -127,15 +142,17 @@ module Ronin
|
|
127
142
|
# @return [true]
|
128
143
|
# The method returned the expected value.
|
129
144
|
#
|
130
|
-
# @raise [
|
145
|
+
# @raise [TestFailed]
|
131
146
|
# The method did not return the expected value.
|
132
147
|
#
|
133
|
-
# @since 1.
|
148
|
+
# @since 1.1.0
|
134
149
|
#
|
135
|
-
|
150
|
+
# @api public
|
151
|
+
#
|
152
|
+
def test_equal(name,expected_value,message=nil)
|
136
153
|
name = name.to_sym
|
137
154
|
|
138
|
-
|
155
|
+
test do
|
139
156
|
actual_value = self.send(name)
|
140
157
|
message ||= "#{name} (#{actual_value.inspect}) must equal #{expected_value.inspect}"
|
141
158
|
|
@@ -144,7 +161,7 @@ module Ronin
|
|
144
161
|
end
|
145
162
|
|
146
163
|
#
|
147
|
-
#
|
164
|
+
# Tests whether a method does not have the unexpected value.
|
148
165
|
#
|
149
166
|
# @param [Symbol] name
|
150
167
|
# The method to call.
|
@@ -158,15 +175,17 @@ module Ronin
|
|
158
175
|
# @return [true]
|
159
176
|
# The method did not return the unexpected value.
|
160
177
|
#
|
161
|
-
# @raise [
|
178
|
+
# @raise [TestFailed]
|
162
179
|
# The method did return the unexpected value.
|
163
180
|
#
|
164
|
-
# @since 1.
|
181
|
+
# @since 1.1.0
|
182
|
+
#
|
183
|
+
# @api public
|
165
184
|
#
|
166
|
-
def
|
185
|
+
def test_not_equal(name,unexpected_value,message=nil)
|
167
186
|
name = name.to_sym
|
168
187
|
|
169
|
-
|
188
|
+
test do
|
170
189
|
actual_value = self.send(name)
|
171
190
|
message ||= "#{name} (#{actual_value.inspect}) cannot equal #{unexpected_value.inspect}"
|
172
191
|
|
@@ -175,7 +194,7 @@ module Ronin
|
|
175
194
|
end
|
176
195
|
|
177
196
|
#
|
178
|
-
#
|
197
|
+
# Tests whether a method returns a non-`nil` value.
|
179
198
|
#
|
180
199
|
# @param [Symbol] name
|
181
200
|
# The method to call.
|
@@ -186,15 +205,17 @@ module Ronin
|
|
186
205
|
# @return [true]
|
187
206
|
# The method returned a non-`nil` value.
|
188
207
|
#
|
189
|
-
# @raise [
|
208
|
+
# @raise [TestFailed]
|
190
209
|
# The method returned `nil`.
|
191
210
|
#
|
192
|
-
# @since 1.
|
211
|
+
# @since 1.1.0
|
193
212
|
#
|
194
|
-
|
213
|
+
# @api public
|
214
|
+
#
|
215
|
+
def test_set(name,message=nil)
|
195
216
|
name = name.to_sym
|
196
217
|
|
197
|
-
|
218
|
+
test do
|
198
219
|
actual_value = self.send(name)
|
199
220
|
message ||= "#{name} is not set"
|
200
221
|
|
@@ -209,7 +230,7 @@ module Ronin
|
|
209
230
|
end
|
210
231
|
|
211
232
|
#
|
212
|
-
#
|
233
|
+
# Tests whether a method matches the pattern.
|
213
234
|
#
|
214
235
|
# @param [Symbol] name
|
215
236
|
# The method to call.
|
@@ -223,15 +244,17 @@ module Ronin
|
|
223
244
|
# @return [true]
|
224
245
|
# The method matched the pattern.
|
225
246
|
#
|
226
|
-
# @raise [
|
247
|
+
# @raise [TestFailed]
|
227
248
|
# The method did not match the pattern.
|
228
249
|
#
|
229
|
-
# @since 1.
|
250
|
+
# @since 1.1.0
|
251
|
+
#
|
252
|
+
# @api public
|
230
253
|
#
|
231
|
-
def
|
254
|
+
def test_match(name,pattern,message=nil)
|
232
255
|
name = name.to_sym
|
233
256
|
|
234
|
-
|
257
|
+
test do
|
235
258
|
actual_value = self.send(name)
|
236
259
|
message ||= "#{name} (#{actual_value.inspect}) must match #{pattern.inspect}"
|
237
260
|
|
@@ -240,7 +263,7 @@ module Ronin
|
|
240
263
|
end
|
241
264
|
|
242
265
|
#
|
243
|
-
#
|
266
|
+
# Tests whether a method does not matches the pattern.
|
244
267
|
#
|
245
268
|
# @param [Symbol] name
|
246
269
|
# The method to call.
|
@@ -254,15 +277,17 @@ module Ronin
|
|
254
277
|
# @return [true]
|
255
278
|
# The method matched the pattern.
|
256
279
|
#
|
257
|
-
# @raise [
|
280
|
+
# @raise [TestFailed]
|
258
281
|
# The method did not match the pattern.
|
259
282
|
#
|
260
|
-
# @since 1.
|
283
|
+
# @since 1.1.0
|
261
284
|
#
|
262
|
-
|
285
|
+
# @api public
|
286
|
+
#
|
287
|
+
def test_no_match(name,pattern,message=nil)
|
263
288
|
name = name.to_sym
|
264
289
|
|
265
|
-
|
290
|
+
test do
|
266
291
|
actual_value = self.send(name)
|
267
292
|
message ||= "#{name} (#{actual_value.inspect}) cannot match #{pattern.inspect}"
|
268
293
|
|
@@ -271,7 +296,7 @@ module Ronin
|
|
271
296
|
end
|
272
297
|
|
273
298
|
#
|
274
|
-
#
|
299
|
+
# Tests a method has a value in the expected values.
|
275
300
|
#
|
276
301
|
# @param [Symbol] name
|
277
302
|
# The method name.
|
@@ -285,15 +310,17 @@ module Ronin
|
|
285
310
|
# @return [true]
|
286
311
|
# The method returned one of the expected values.
|
287
312
|
#
|
288
|
-
# @raise [
|
313
|
+
# @raise [TestFailed]
|
289
314
|
# The method did not return one of the expected values.
|
290
315
|
#
|
291
|
-
# @since 1.
|
316
|
+
# @since 1.1.0
|
317
|
+
#
|
318
|
+
# @api public
|
292
319
|
#
|
293
|
-
def
|
320
|
+
def test_in(name,expected_values,message=nil)
|
294
321
|
name = name.to_sym
|
295
322
|
|
296
|
-
|
323
|
+
test do
|
297
324
|
actual_value = self.send(name)
|
298
325
|
message ||= "#{name} (#{actual_value.inspect}) must be one of #{expected_values.inspect}"
|
299
326
|
|
@@ -302,7 +329,7 @@ module Ronin
|
|
302
329
|
end
|
303
330
|
|
304
331
|
#
|
305
|
-
#
|
332
|
+
# Tests a method does not have a value in the unexpected values.
|
306
333
|
#
|
307
334
|
# @param [Symbol] name
|
308
335
|
# The method name.
|
@@ -316,15 +343,17 @@ module Ronin
|
|
316
343
|
# @return [true]
|
317
344
|
# The method did not return one of the unexpected values.
|
318
345
|
#
|
319
|
-
# @raise [
|
346
|
+
# @raise [TestFailed]
|
320
347
|
# The method did return one of the unexpected values.
|
321
348
|
#
|
322
|
-
# @since 1.
|
349
|
+
# @since 1.1.0
|
350
|
+
#
|
351
|
+
# @api public
|
323
352
|
#
|
324
|
-
def
|
353
|
+
def test_not_in(name,unexpected_values,message=nil)
|
325
354
|
name = name.to_sym
|
326
355
|
|
327
|
-
|
356
|
+
test do
|
328
357
|
actual_value = self.send(name)
|
329
358
|
message ||= "#{name} (#{actual_value.inspect}) cannot be one of #{unexpected_values.inspect}"
|
330
359
|
|