esp_sdk 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +4 -1
- data/Rakefile +12 -1
- data/lib/esp/extensions/active_resource/formats/json_api_format.rb +1 -1
- data/lib/esp/extensions/active_resource/validations.rb +3 -2
- data/lib/esp/external_account_creator.rb +2 -2
- data/lib/esp/resources/custom_signature.rb +7 -0
- data/lib/esp/resources/report.rb +1 -1
- data/lib/esp/resources/reports/export/integration.rb +44 -0
- data/lib/esp/resources/team.rb +6 -0
- data/lib/esp/version.rb +1 -1
- data/lib/esp.rb +5 -0
- data/test/esp/extensions/active_resource/formats/json_api_format_test.rb +0 -67
- data/test/esp/extensions/active_resource/paginated_collection_test.rb +0 -69
- data/test/esp/extensions/active_resource/validations_test.rb +0 -20
- data/test/esp/integration/alert_integration_test.rb +96 -0
- data/test/esp/integration/cloud_trail_event_integration_test.rb +18 -0
- data/test/esp/integration/contact_request_integration_test.rb +21 -0
- data/test/esp/integration/custom_signature_integration_test.rb +97 -0
- data/test/esp/integration/dashboard_integration_test.rb +17 -0
- data/test/esp/integration/external_account_integration_test.rb +68 -0
- data/test/esp/integration/json_api_format_integration_test.rb +61 -0
- data/test/esp/integration/metadata_integration_test.rb +18 -0
- data/test/esp/integration/organization_integration_test.rb +81 -0
- data/test/esp/integration/paginated_collection_integration_test.rb +67 -0
- data/test/esp/integration/region_integration_test.rb +32 -0
- data/test/esp/integration/report_export_integration_integration_test.rb +24 -0
- data/test/esp/integration/report_integration_test.rb +71 -0
- data/test/esp/integration/resource_integration_test.rb +54 -0
- data/test/esp/integration/scan_interval_integration_test.rb +49 -0
- data/test/esp/integration/service_integration_test.rb +28 -0
- data/test/esp/integration/signature_integration_test.rb +62 -0
- data/test/esp/integration/stat_custom_signature_integration_test.rb +22 -0
- data/test/esp/integration/stat_integration_test.rb +69 -0
- data/test/esp/integration/stat_region_integration_test.rb +36 -0
- data/test/esp/integration/stat_service_integration_test.rb +36 -0
- data/test/esp/integration/stat_signature_integration_test.rb +36 -0
- data/test/esp/integration/sub_organization_integration_test.rb +79 -0
- data/test/esp/integration/suppression_integration_test.rb +95 -0
- data/test/esp/integration/suppression_region_integration_test.rb +52 -0
- data/test/esp/integration/suppression_signature_integration_test.rb +52 -0
- data/test/esp/integration/suppression_unique_identifier_integration_test.rb +30 -0
- data/test/esp/integration/tag_integration_test.rb +18 -0
- data/test/esp/integration/team_integration_test.rb +87 -0
- data/test/esp/integration/user_integration_test.rb +52 -0
- data/test/esp/integration/validations_integration_test.rb +18 -0
- data/test/esp/resources/alert_test.rb +0 -93
- data/test/esp/resources/cloud_trail_event_test.rb +0 -20
- data/test/esp/resources/contact_request_test.rb +0 -23
- data/test/esp/resources/custom_signature_test.rb +14 -85
- data/test/esp/resources/dashboard_test.rb +0 -19
- data/test/esp/resources/external_account_test.rb +0 -67
- data/test/esp/resources/metadata_test.rb +0 -20
- data/test/esp/resources/organization_test.rb +0 -80
- data/test/esp/resources/region_test.rb +0 -31
- data/test/esp/resources/report_test.rb +0 -70
- data/test/esp/resources/reports/export/integration_test.rb +55 -0
- data/test/esp/resources/resource_test.rb +0 -53
- data/test/esp/resources/scan_interval_test.rb +0 -50
- data/test/esp/resources/service_test.rb +0 -27
- data/test/esp/resources/signature_test.rb +0 -60
- data/test/esp/resources/stat_custom_signature_test.rb +0 -22
- data/test/esp/resources/stat_region_test.rb +1 -36
- data/test/esp/resources/stat_service_test.rb +1 -36
- data/test/esp/resources/stat_signature_test.rb +0 -36
- data/test/esp/resources/stat_test.rb +0 -68
- data/test/esp/resources/sub_organization_test.rb +0 -78
- data/test/esp/resources/suppression/region_test.rb +0 -50
- data/test/esp/resources/suppression/signature_test.rb +0 -50
- data/test/esp/resources/suppression/unique_identifier_test.rb +0 -30
- data/test/esp/resources/suppression_test.rb +0 -94
- data/test/esp/resources/tag_test.rb +0 -20
- data/test/esp/resources/team_test.rb +14 -78
- data/test/esp/resources/user_test.rb +0 -47
- data/test/factories/custom_signatures.rb +17 -7
- data/test/factories/teams.rb +18 -8
- data/test/parallel_reporter.rb +93 -0
- data/test/test_helper.rb +20 -4
- metadata +70 -3
@@ -51,36 +51,6 @@ module ESP
|
|
51
51
|
assert_equal ESP::Suppression::UniqueIdentifier, suppression.class
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
context 'live calls' do
|
56
|
-
setup do
|
57
|
-
skip "Make sure you run the live calls locally to ensure proper integration" if ENV['CI_SERVER']
|
58
|
-
WebMock.allow_net_connect!
|
59
|
-
end
|
60
|
-
|
61
|
-
teardown do
|
62
|
-
WebMock.disable_net_connect!
|
63
|
-
end
|
64
|
-
|
65
|
-
context '.create' do
|
66
|
-
should 'return error when reason is not supplied' do
|
67
|
-
alert_id = ESP::Report.all.detect { |r| r.status == 'complete' }.alerts.last.id
|
68
|
-
|
69
|
-
suppression = ESP::Suppression::UniqueIdentifier.create(alert_id: alert_id)
|
70
|
-
|
71
|
-
assert_equal "Reason can't be blank", suppression.errors.full_messages.first
|
72
|
-
end
|
73
|
-
|
74
|
-
should 'return suppression' do
|
75
|
-
alert_id = ESP::Report.all.detect { |r| r.status == 'complete' }.alerts.last.id
|
76
|
-
|
77
|
-
suppression = ESP::Suppression::UniqueIdentifier.create(alert_id: alert_id, reason: 'test')
|
78
|
-
|
79
|
-
assert_predicate suppression.errors, :blank?
|
80
|
-
assert_equal ESP::Suppression::UniqueIdentifier, suppression.class
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
54
|
end
|
85
55
|
end
|
86
56
|
end
|
@@ -187,100 +187,6 @@ module ESP
|
|
187
187
|
assert_equal "Failed. Response code = 400. Response message = #{JSON.parse(error_response)['errors'].first['title']}.", error.message
|
188
188
|
end
|
189
189
|
end
|
190
|
-
|
191
|
-
context 'live calls' do
|
192
|
-
setup do
|
193
|
-
skip "Make sure you run the live calls locally to ensure proper integration" if ENV['CI_SERVER']
|
194
|
-
WebMock.allow_net_connect!
|
195
|
-
@s = ESP::Suppression.first
|
196
|
-
skip "Live DB does not have any suppressions. Add a suppression and run tests again." if @s.blank?
|
197
|
-
end
|
198
|
-
|
199
|
-
teardown do
|
200
|
-
WebMock.disable_net_connect!
|
201
|
-
end
|
202
|
-
|
203
|
-
context '#organization' do
|
204
|
-
should 'return an organization' do
|
205
|
-
org = @s.organization
|
206
|
-
|
207
|
-
assert_equal @s.organization_id, org.id
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
context '#created_by' do
|
212
|
-
should 'return a user' do
|
213
|
-
u = @s.created_by
|
214
|
-
|
215
|
-
assert_equal @s.created_by_id, u.id
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
context '#regions' do
|
220
|
-
should 'return regions' do
|
221
|
-
r = @s.regions
|
222
|
-
|
223
|
-
assert_equal ESP::Region, r.resource_class unless r == []
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
context '#external_accounts' do
|
228
|
-
should 'return external_accounts' do
|
229
|
-
e = @s.external_accounts
|
230
|
-
|
231
|
-
assert_equal ESP::ExternalAccount, e.resource_class
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
context '#signatures' do
|
236
|
-
should 'return signatures' do
|
237
|
-
s = @s.signatures
|
238
|
-
|
239
|
-
assert_equal ESP::Signature, s.resource_class unless s == []
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
context '#custom_signatures' do
|
244
|
-
should 'return custom_signatures' do
|
245
|
-
cs = @s.custom_signatures
|
246
|
-
|
247
|
-
assert_equal ESP::CustomSignature, cs.resource_class unless cs == []
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
context '#deactivate' do
|
252
|
-
should 'deactivate the suppression' do
|
253
|
-
status = @s.status
|
254
|
-
|
255
|
-
@s.deactivate
|
256
|
-
|
257
|
-
assert_equal 'inactive', @s.status
|
258
|
-
assert_contains @s.errors.full_messages.first, 'Access Denied' if status == 'inactive'
|
259
|
-
end
|
260
|
-
end
|
261
|
-
|
262
|
-
context '#deactivate!' do
|
263
|
-
should 'raise an error if already inactive' do
|
264
|
-
status = @s.status
|
265
|
-
|
266
|
-
if status == 'inactive'
|
267
|
-
assert_raises ActiveResource::ResourceInvalid do
|
268
|
-
@s.deactivate!
|
269
|
-
end
|
270
|
-
assert_equal 'inactive', @s.status
|
271
|
-
assert_contains @s.errors.full_messages.first, 'Access Denied' if status == 'inactive'
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
context '.where' do
|
277
|
-
should 'return suppression objects' do
|
278
|
-
suppressions = ESP::Suppression.where(id_eq: @s.id)
|
279
|
-
|
280
|
-
assert_equal ESP::Suppression, suppressions.resource_class
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
284
190
|
end
|
285
191
|
end
|
286
192
|
end
|
@@ -81,26 +81,6 @@ module ESP
|
|
81
81
|
assert_equal ESP::Tag, tags.resource_class
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
85
|
-
context 'live calls' do
|
86
|
-
setup do
|
87
|
-
skip "Make sure you run the live calls locally to ensure proper integration" if ENV['CI_SERVER']
|
88
|
-
WebMock.allow_net_connect!
|
89
|
-
end
|
90
|
-
|
91
|
-
teardown do
|
92
|
-
WebMock.disable_net_connect!
|
93
|
-
end
|
94
|
-
|
95
|
-
context '.for_alert' do
|
96
|
-
should 'return tags for alert id' do
|
97
|
-
report = ESP::Report.all.detect { |r| r.status == 'complete' }
|
98
|
-
events = ESP::Tag.for_alert(report.alerts.last.id)
|
99
|
-
|
100
|
-
assert_equal ESP::Tag, events.resource_class
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
84
|
end
|
105
85
|
end
|
106
86
|
end
|
@@ -38,6 +38,20 @@ module ESP
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
context '#custom_signatures' do
|
42
|
+
should 'call the api' do
|
43
|
+
team = build(:team)
|
44
|
+
stub_request(:put, /custom_signatures.json*/).to_return(body: json_list(:custom_signature, 2))
|
45
|
+
|
46
|
+
team.custom_signatures
|
47
|
+
|
48
|
+
assert_requested(:put, /custom_signatures.json*/) do |req|
|
49
|
+
body = JSON.parse(req.body)
|
50
|
+
assert_equal team.id, body['filter']['teams_id_eq']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
41
55
|
context '#reports' do
|
42
56
|
should 'call the api' do
|
43
57
|
team = build(:team)
|
@@ -65,84 +79,6 @@ module ESP
|
|
65
79
|
end
|
66
80
|
end
|
67
81
|
end
|
68
|
-
|
69
|
-
context 'live calls' do
|
70
|
-
setup do
|
71
|
-
skip "Make sure you run the live calls locally to ensure proper integration" if ENV['CI_SERVER']
|
72
|
-
WebMock.allow_net_connect!
|
73
|
-
@team = ESP::Team.last
|
74
|
-
skip "Live DB does not have any teams. Add a team and run tests again." if @team.blank?
|
75
|
-
end
|
76
|
-
|
77
|
-
teardown do
|
78
|
-
WebMock.disable_net_connect!
|
79
|
-
end
|
80
|
-
|
81
|
-
context '#organization' do
|
82
|
-
should 'return an organization' do
|
83
|
-
org = @team.organization
|
84
|
-
|
85
|
-
assert_equal @team.organization_id, org.id
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context '#sub_organization' do
|
90
|
-
should 'return a sub_organization' do
|
91
|
-
sub_org = @team.sub_organization
|
92
|
-
|
93
|
-
assert_equal @team.sub_organization_id, sub_org.id
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context '#external_accounts' do
|
98
|
-
should 'return an array of external_accounts' do
|
99
|
-
external_accounts = @team.external_accounts
|
100
|
-
|
101
|
-
assert_equal ESP::ExternalAccount, external_accounts.resource_class
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context '#reports' do
|
106
|
-
should 'return an array of reports' do
|
107
|
-
reports = @team.reports
|
108
|
-
|
109
|
-
assert_equal ESP::Report, reports.resource_class
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context '.where' do
|
114
|
-
should 'return team objects' do
|
115
|
-
teams = ESP::Team.where(name_eq: @team.name)
|
116
|
-
|
117
|
-
assert_equal ESP::Team, teams.resource_class
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context '#CRUD' do
|
122
|
-
should 'be able to create, update and destroy' do
|
123
|
-
team = ESP::Team.new(name: 'bob', organization_id: @team.organization_id, sub_organization_id: @team.sub_organization_id)
|
124
|
-
|
125
|
-
assert_predicate team, :new?
|
126
|
-
|
127
|
-
team.save
|
128
|
-
|
129
|
-
refute_predicate team, :new?
|
130
|
-
|
131
|
-
team.name = 'jim'
|
132
|
-
team.save
|
133
|
-
|
134
|
-
assert_nothing_raised do
|
135
|
-
ESP::Team.find(team.id)
|
136
|
-
end
|
137
|
-
|
138
|
-
team.destroy
|
139
|
-
|
140
|
-
assert_raises ActiveResource::ResourceNotFound do
|
141
|
-
ESP::Team.find(team.id)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
82
|
end
|
147
83
|
end
|
148
84
|
end
|
@@ -91,53 +91,6 @@ module ESP
|
|
91
91
|
assert_not_requested(:put, /teams.json*/)
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
95
|
-
context 'live calls' do
|
96
|
-
setup do
|
97
|
-
skip "Make sure you run the live calls locally to ensure proper integration" if ENV['CI_SERVER']
|
98
|
-
WebMock.allow_net_connect!
|
99
|
-
@user = ESP::User.last
|
100
|
-
skip "Live DB does not have any users. Add a user and run tests again." if @user.blank?
|
101
|
-
end
|
102
|
-
|
103
|
-
teardown do
|
104
|
-
WebMock.disable_net_connect!
|
105
|
-
end
|
106
|
-
|
107
|
-
context '#organization' do
|
108
|
-
should 'return an organization' do
|
109
|
-
org = @user.organization
|
110
|
-
|
111
|
-
assert_equal @user.organization_id, org.id
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context '#sub_organizations' do
|
116
|
-
should 'return an array of sub_organizations' do
|
117
|
-
sub_orgs = @user.sub_organizations
|
118
|
-
|
119
|
-
assert_equal @user.sub_organization_ids.count, sub_orgs.count
|
120
|
-
assert_equal @user.sub_organization_ids, sub_orgs.map(&:id)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context '#teams' do
|
125
|
-
should 'return an array of teams' do
|
126
|
-
teams = @user.teams
|
127
|
-
|
128
|
-
assert_equal @user.team_ids.count, teams.count
|
129
|
-
assert_equal @user.team_ids.sort, teams.map(&:id).sort
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context '.where' do
|
134
|
-
should 'return user objects' do
|
135
|
-
users = ESP::User.where(id_eq: @user.id)
|
136
|
-
|
137
|
-
assert_equal ESP::User, users.resource_class
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
94
|
end
|
142
95
|
end
|
143
96
|
end
|
@@ -15,16 +15,26 @@ FactoryGirl.define do
|
|
15
15
|
language "javascript"
|
16
16
|
updated_at nil
|
17
17
|
relationships do
|
18
|
-
{
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
{
|
19
|
+
organization: {
|
20
|
+
data: {
|
21
|
+
type: "organizations",
|
22
|
+
id: "1003"
|
23
|
+
},
|
24
|
+
links: {
|
25
|
+
related: "http://test.host/api/v2/organizations/1003.json"
|
26
|
+
}
|
22
27
|
},
|
23
|
-
|
24
|
-
|
28
|
+
teams: {
|
29
|
+
data: {
|
30
|
+
type: "teams",
|
31
|
+
id: "1003"
|
32
|
+
},
|
33
|
+
links: {
|
34
|
+
related: "http://test.host/api/v2/teams?filter%5Bcustom_signatures_id_eq%5D=#{id}"
|
35
|
+
}
|
25
36
|
}
|
26
37
|
}
|
27
|
-
}
|
28
38
|
end
|
29
39
|
end
|
30
40
|
end
|
data/test/factories/teams.rb
CHANGED
@@ -8,15 +8,16 @@ FactoryGirl.define do
|
|
8
8
|
created_at { Time.current }
|
9
9
|
updated_at { Time.current }
|
10
10
|
relationships do
|
11
|
-
{
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
{
|
12
|
+
sub_organization: {
|
13
|
+
data: {
|
14
|
+
type: "sub_organizations",
|
15
|
+
id: "2"
|
16
|
+
},
|
17
|
+
links: {
|
18
|
+
related: "http://localhost:3000/api/v2/sub_organizations/2.json"
|
19
|
+
}
|
15
20
|
},
|
16
|
-
links: {
|
17
|
-
related: "http://localhost:3000/api/v2/sub_organizations/2.json"
|
18
|
-
}
|
19
|
-
},
|
20
21
|
organization: {
|
21
22
|
data: {
|
22
23
|
type: "organizations",
|
@@ -25,6 +26,15 @@ FactoryGirl.define do
|
|
25
26
|
links: {
|
26
27
|
related: "http://localhost:3000/api/v2/organizations/2.json"
|
27
28
|
}
|
29
|
+
},
|
30
|
+
custom_signatures: {
|
31
|
+
data: {
|
32
|
+
type: "custom_signatures",
|
33
|
+
id: "2"
|
34
|
+
},
|
35
|
+
links: {
|
36
|
+
related: "http://localhost:3000/api/v2/custom_signatures?filter%5Bteam_id_eq%5D=#{id}"
|
37
|
+
}
|
28
38
|
}
|
29
39
|
}
|
30
40
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'ansi/code'
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module Reporters
|
5
|
+
# Features:
|
6
|
+
# Like the SpecReporter but with the pass/time on the left
|
7
|
+
# Collects the message before doing a puts so that lines dont get mixed up when running tests in threads
|
8
|
+
# Highlights lines in a stacktrace from this project
|
9
|
+
# Highlights slow tests
|
10
|
+
class ParallelReporter < BaseReporter
|
11
|
+
# fix coloring for parallel_tests
|
12
|
+
require 'ansi/code'
|
13
|
+
include ::ANSI::Code
|
14
|
+
extend ::ANSI::Code
|
15
|
+
|
16
|
+
include RelativePosition
|
17
|
+
|
18
|
+
def report
|
19
|
+
super
|
20
|
+
msg = "\n"
|
21
|
+
msg += "Finished in #{format('%f', total_time)}s"
|
22
|
+
msg += "\n"
|
23
|
+
msg += "#{format('%d', count)} tests, #{format('%d', assertions)} assertions, "
|
24
|
+
color = failures.zero? && errors.zero? ? :green : :red
|
25
|
+
msg += send(color) { "#{format('%d', failures)} failures, #{format('%d', errors)} errors, " }
|
26
|
+
msg += yellow { "#{format('%d', skips)} skips" }
|
27
|
+
msg += "\n"
|
28
|
+
puts msg
|
29
|
+
end
|
30
|
+
|
31
|
+
def record(test)
|
32
|
+
super
|
33
|
+
if test.passed?
|
34
|
+
print_pass(test)
|
35
|
+
else
|
36
|
+
print_fail(test)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def print_pass(_test)
|
43
|
+
print green '.'
|
44
|
+
end
|
45
|
+
|
46
|
+
def print_fail(test)
|
47
|
+
puts ''
|
48
|
+
msg = ''
|
49
|
+
msg += colored_status(test)
|
50
|
+
msg += color_by_time(" (#{format('%.2f', test.time)}s)", test.time)
|
51
|
+
msg += pad_test(test.name).gsub('test_: ', "[#{blue ENV['TEST_ENV_NUMBER'].to_i}] ")
|
52
|
+
msg += stacktrace(test)
|
53
|
+
puts msg
|
54
|
+
puts ''
|
55
|
+
end
|
56
|
+
|
57
|
+
def color_by_time(string, time)
|
58
|
+
if time > 5
|
59
|
+
red string
|
60
|
+
elsif time > 1
|
61
|
+
yellow string
|
62
|
+
else
|
63
|
+
string
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def colored_status(test)
|
68
|
+
if test.passed?
|
69
|
+
green { pad_mark(result(test).to_s.upcase) }
|
70
|
+
elsif test.skipped?
|
71
|
+
yellow { pad_mark(result(test).to_s.upcase) }
|
72
|
+
else
|
73
|
+
red { pad_mark(result(test).to_s.upcase) }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def stacktrace(test) # rubocop:disable Metrics/MethodLength
|
78
|
+
return '' unless !test.skipped? && test.failure
|
79
|
+
msg = "\n"
|
80
|
+
msg += red(test.failure.message.split("\n ").first.to_s) + "\n"
|
81
|
+
test.failure.backtrace.each do |line|
|
82
|
+
msg += if line.include?('esp_sdk/lib')
|
83
|
+
yellow line
|
84
|
+
else
|
85
|
+
line
|
86
|
+
end
|
87
|
+
msg += "\n"
|
88
|
+
end
|
89
|
+
msg
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
ENV['ESP_ENV'] = 'test'
|
2
|
-
|
3
|
-
|
2
|
+
# Don't run coveralls when esp web runs sdk tests.
|
3
|
+
if ENV['CI_BUILD_STAGE'].to_s.casecmp('test_sdk') != 0
|
4
|
+
require 'coveralls'
|
5
|
+
Coveralls.wear!
|
6
|
+
end
|
4
7
|
|
5
8
|
require 'minitest/autorun'
|
6
9
|
require 'minitest/reporters'
|
@@ -13,11 +16,12 @@ require 'rubygems'
|
|
13
16
|
require 'active_resource'
|
14
17
|
require_relative 'json_strategy'
|
15
18
|
require_relative '../lib/esp_sdk'
|
19
|
+
require_relative 'parallel_reporter'
|
16
20
|
|
17
21
|
FactoryGirl.definition_file_paths = [File.expand_path('factories', File.dirname(__FILE__))]
|
18
22
|
FactoryGirl.find_definitions
|
19
23
|
FactoryGirl.register_strategy(:json, JsonStrategy)
|
20
|
-
Minitest::Reporters.use! Minitest::Reporters::
|
24
|
+
Minitest::Reporters.use! Minitest::Reporters::ParallelReporter.new(color: true)
|
21
25
|
|
22
26
|
class ActiveSupport::TestCase
|
23
27
|
include FactoryGirl::Syntax::Methods # so we can use json(:object) instead of FactoryGirl.json(:object)
|
@@ -33,7 +37,7 @@ class ActiveSupport::TestCase
|
|
33
37
|
def json_list(*args)
|
34
38
|
page_args = args.last.delete(:page) if args.last.present? && args.last.is_a?(Hash)
|
35
39
|
page_args ||= { number: 1, size: 20 }
|
36
|
-
json_array
|
40
|
+
json_array = args.first == :empty ? [] : super
|
37
41
|
data = json_array.map { |j| JSON.parse(j)['data'] }
|
38
42
|
links = build_links(data, page_args)
|
39
43
|
list = { 'data' => data.slice(0, page_args[:size]),
|
@@ -57,3 +61,15 @@ class ActiveSupport::TestCase
|
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
64
|
+
|
65
|
+
module ESP::Integration
|
66
|
+
class TestCase < ActiveSupport::TestCase
|
67
|
+
setup do
|
68
|
+
WebMock.allow_net_connect!
|
69
|
+
end
|
70
|
+
|
71
|
+
teardown do
|
72
|
+
WebMock.disable_net_connect!
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esp_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evident.io
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -336,6 +336,7 @@ files:
|
|
336
336
|
- lib/esp/resources/organization.rb
|
337
337
|
- lib/esp/resources/region.rb
|
338
338
|
- lib/esp/resources/report.rb
|
339
|
+
- lib/esp/resources/reports/export/integration.rb
|
339
340
|
- lib/esp/resources/resource.rb
|
340
341
|
- lib/esp/resources/scan_interval.rb
|
341
342
|
- lib/esp/resources/service.rb
|
@@ -362,6 +363,37 @@ files:
|
|
362
363
|
- test/esp/extensions/active_resource/paginated_collection_test.rb
|
363
364
|
- test/esp/extensions/active_resource/validations_test.rb
|
364
365
|
- test/esp/external_account_creator_test.rb
|
366
|
+
- test/esp/integration/alert_integration_test.rb
|
367
|
+
- test/esp/integration/cloud_trail_event_integration_test.rb
|
368
|
+
- test/esp/integration/contact_request_integration_test.rb
|
369
|
+
- test/esp/integration/custom_signature_integration_test.rb
|
370
|
+
- test/esp/integration/dashboard_integration_test.rb
|
371
|
+
- test/esp/integration/external_account_integration_test.rb
|
372
|
+
- test/esp/integration/json_api_format_integration_test.rb
|
373
|
+
- test/esp/integration/metadata_integration_test.rb
|
374
|
+
- test/esp/integration/organization_integration_test.rb
|
375
|
+
- test/esp/integration/paginated_collection_integration_test.rb
|
376
|
+
- test/esp/integration/region_integration_test.rb
|
377
|
+
- test/esp/integration/report_export_integration_integration_test.rb
|
378
|
+
- test/esp/integration/report_integration_test.rb
|
379
|
+
- test/esp/integration/resource_integration_test.rb
|
380
|
+
- test/esp/integration/scan_interval_integration_test.rb
|
381
|
+
- test/esp/integration/service_integration_test.rb
|
382
|
+
- test/esp/integration/signature_integration_test.rb
|
383
|
+
- test/esp/integration/stat_custom_signature_integration_test.rb
|
384
|
+
- test/esp/integration/stat_integration_test.rb
|
385
|
+
- test/esp/integration/stat_region_integration_test.rb
|
386
|
+
- test/esp/integration/stat_service_integration_test.rb
|
387
|
+
- test/esp/integration/stat_signature_integration_test.rb
|
388
|
+
- test/esp/integration/sub_organization_integration_test.rb
|
389
|
+
- test/esp/integration/suppression_integration_test.rb
|
390
|
+
- test/esp/integration/suppression_region_integration_test.rb
|
391
|
+
- test/esp/integration/suppression_signature_integration_test.rb
|
392
|
+
- test/esp/integration/suppression_unique_identifier_integration_test.rb
|
393
|
+
- test/esp/integration/tag_integration_test.rb
|
394
|
+
- test/esp/integration/team_integration_test.rb
|
395
|
+
- test/esp/integration/user_integration_test.rb
|
396
|
+
- test/esp/integration/validations_integration_test.rb
|
365
397
|
- test/esp/resources/alert_test.rb
|
366
398
|
- test/esp/resources/cloud_trail_event_test.rb
|
367
399
|
- test/esp/resources/contact_request_test.rb
|
@@ -372,6 +404,7 @@ files:
|
|
372
404
|
- test/esp/resources/organization_test.rb
|
373
405
|
- test/esp/resources/region_test.rb
|
374
406
|
- test/esp/resources/report_test.rb
|
407
|
+
- test/esp/resources/reports/export/integration_test.rb
|
375
408
|
- test/esp/resources/resource_test.rb
|
376
409
|
- test/esp/resources/scan_interval_test.rb
|
377
410
|
- test/esp/resources/service_test.rb
|
@@ -418,6 +451,7 @@ files:
|
|
418
451
|
- test/factories/teams.rb
|
419
452
|
- test/factories/users.rb
|
420
453
|
- test/json_strategy.rb
|
454
|
+
- test/parallel_reporter.rb
|
421
455
|
- test/test_helper.rb
|
422
456
|
homepage: https://github.com/EvidentSecurity/esp_sdk
|
423
457
|
licenses:
|
@@ -439,7 +473,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
439
473
|
version: '0'
|
440
474
|
requirements: []
|
441
475
|
rubyforge_project:
|
442
|
-
rubygems_version: 2.4.
|
476
|
+
rubygems_version: 2.4.8
|
443
477
|
signing_key:
|
444
478
|
specification_version: 4
|
445
479
|
summary: SDK for interacting with the ESP API.
|
@@ -449,6 +483,37 @@ test_files:
|
|
449
483
|
- test/esp/extensions/active_resource/paginated_collection_test.rb
|
450
484
|
- test/esp/extensions/active_resource/validations_test.rb
|
451
485
|
- test/esp/external_account_creator_test.rb
|
486
|
+
- test/esp/integration/alert_integration_test.rb
|
487
|
+
- test/esp/integration/cloud_trail_event_integration_test.rb
|
488
|
+
- test/esp/integration/contact_request_integration_test.rb
|
489
|
+
- test/esp/integration/custom_signature_integration_test.rb
|
490
|
+
- test/esp/integration/dashboard_integration_test.rb
|
491
|
+
- test/esp/integration/external_account_integration_test.rb
|
492
|
+
- test/esp/integration/json_api_format_integration_test.rb
|
493
|
+
- test/esp/integration/metadata_integration_test.rb
|
494
|
+
- test/esp/integration/organization_integration_test.rb
|
495
|
+
- test/esp/integration/paginated_collection_integration_test.rb
|
496
|
+
- test/esp/integration/region_integration_test.rb
|
497
|
+
- test/esp/integration/report_export_integration_integration_test.rb
|
498
|
+
- test/esp/integration/report_integration_test.rb
|
499
|
+
- test/esp/integration/resource_integration_test.rb
|
500
|
+
- test/esp/integration/scan_interval_integration_test.rb
|
501
|
+
- test/esp/integration/service_integration_test.rb
|
502
|
+
- test/esp/integration/signature_integration_test.rb
|
503
|
+
- test/esp/integration/stat_custom_signature_integration_test.rb
|
504
|
+
- test/esp/integration/stat_integration_test.rb
|
505
|
+
- test/esp/integration/stat_region_integration_test.rb
|
506
|
+
- test/esp/integration/stat_service_integration_test.rb
|
507
|
+
- test/esp/integration/stat_signature_integration_test.rb
|
508
|
+
- test/esp/integration/sub_organization_integration_test.rb
|
509
|
+
- test/esp/integration/suppression_integration_test.rb
|
510
|
+
- test/esp/integration/suppression_region_integration_test.rb
|
511
|
+
- test/esp/integration/suppression_signature_integration_test.rb
|
512
|
+
- test/esp/integration/suppression_unique_identifier_integration_test.rb
|
513
|
+
- test/esp/integration/tag_integration_test.rb
|
514
|
+
- test/esp/integration/team_integration_test.rb
|
515
|
+
- test/esp/integration/user_integration_test.rb
|
516
|
+
- test/esp/integration/validations_integration_test.rb
|
452
517
|
- test/esp/resources/alert_test.rb
|
453
518
|
- test/esp/resources/cloud_trail_event_test.rb
|
454
519
|
- test/esp/resources/contact_request_test.rb
|
@@ -459,6 +524,7 @@ test_files:
|
|
459
524
|
- test/esp/resources/organization_test.rb
|
460
525
|
- test/esp/resources/region_test.rb
|
461
526
|
- test/esp/resources/report_test.rb
|
527
|
+
- test/esp/resources/reports/export/integration_test.rb
|
462
528
|
- test/esp/resources/resource_test.rb
|
463
529
|
- test/esp/resources/scan_interval_test.rb
|
464
530
|
- test/esp/resources/service_test.rb
|
@@ -505,4 +571,5 @@ test_files:
|
|
505
571
|
- test/factories/teams.rb
|
506
572
|
- test/factories/users.rb
|
507
573
|
- test/json_strategy.rb
|
574
|
+
- test/parallel_reporter.rb
|
508
575
|
- test/test_helper.rb
|