esp_sdk 1.1.0 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/.rubocop.yml +53 -6
- data/.ruby-version +1 -1
- data/.travis.yml +8 -2
- data/Gemfile.lock +171 -0
- data/Guardfile +47 -0
- data/README.md +230 -5
- data/Rakefile +14 -1
- data/assets/logo.png +0 -0
- data/bin/esp_console +71 -0
- data/esp_sdk.gemspec +27 -18
- data/lib/esp/exceptions.rb +3 -0
- data/lib/esp/extensions/active_resource/formats/json_api_format.rb +105 -0
- data/lib/esp/extensions/active_resource/paginated_collection.rb +198 -0
- data/lib/esp/extensions/active_resource/validations.rb +45 -0
- data/lib/esp/resources/alert.rb +135 -0
- data/lib/esp/resources/cloud_trail_event.rb +45 -0
- data/lib/esp/resources/concerns/stat_totals.rb +79 -0
- data/lib/esp/resources/contact_request.rb +42 -0
- data/lib/esp/resources/custom_signature.rb +224 -0
- data/lib/esp/resources/dashboard.rb +31 -0
- data/lib/esp/resources/external_account.rb +89 -0
- data/lib/esp/resources/organization.rb +61 -0
- data/lib/esp/resources/region.rb +46 -0
- data/lib/esp/resources/report.rb +100 -0
- data/lib/esp/resources/resource.rb +66 -0
- data/lib/esp/resources/service.rb +31 -0
- data/lib/esp/resources/signature.rb +106 -0
- data/lib/esp/resources/stat.rb +124 -0
- data/lib/esp/resources/stat_custom_signature.rb +121 -0
- data/lib/esp/resources/stat_region.rb +121 -0
- data/lib/esp/resources/stat_service.rb +121 -0
- data/lib/esp/resources/stat_signature.rb +121 -0
- data/lib/esp/resources/sub_organization.rb +69 -0
- data/lib/esp/resources/suppression/region.rb +99 -0
- data/lib/esp/resources/suppression/signature.rb +107 -0
- data/lib/esp/resources/suppression/unique_identifier.rb +60 -0
- data/lib/esp/resources/suppression.rb +86 -0
- data/lib/esp/resources/tag.rb +45 -0
- data/lib/esp/resources/team.rb +79 -0
- data/lib/esp/resources/user.rb +46 -0
- data/lib/esp/version.rb +3 -0
- data/lib/esp.rb +95 -0
- data/lib/esp_sdk.rb +9 -45
- data/lib/tasks/rubocop.rake +2 -0
- data/lib/tasks/testing.rake +3 -0
- data/rdoc/ActiveResource/Formats.html +176 -0
- data/rdoc/ActiveResource/PaginatedCollection.html +910 -0
- data/rdoc/ActiveResource.html +180 -0
- data/rdoc/ESP/Alert.html +771 -0
- data/rdoc/ESP/CloudTrailEvent.html +375 -0
- data/rdoc/ESP/ContactRequest.html +366 -0
- data/rdoc/ESP/CustomSignature.html +746 -0
- data/rdoc/ESP/Dashboard.html +355 -0
- data/rdoc/ESP/ExternalAccount.html +565 -0
- data/rdoc/ESP/Organization.html +590 -0
- data/rdoc/ESP/Region.html +399 -0
- data/rdoc/ESP/Report.html +622 -0
- data/rdoc/ESP/Service.html +380 -0
- data/rdoc/ESP/Signature.html +555 -0
- data/rdoc/ESP/Stat.html +1778 -0
- data/rdoc/ESP/StatCustomSignature.html +1599 -0
- data/rdoc/ESP/StatRegion.html +1598 -0
- data/rdoc/ESP/StatService.html +1598 -0
- data/rdoc/ESP/StatSignature.html +1598 -0
- data/rdoc/ESP/SubOrganization.html +540 -0
- data/rdoc/ESP/Suppression/Region.html +454 -0
- data/rdoc/ESP/Suppression/Signature.html +470 -0
- data/rdoc/ESP/Suppression/UniqueIdentifier.html +417 -0
- data/rdoc/ESP/Suppression.html +649 -0
- data/rdoc/ESP/Tag.html +371 -0
- data/rdoc/ESP/Team.html +584 -0
- data/rdoc/ESP/User.html +483 -0
- data/rdoc/ESP.html +546 -0
- data/rdoc/README_md.html +501 -0
- data/rdoc/created.rid +30 -0
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +134 -0
- data/rdoc/js/darkfish.js +155 -0
- data/rdoc/js/jquery.js +4 -0
- data/rdoc/js/navigation.js +142 -0
- data/rdoc/js/search.js +94 -0
- data/rdoc/js/search_index.js +1 -0
- data/rdoc/js/searcher.js +228 -0
- data/rdoc/rdoc.css +595 -0
- data/rdoc/table_of_contents.html +927 -0
- data/test/esp/extensions/active_resource/formats/json_api_format_test.rb +109 -0
- data/test/esp/extensions/active_resource/paginated_collection_test.rb +435 -0
- data/test/esp/extensions/active_resource/validations_test.rb +59 -0
- data/test/esp/resources/alert_test.rb +263 -0
- data/test/esp/resources/cloud_trail_event_test.rb +98 -0
- data/test/esp/resources/contact_request_test.rb +73 -0
- data/test/esp/resources/custom_signature_test.rb +241 -0
- data/test/esp/resources/dashboard_test.rb +71 -0
- data/test/esp/resources/external_account_test.rb +125 -0
- data/test/esp/resources/organization_test.rb +175 -0
- data/test/esp/resources/region_test.rb +84 -0
- data/test/esp/resources/report_test.rb +180 -0
- data/test/esp/resources/resource_test.rb +183 -0
- data/test/esp/resources/service_test.rb +64 -0
- data/test/esp/resources/signature_test.rb +177 -0
- data/test/esp/resources/stat_custom_signature_test.rb +115 -0
- data/test/esp/resources/stat_region_test.rb +114 -0
- data/test/esp/resources/stat_service_test.rb +114 -0
- data/test/esp/resources/stat_signature_test.rb +115 -0
- data/test/esp/resources/stat_test.rb +159 -0
- data/test/esp/resources/sub_organization_test.rb +127 -0
- data/test/esp/resources/suppression/region_test.rb +115 -0
- data/test/esp/resources/suppression/signature_test.rb +117 -0
- data/test/esp/resources/suppression/unique_identifier_test.rb +79 -0
- data/test/esp/resources/suppression_test.rb +226 -0
- data/test/esp/resources/tag_test.rb +98 -0
- data/test/esp/resources/team_test.rb +140 -0
- data/test/esp/resources/user_test.rb +113 -0
- data/test/esp_test.rb +139 -0
- data/test/factories/alerts.rb +234 -0
- data/test/factories/cloud_trail_events.rb +16 -0
- data/test/factories/contact_requests.rb +14 -0
- data/test/factories/custom_signatures.rb +30 -0
- data/test/factories/dashboards.rb +91 -0
- data/test/factories/errors.rb +24 -0
- data/test/factories/external_accounts.rb +44 -0
- data/test/factories/organizations.rb +48 -0
- data/test/factories/regions.rb +9 -0
- data/test/factories/reports.rb +56 -0
- data/test/factories/services.rb +12 -0
- data/test/factories/signatures.rb +28 -0
- data/test/factories/stat_custom_signatures.rb +97 -0
- data/test/factories/stat_regions.rb +97 -0
- data/test/factories/stat_services.rb +97 -0
- data/test/factories/stat_signautures.rb +97 -0
- data/test/factories/stats.rb +129 -0
- data/test/factories/sub_organizations.rb +34 -0
- data/test/factories/suppression/regions.rb +90 -0
- data/test/factories/suppression/signatures.rb +117 -0
- data/test/factories/suppression/unique_identifiers.rb +111 -0
- data/test/factories/suppressions.rb +71 -0
- data/test/factories/tags.rb +12 -0
- data/test/factories/teams.rb +32 -0
- data/test/factories/users.rb +54 -0
- data/test/json_strategy.rb +25 -0
- data/test/test_helper.rb +44 -5
- metadata +387 -119
- data/bin/esp_repl +0 -60
- data/lib/esp_sdk/api.rb +0 -33
- data/lib/esp_sdk/client.rb +0 -62
- data/lib/esp_sdk/configure.rb +0 -40
- data/lib/esp_sdk/end_points/base.rb +0 -102
- data/lib/esp_sdk/end_points/contact_requests.rb +0 -6
- data/lib/esp_sdk/end_points/custom_signatures.rb +0 -41
- data/lib/esp_sdk/end_points/dashboard.rb +0 -35
- data/lib/esp_sdk/end_points/external_accounts.rb +0 -9
- data/lib/esp_sdk/end_points/organizations.rb +0 -6
- data/lib/esp_sdk/end_points/reports.rb +0 -6
- data/lib/esp_sdk/end_points/services.rb +0 -6
- data/lib/esp_sdk/end_points/signatures.rb +0 -39
- data/lib/esp_sdk/end_points/sub_organizations.rb +0 -6
- data/lib/esp_sdk/end_points/teams.rb +0 -6
- data/lib/esp_sdk/end_points/users.rb +0 -6
- data/lib/esp_sdk/exceptions.rb +0 -8
- data/lib/esp_sdk/extensions/rest_client/request.rb +0 -9
- data/lib/esp_sdk/repl.rb +0 -61
- data/lib/esp_sdk/version.rb +0 -3
- data/test/esp_sdk/api_test.rb +0 -36
- data/test/esp_sdk/client_test.rb +0 -129
- data/test/esp_sdk/configure_test.rb +0 -65
- data/test/esp_sdk/end_points/.keep +0 -0
- data/test/esp_sdk/end_points/base_test.rb +0 -230
- data/test/esp_sdk/end_points/custom_signatures_test.rb +0 -90
- data/test/esp_sdk/end_points/dashboard_test.rb +0 -55
- data/test/esp_sdk/end_points/external_accounts_test.rb +0 -20
- data/test/esp_sdk/end_points/signatures_test.rb +0 -83
- data/test/esp_sdk/exceptions_test.rb +0 -41
- data/test/esp_sdk_test.rb +0 -70
@@ -0,0 +1,113 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
|
2
|
+
|
3
|
+
module ESP
|
4
|
+
class UserTest < ActiveSupport::TestCase
|
5
|
+
context ESP::User do
|
6
|
+
context '#create' do
|
7
|
+
should 'not be implemented' do
|
8
|
+
assert_raises ESP::NotImplementedError do
|
9
|
+
ESP::User.create(name: 'test')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context '#update' do
|
15
|
+
should 'not be implemented' do
|
16
|
+
u = build(:user)
|
17
|
+
assert_raises ESP::NotImplementedError do
|
18
|
+
u.save
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context '#destroy' do
|
24
|
+
should 'not be implemented' do
|
25
|
+
u = build(:user)
|
26
|
+
assert_raises ESP::NotImplementedError do
|
27
|
+
u.destroy
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context '#organization' do
|
33
|
+
should 'call the api' do
|
34
|
+
u = build(:user, organization_id: 1)
|
35
|
+
stub_org = stub_request(:get, %r{organizations/#{u.organization_id}.json*}).to_return(body: json(:organization))
|
36
|
+
|
37
|
+
u.organization
|
38
|
+
|
39
|
+
assert_requested(stub_org)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context '#sub_organizations' do
|
44
|
+
should 'call the api' do
|
45
|
+
u = build(:user, sub_organization_ids: [1, 2])
|
46
|
+
stub_request(:get, /sub_organizations.json*/).to_return(body: json_list(:sub_organization, 2))
|
47
|
+
|
48
|
+
u.sub_organizations
|
49
|
+
|
50
|
+
assert_requested(:get, /sub_organizations.json*/) do |req|
|
51
|
+
assert_equal "filter[id_in][0]=#{u.sub_organization_ids.first}&filter[id_in][1]=#{u.sub_organization_ids.second}", URI.unescape(req.uri.query)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context '#teams' do
|
57
|
+
should 'call the api' do
|
58
|
+
u = build(:user, team_ids: [1, 2])
|
59
|
+
stub_request(:get, /teams.json*/).to_return(body: json_list(:team, 2))
|
60
|
+
|
61
|
+
u.teams
|
62
|
+
|
63
|
+
assert_requested(:get, /teams.json*/) do |req|
|
64
|
+
assert_equal "filter[id_in][0]=#{u.team_ids.first}&filter[id_in][1]=#{u.team_ids.second}", URI.unescape(req.uri.query)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
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
|
+
end
|
74
|
+
|
75
|
+
teardown do
|
76
|
+
WebMock.disable_net_connect!
|
77
|
+
end
|
78
|
+
|
79
|
+
context '#organization' do
|
80
|
+
should 'return an organization' do
|
81
|
+
u = ESP::User.last
|
82
|
+
|
83
|
+
org = u.organization
|
84
|
+
|
85
|
+
assert_equal u.organization_id, org.id
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context '#sub_organizations' do
|
90
|
+
should 'return an array of sub_organizations' do
|
91
|
+
u = ESP::User.last
|
92
|
+
|
93
|
+
sub_orgs = u.sub_organizations
|
94
|
+
|
95
|
+
assert_equal u.sub_organization_ids.count, sub_orgs.count
|
96
|
+
assert_equal u.sub_organization_ids, sub_orgs.map(&:id)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context '#teams' do
|
101
|
+
should 'return an array of teams' do
|
102
|
+
u = ESP::User.last
|
103
|
+
|
104
|
+
teams = u.teams
|
105
|
+
|
106
|
+
assert_equal u.team_ids.count, teams.count
|
107
|
+
assert_equal u.team_ids.sort, teams.map(&:id).sort
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/test/esp_test.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
2
|
+
|
3
|
+
class ESPTest < ActiveSupport::TestCase
|
4
|
+
context ESP do
|
5
|
+
setup do
|
6
|
+
@original_access_key_id = ESP.access_key_id
|
7
|
+
@original_secret_access_key = ESP.secret_access_key
|
8
|
+
end
|
9
|
+
|
10
|
+
teardown do
|
11
|
+
ESP.access_key_id = @original_access_key_id
|
12
|
+
ESP.secret_access_key = @original_secret_access_key
|
13
|
+
end
|
14
|
+
|
15
|
+
context '.access_key_id' do
|
16
|
+
should 'be set manually' do
|
17
|
+
ESP.access_key_id = '1234'
|
18
|
+
|
19
|
+
assert_equal '1234', ESP.access_key_id
|
20
|
+
assert_equal '1234', ESP::Resource.hmac_access_id
|
21
|
+
end
|
22
|
+
|
23
|
+
should 'be set from an environment variable' do
|
24
|
+
ESP.access_key_id = nil
|
25
|
+
ENV['ESP_ACCESS_KEY_ID'] = '4321'
|
26
|
+
|
27
|
+
assert_equal '4321', ESP.access_key_id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context '.secret_access_key' do
|
32
|
+
should 'be set manually' do
|
33
|
+
ESP.secret_access_key = '1234'
|
34
|
+
|
35
|
+
assert_equal '1234', ESP.secret_access_key
|
36
|
+
assert_equal '1234', ESP::Resource.hmac_secret_key
|
37
|
+
end
|
38
|
+
|
39
|
+
should 'be set from an environment variable' do
|
40
|
+
ESP.secret_access_key = nil
|
41
|
+
ENV['ESP_SECRET_ACCESS_KEY'] = '4321'
|
42
|
+
|
43
|
+
assert_equal '4321', ESP.secret_access_key
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context '.host=' do
|
48
|
+
setup do
|
49
|
+
ESP.host = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
teardown do
|
53
|
+
ESP.host = nil
|
54
|
+
ENV['ESP_HOST'] = nil
|
55
|
+
end
|
56
|
+
|
57
|
+
should 'set ESP::Resource.site' do
|
58
|
+
ESP.host = 'http://sample.com'
|
59
|
+
|
60
|
+
assert_equal URI.parse("http://sample.com#{ESP::PATH}"), ESP::Resource.site
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context '.site' do
|
65
|
+
setup do
|
66
|
+
ESP.host = nil
|
67
|
+
end
|
68
|
+
|
69
|
+
teardown do
|
70
|
+
ESP.host = nil
|
71
|
+
ENV['ESP_HOST'] = nil
|
72
|
+
end
|
73
|
+
|
74
|
+
should "return manually set host with path when set" do
|
75
|
+
ESP.host = 'http://sample.com'
|
76
|
+
|
77
|
+
assert_equal URI.parse("http://sample.com#{ESP::PATH}"), ESP::Resource.site
|
78
|
+
end
|
79
|
+
|
80
|
+
should 'should return the test host with path' do
|
81
|
+
assert_equal "#{ESP::HOST[ESP.env.to_sym]}#{ESP::PATH}", ESP.site
|
82
|
+
end
|
83
|
+
|
84
|
+
should "return ENV['ESP_HOST'] with path when in appliance env" do
|
85
|
+
ENV['ESP_HOST'] = 'https://sample.com'
|
86
|
+
ESP.stubs(:env).returns('appliance')
|
87
|
+
assert_equal "https://sample.com#{ESP::PATH}", ESP.site
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context '.configure' do
|
92
|
+
setup do
|
93
|
+
ESP.host = nil
|
94
|
+
end
|
95
|
+
|
96
|
+
teardown do
|
97
|
+
ESP.host = nil
|
98
|
+
end
|
99
|
+
|
100
|
+
should 'set site, access_key_id, secret_access_key' do
|
101
|
+
ESP.configure do |config|
|
102
|
+
config.host = 'https://sample.com'
|
103
|
+
config.access_key_id = '1234'
|
104
|
+
config.secret_access_key = '5678'
|
105
|
+
end
|
106
|
+
|
107
|
+
assert_equal "https://sample.com#{ESP::PATH}", ESP.site
|
108
|
+
assert_equal URI.parse("https://sample.com#{ESP::PATH}"), ESP::Resource.site
|
109
|
+
assert_equal '1234', ESP.access_key_id
|
110
|
+
assert_equal '1234', ESP::Resource.hmac_access_id
|
111
|
+
assert_equal '5678', ESP.secret_access_key
|
112
|
+
assert_equal '5678', ESP::Resource.hmac_secret_key
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context '.env' do
|
117
|
+
setup do
|
118
|
+
ESP.instance_variable_set(:@env, nil)
|
119
|
+
end
|
120
|
+
|
121
|
+
teardown do
|
122
|
+
ESP.instance_variable_set(:@env, nil)
|
123
|
+
ENV['ESP_ENV'] = 'test'
|
124
|
+
ENV['RAILS_ENV'] = 'test'
|
125
|
+
end
|
126
|
+
|
127
|
+
should 'return production when ENV is not set' do
|
128
|
+
ENV['ESP_ENV'] = nil
|
129
|
+
ENV['RAILS_ENV'] = nil
|
130
|
+
assert_predicate ESP.env, :production?
|
131
|
+
end
|
132
|
+
|
133
|
+
should 'return test when ENV[ESP_ENV] is set to test' do
|
134
|
+
ENV['ESP_ENV'] = 'test'
|
135
|
+
assert_predicate ESP.env, :test?
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :alert, class: 'ESP::Alert' do
|
3
|
+
skip_create
|
4
|
+
|
5
|
+
sequence(:id) { |n| n }
|
6
|
+
type "alerts"
|
7
|
+
created_at { Time.current }
|
8
|
+
status "fail"
|
9
|
+
resource "resource-3"
|
10
|
+
updated_at nil
|
11
|
+
metadata { { abc: 123 } }
|
12
|
+
started_at { Time.current }
|
13
|
+
ended_at nil
|
14
|
+
relationships do
|
15
|
+
{
|
16
|
+
external_account: {
|
17
|
+
data: {
|
18
|
+
type: "external_accounts",
|
19
|
+
id: "1015"
|
20
|
+
},
|
21
|
+
links: {
|
22
|
+
related: "http://test.host/api/v2/external_accounts/1015.json"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
region: {
|
26
|
+
data: {
|
27
|
+
type: "regions",
|
28
|
+
id: "1014"
|
29
|
+
}
|
30
|
+
},
|
31
|
+
signature: {
|
32
|
+
data: {
|
33
|
+
type: "signatures",
|
34
|
+
id: "1013"
|
35
|
+
},
|
36
|
+
links: {
|
37
|
+
related: "http://test.host/api/v2/signatures/1013.json"
|
38
|
+
}
|
39
|
+
},
|
40
|
+
custom_signature: {
|
41
|
+
data: nil
|
42
|
+
},
|
43
|
+
suppression: {
|
44
|
+
data: {
|
45
|
+
id: "1",
|
46
|
+
type: "suppressions"
|
47
|
+
},
|
48
|
+
links: {
|
49
|
+
related: "http://test.host/api/v2/suppressions/1.json"
|
50
|
+
}
|
51
|
+
},
|
52
|
+
cloud_trail_events: {
|
53
|
+
data: [
|
54
|
+
{
|
55
|
+
type: "cloud_trail_events",
|
56
|
+
id: "1"
|
57
|
+
}
|
58
|
+
],
|
59
|
+
links: {
|
60
|
+
related: "http://test.host/api/v2/alerts/1017/cloud_trail_events.json"
|
61
|
+
}
|
62
|
+
},
|
63
|
+
tags: {
|
64
|
+
data: [
|
65
|
+
{
|
66
|
+
id: "1",
|
67
|
+
type: "tags"
|
68
|
+
},
|
69
|
+
{
|
70
|
+
id: "2",
|
71
|
+
type: "tags"
|
72
|
+
}
|
73
|
+
]
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
included do
|
78
|
+
[
|
79
|
+
{
|
80
|
+
id: "1015",
|
81
|
+
type: "external_accounts",
|
82
|
+
attributes: {
|
83
|
+
account: "5",
|
84
|
+
arn: "arn:aws:iam::5:role/test_sts_role",
|
85
|
+
created_at: "2015-09-11T21:12:15.183Z",
|
86
|
+
external_id: "test_sts_external_id_1",
|
87
|
+
name: nil,
|
88
|
+
updated_at: nil,
|
89
|
+
user_attribution_role: nil
|
90
|
+
},
|
91
|
+
relationships: {
|
92
|
+
organization: {
|
93
|
+
data: {
|
94
|
+
type: "organizations",
|
95
|
+
id: "5"
|
96
|
+
},
|
97
|
+
links: {
|
98
|
+
related: "http://test.host/api/v2/organizations/5.json"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
sub_organization: {
|
102
|
+
data: {
|
103
|
+
type: "sub_organizations",
|
104
|
+
id: "5"
|
105
|
+
},
|
106
|
+
links: {
|
107
|
+
related: "http://test.host/api/v2/sub_organizations/5.json"
|
108
|
+
}
|
109
|
+
},
|
110
|
+
team: {
|
111
|
+
data: {
|
112
|
+
type: "teams",
|
113
|
+
id: "5"
|
114
|
+
},
|
115
|
+
links: {
|
116
|
+
related: "http://test.host/api/v2/teams/5.json"
|
117
|
+
}
|
118
|
+
},
|
119
|
+
user_attribution_role: {
|
120
|
+
data: nil
|
121
|
+
}
|
122
|
+
}
|
123
|
+
},
|
124
|
+
{
|
125
|
+
id: "1014",
|
126
|
+
type: "regions",
|
127
|
+
attributes: {
|
128
|
+
code: "us_east_test_3"
|
129
|
+
}
|
130
|
+
},
|
131
|
+
{
|
132
|
+
id: "1013",
|
133
|
+
type: "signatures",
|
134
|
+
attributes: {
|
135
|
+
created_at: "2015-09-11T21:12:15.192Z",
|
136
|
+
description: "\"Some description for some test\"",
|
137
|
+
identifier: "3 Unique ID",
|
138
|
+
name: "3_test_signature",
|
139
|
+
resolution: "\"Turn on some setting\"",
|
140
|
+
risk_level: "High",
|
141
|
+
updated_at: nil
|
142
|
+
},
|
143
|
+
relationships: {
|
144
|
+
service: {
|
145
|
+
data: {
|
146
|
+
type: "services",
|
147
|
+
id: "3"
|
148
|
+
},
|
149
|
+
links: {
|
150
|
+
related: "http://test.host/api/v2/services/3.json"
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
},
|
155
|
+
{
|
156
|
+
id: "1",
|
157
|
+
type: "cloud_trail_events",
|
158
|
+
attributes: {
|
159
|
+
event_id: "1",
|
160
|
+
event_name: "1",
|
161
|
+
event_time: "2015-09-11T21:12:14.661Z",
|
162
|
+
username: "johndoe",
|
163
|
+
ip_address: "123.0.0.123",
|
164
|
+
user_agent: "Chrome"
|
165
|
+
}
|
166
|
+
},
|
167
|
+
{
|
168
|
+
id: "1",
|
169
|
+
type: "suppressions",
|
170
|
+
attributes: {
|
171
|
+
created_at: "2015-10-16T18:34:19.464Z",
|
172
|
+
reason: "I dont like this",
|
173
|
+
status: "setup",
|
174
|
+
updated_at: "2015-10-16T18:34:19.464Z",
|
175
|
+
configuration: {
|
176
|
+
suppression_type: "regions",
|
177
|
+
resource: nil,
|
178
|
+
regions: [
|
179
|
+
{
|
180
|
+
id: "4",
|
181
|
+
type: "regions",
|
182
|
+
attributes: {
|
183
|
+
code: "us_east_test_4"
|
184
|
+
}
|
185
|
+
}
|
186
|
+
],
|
187
|
+
external_accounts: []
|
188
|
+
}
|
189
|
+
},
|
190
|
+
relationships: {
|
191
|
+
organization: {
|
192
|
+
data: {
|
193
|
+
id: "4",
|
194
|
+
type: "organizations"
|
195
|
+
},
|
196
|
+
links: {
|
197
|
+
related: "http://test.host/api/v2/organizations/4.json"
|
198
|
+
}
|
199
|
+
},
|
200
|
+
created_by: {
|
201
|
+
data: {
|
202
|
+
id: "1",
|
203
|
+
type: "users"
|
204
|
+
},
|
205
|
+
links: {
|
206
|
+
related: "http://test.host/api/v2/users/1.json"
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
},
|
211
|
+
{
|
212
|
+
id: "1",
|
213
|
+
type: "tags",
|
214
|
+
attributes: {
|
215
|
+
key: "Name",
|
216
|
+
value: "abc123",
|
217
|
+
created_at: "2015-10-16T18:34:19.569Z",
|
218
|
+
updated_at: "2015-10-16T18:34:19.569Z"
|
219
|
+
}
|
220
|
+
},
|
221
|
+
{
|
222
|
+
id: "2",
|
223
|
+
type: "tags",
|
224
|
+
attributes: {
|
225
|
+
key: "Name",
|
226
|
+
value: "abc123",
|
227
|
+
created_at: "2015-10-16T18:34:19.571Z",
|
228
|
+
updated_at: "2015-10-16T18:34:19.571Z"
|
229
|
+
}
|
230
|
+
}
|
231
|
+
]
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :contact_request, class: 'ESP::ContactRequest' do
|
3
|
+
skip_create
|
4
|
+
|
5
|
+
sequence(:id) { |n| n }
|
6
|
+
type "cloud_trail_events"
|
7
|
+
title "test2"
|
8
|
+
event_id "1"
|
9
|
+
event_name "1"
|
10
|
+
event_time "2015-10-16T19:07:24.434Z"
|
11
|
+
raw_event { { test: "event data" } }
|
12
|
+
username "johndoe"
|
13
|
+
ip_address "123.0.0.123"
|
14
|
+
user_agent "Chrome"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :cloud_trail_event, class: 'ESP::CloudTrailEvent' do
|
3
|
+
skip_create
|
4
|
+
|
5
|
+
sequence(:id) { |n| n }
|
6
|
+
type "cloud_trail_events"
|
7
|
+
event_id "1"
|
8
|
+
event_name "1"
|
9
|
+
event_time { Time.current }
|
10
|
+
username "johndoe"
|
11
|
+
ip_address "123.0.0.123"
|
12
|
+
user_agent "Chrome"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :custom_signature, class: 'ESP::CustomSignature' do
|
3
|
+
skip_create
|
4
|
+
|
5
|
+
sequence(:id) { |n| n }
|
6
|
+
type "custom_signatures"
|
7
|
+
created_at { Time.current }
|
8
|
+
active true
|
9
|
+
description "Test description"
|
10
|
+
identifier "AWS::Test::001"
|
11
|
+
name "Test"
|
12
|
+
resolution "Test resolution"
|
13
|
+
risk_level "Medium"
|
14
|
+
signature "Some javascript"
|
15
|
+
language "javascript"
|
16
|
+
updated_at nil
|
17
|
+
relationships do
|
18
|
+
{ organization: {
|
19
|
+
data: {
|
20
|
+
type: "organizations",
|
21
|
+
id: "1003"
|
22
|
+
},
|
23
|
+
links: {
|
24
|
+
related: "http://test.host/api/v2/organizations/1003.json"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :dashboard, class: 'ESP::Dashboard' do
|
3
|
+
skip_create
|
4
|
+
|
5
|
+
type "reports"
|
6
|
+
team_name "Operations 1"
|
7
|
+
sub_organization_name "IT Department 1"
|
8
|
+
organization_name "Test Organization 1"
|
9
|
+
created_at { Time.current }
|
10
|
+
updated_at { Time.current }
|
11
|
+
relationships do
|
12
|
+
{ stat: {
|
13
|
+
data: {
|
14
|
+
type: "stats",
|
15
|
+
id: "1"
|
16
|
+
},
|
17
|
+
links: {
|
18
|
+
related: "http://test.host/api/v2/reports/1/stats.json"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
included do
|
24
|
+
[
|
25
|
+
{
|
26
|
+
id: "1",
|
27
|
+
type: "stats",
|
28
|
+
attributes: {
|
29
|
+
total: 59,
|
30
|
+
stat_signatures: [
|
31
|
+
{
|
32
|
+
signature: {
|
33
|
+
id: 1,
|
34
|
+
name: "1_test_signature",
|
35
|
+
risk_level: "High",
|
36
|
+
service: {
|
37
|
+
code: "S1",
|
38
|
+
id: 1,
|
39
|
+
name: "SSS"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
total_pass: 2,
|
43
|
+
total_fail: 6,
|
44
|
+
total_warn: 8,
|
45
|
+
total_error: 1,
|
46
|
+
total_new_1h: 7,
|
47
|
+
total_new_1d: 14
|
48
|
+
}
|
49
|
+
],
|
50
|
+
stat_custom_signatures: [
|
51
|
+
{
|
52
|
+
custom_signature: {
|
53
|
+
id: 1,
|
54
|
+
name: "Test",
|
55
|
+
risk_level: "Medium"
|
56
|
+
},
|
57
|
+
total_pass: 8,
|
58
|
+
total_fail: 2,
|
59
|
+
total_warn: 4,
|
60
|
+
total_error: 6,
|
61
|
+
total_new_1h: 8,
|
62
|
+
total_new_1d: 12
|
63
|
+
}
|
64
|
+
],
|
65
|
+
stat_regions: [
|
66
|
+
{
|
67
|
+
region: {
|
68
|
+
id: 1,
|
69
|
+
code: "us_east_test_1"
|
70
|
+
},
|
71
|
+
total_pass: 16,
|
72
|
+
total_fail: 18,
|
73
|
+
total_warn: 12,
|
74
|
+
total_error: 11,
|
75
|
+
total_high: 16,
|
76
|
+
total_medium: 18,
|
77
|
+
total_low: 20,
|
78
|
+
total_new_1h_high: 4,
|
79
|
+
total_new_1h_medium: 5,
|
80
|
+
total_new_1h_low: 9,
|
81
|
+
total_new_1d_high: 8,
|
82
|
+
total_new_1d_medium: 8,
|
83
|
+
total_new_1d_low: 13
|
84
|
+
}
|
85
|
+
]
|
86
|
+
}
|
87
|
+
}
|
88
|
+
]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :error, class: 'ActiveResource::Base' do
|
3
|
+
skip_create
|
4
|
+
|
5
|
+
errors do
|
6
|
+
[{ status: '401',
|
7
|
+
title: 'Access Denied' }]
|
8
|
+
end
|
9
|
+
|
10
|
+
trait :active_record do
|
11
|
+
errors do
|
12
|
+
[{ status: '401',
|
13
|
+
title: "Name can't be blank",
|
14
|
+
meta: { name: "can't be blank" } },
|
15
|
+
{ status: '401',
|
16
|
+
title: "Name is invalid",
|
17
|
+
meta: { name: "is invalid" } },
|
18
|
+
{ status: '401',
|
19
|
+
title: "Description can't be blank",
|
20
|
+
meta: { description: "can't be blank" } }]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :external_account, class: 'ESP::ExternalAccount' do
|
3
|
+
skip_create
|
4
|
+
|
5
|
+
sequence(:id) { |n| n }
|
6
|
+
type "external_accounts"
|
7
|
+
account "762160981991"
|
8
|
+
arn "arn:aws:iam::762160981991:role/Evident-Service-Role-Kevin"
|
9
|
+
created_at { Time.current }
|
10
|
+
external_id "913310e7-6a9c-49f7-bd69-120721ec1122"
|
11
|
+
name "Dev"
|
12
|
+
updated_at { Time.current }
|
13
|
+
relationships do
|
14
|
+
{ organization: {
|
15
|
+
data: {
|
16
|
+
type: "organizations",
|
17
|
+
id: "1"
|
18
|
+
},
|
19
|
+
links: {
|
20
|
+
related: "http://localhost:3000/api/v2/organizations/1.json"
|
21
|
+
}
|
22
|
+
},
|
23
|
+
sub_organization: {
|
24
|
+
data: {
|
25
|
+
type: "sub_organizations",
|
26
|
+
id: "1"
|
27
|
+
},
|
28
|
+
links: {
|
29
|
+
related: "http://localhost:3000/api/v2/sub_organizations/1.json"
|
30
|
+
}
|
31
|
+
},
|
32
|
+
team: {
|
33
|
+
data: {
|
34
|
+
type: "teams",
|
35
|
+
id: "1"
|
36
|
+
},
|
37
|
+
links: {
|
38
|
+
related: "http://localhost:3000/api/v2/teams/1.json"
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|