skull_island 1.2.10 → 1.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +18 -18
- data/lib/skull_island/helpers/resource.rb +15 -3
- data/lib/skull_island/resources/plugin.rb +1 -1
- data/lib/skull_island/resources/route.rb +2 -2
- data/lib/skull_island/rspec/fake_api_client.rb +4 -37
- data/lib/skull_island/rspec/fake_client/request.rb +41 -0
- data/lib/skull_island/rspec/fake_rest_client.rb +32 -0
- data/lib/skull_island/rspec.rb +2 -0
- data/lib/skull_island/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9041d8426e20bd746ce9efe08b5b16a30e6b3ce4f176246c207e45e450321262
|
4
|
+
data.tar.gz: a31475d45dc6cf1716bd8512fd0e1e7014dfa63c080f0197ae533bdfbcdc9ef5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9907185af7eb04498fe9cc1ea2842aee6694edf017be0f52c94fc4a6dfc4dd4562893da829b7a1c6e90ca5c620564e1ecbcd2ee0853ec7857c2bd77384c18b53
|
7
|
+
data.tar.gz: 8ba0a61980000f26c2a60408c8afd9eed717c1da3fd73ce29f70e8237fde403389f50be3f14c2fcbed0edd8d3674b07b4f36cd0e269729e78fd9ca4ab91d8bea
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
skull_island (1.2.
|
4
|
+
skull_island (1.2.11)
|
5
5
|
deepsort (~> 0.4)
|
6
6
|
erubi (~> 1.8)
|
7
7
|
json (~> 2.1)
|
@@ -27,7 +27,7 @@ GEM
|
|
27
27
|
docile (1.3.2)
|
28
28
|
domain_name (0.5.20190701)
|
29
29
|
unf (>= 0.0.5, < 1.0.0)
|
30
|
-
erubi (1.
|
30
|
+
erubi (1.9.0)
|
31
31
|
ethon (0.12.0)
|
32
32
|
ffi (>= 1.3.0)
|
33
33
|
faraday (0.15.4)
|
@@ -61,8 +61,8 @@ GEM
|
|
61
61
|
net-http-persistent (2.9.4)
|
62
62
|
net-http-pipeline (1.0.1)
|
63
63
|
netrc (0.11.0)
|
64
|
-
parallel (1.
|
65
|
-
parser (2.6.
|
64
|
+
parallel (1.18.0)
|
65
|
+
parser (2.6.5.0)
|
66
66
|
ast (~> 2.4.0)
|
67
67
|
pusher-client (0.6.2)
|
68
68
|
json
|
@@ -74,20 +74,20 @@ GEM
|
|
74
74
|
http-cookie (>= 1.0.2, < 2.0)
|
75
75
|
mime-types (>= 1.16, < 4.0)
|
76
76
|
netrc (~> 0.8)
|
77
|
-
rspec (3.
|
78
|
-
rspec-core (~> 3.
|
79
|
-
rspec-expectations (~> 3.
|
80
|
-
rspec-mocks (~> 3.
|
81
|
-
rspec-core (3.
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-expectations (3.
|
77
|
+
rspec (3.9.0)
|
78
|
+
rspec-core (~> 3.9.0)
|
79
|
+
rspec-expectations (~> 3.9.0)
|
80
|
+
rspec-mocks (~> 3.9.0)
|
81
|
+
rspec-core (3.9.0)
|
82
|
+
rspec-support (~> 3.9.0)
|
83
|
+
rspec-expectations (3.9.0)
|
84
84
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
-
rspec-support (~> 3.
|
86
|
-
rspec-mocks (3.
|
85
|
+
rspec-support (~> 3.9.0)
|
86
|
+
rspec-mocks (3.9.0)
|
87
87
|
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
-
rspec-support (~> 3.
|
89
|
-
rspec-support (3.
|
90
|
-
rubocop (0.
|
88
|
+
rspec-support (~> 3.9.0)
|
89
|
+
rspec-support (3.9.0)
|
90
|
+
rubocop (0.75.1)
|
91
91
|
jaro_winkler (~> 1.5.1)
|
92
92
|
parallel (~> 1.10)
|
93
93
|
parser (>= 2.6)
|
@@ -95,7 +95,7 @@ GEM
|
|
95
95
|
ruby-progressbar (~> 1.7)
|
96
96
|
unicode-display_width (>= 1.4.0, < 1.7)
|
97
97
|
ruby-progressbar (1.10.1)
|
98
|
-
simplecov (0.17.
|
98
|
+
simplecov (0.17.1)
|
99
99
|
docile (~> 1.1)
|
100
100
|
json (>= 1.8, < 3)
|
101
101
|
simplecov-html (~> 0.10.0)
|
@@ -120,7 +120,7 @@ GEM
|
|
120
120
|
unf_ext (0.0.7.6)
|
121
121
|
unicode-display_width (1.6.0)
|
122
122
|
websocket (1.2.8)
|
123
|
-
will_paginate (3.1
|
123
|
+
will_paginate (3.2.1)
|
124
124
|
yard (0.9.20)
|
125
125
|
|
126
126
|
PLATFORMS
|
@@ -15,17 +15,29 @@ module SkullIsland
|
|
15
15
|
end
|
16
16
|
|
17
17
|
# rubocop:disable Style/GuardClause
|
18
|
+
# rubocop:disable Security/Eval
|
18
19
|
def delayed_set(property, data, key)
|
19
|
-
# rubocop:disable Security/Eval
|
20
20
|
if data[key]
|
21
|
-
value =
|
21
|
+
value = recursive_erubi(data[key])
|
22
22
|
send(
|
23
23
|
"#{property}=".to_sym,
|
24
24
|
value.is_a?(String) && value.start_with?('{"') ? eval(value) : value
|
25
25
|
)
|
26
26
|
end
|
27
|
-
# rubocop:enable Security/Eval
|
28
27
|
end
|
28
|
+
|
29
|
+
def recursive_erubi(data)
|
30
|
+
if data.is_a?(String)
|
31
|
+
eval(Erubi::Engine.new(data).src)
|
32
|
+
elsif data.is_a?(Array)
|
33
|
+
data.map { |item| recursive_erubi(item) }
|
34
|
+
elsif data.is_a?(Hash)
|
35
|
+
data.map { |k, v| [k, recursive_erubi(v)] }.to_h
|
36
|
+
else
|
37
|
+
data
|
38
|
+
end
|
39
|
+
end
|
40
|
+
# rubocop:enable Security/Eval
|
29
41
|
# rubocop:enable Style/GuardClause
|
30
42
|
|
31
43
|
def digest
|
@@ -31,7 +31,7 @@ module SkullIsland
|
|
31
31
|
resource.name = resource_data['name']
|
32
32
|
resource.enabled = resource_data['enabled']
|
33
33
|
resource.run_on = resource_data['run_on'] if resource_data['run_on']
|
34
|
-
resource.config
|
34
|
+
resource.delayed_set(:config, resource_data, 'config') if resource_data['config']
|
35
35
|
resource.tags = resource_data['tags'] if resource_data['tags']
|
36
36
|
resource.project = project if project
|
37
37
|
resource.import_time = (time || Time.now.utc.to_i) if project
|
@@ -39,11 +39,11 @@ module SkullIsland
|
|
39
39
|
resource.methods = rdata['methods'] if rdata['methods']
|
40
40
|
resource.paths = rdata['paths'] if rdata['paths']
|
41
41
|
resource.protocols = rdata['protocols'] if rdata['protocols']
|
42
|
-
resource.hosts
|
42
|
+
resource.delayed_set(:hosts, rdata, 'hosts') if rdata['hosts']
|
43
43
|
resource.regex_priority = rdata['regex_priority'] if rdata['regex_priority']
|
44
44
|
resource.strip_path = rdata['strip_path'] unless rdata['strip_path'].nil?
|
45
45
|
resource.preserve_host = rdata['preserve_host'] unless rdata['preserve_host'].nil?
|
46
|
-
resource.snis
|
46
|
+
resource.delayed_set(:snis, rdata, 'snis') if rdata['snis']
|
47
47
|
resource.tags = rdata['tags'] if rdata['tags']
|
48
48
|
resource.project = project if project
|
49
49
|
resource.import_time = (time || Time.now.utc.to_i) if project
|
@@ -3,13 +3,7 @@
|
|
3
3
|
module SkullIsland
|
4
4
|
module RSpec
|
5
5
|
# A Fake API Client for RSpec testing
|
6
|
-
class FakeAPIClient
|
7
|
-
attr_reader :server, :base_uri
|
8
|
-
attr_accessor :username, :password
|
9
|
-
|
10
|
-
include Validations::APIClient
|
11
|
-
include Helpers::APIClient
|
12
|
-
|
6
|
+
class FakeAPIClient < APIClientBase
|
13
7
|
def initialize(opts = {})
|
14
8
|
# validations
|
15
9
|
validate_opts(opts)
|
@@ -22,39 +16,12 @@ module SkullIsland
|
|
22
16
|
@configured = true
|
23
17
|
end
|
24
18
|
|
25
|
-
def hash(data)
|
26
|
-
if data
|
27
|
-
Digest::MD5.hexdigest(data.sort.to_s)
|
28
|
-
else
|
29
|
-
''
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
19
|
def response_for(type, uri, data: nil, response: {})
|
34
|
-
|
35
|
-
@responses[type.to_s] ||= {}
|
36
|
-
key = data ? uri.to_s + hash(data) : uri.to_s
|
37
|
-
@responses[type.to_s][key] = response
|
38
|
-
end
|
39
|
-
|
40
|
-
def get(uri, _data = nil)
|
41
|
-
@responses ||= {}
|
42
|
-
@responses.dig('get', uri.to_s)
|
43
|
-
end
|
44
|
-
|
45
|
-
def post(uri, data = nil)
|
46
|
-
@responses ||= {}
|
47
|
-
@responses.dig('post', uri.to_s + hash(data))
|
48
|
-
end
|
49
|
-
|
50
|
-
def patch(uri, data)
|
51
|
-
@responses ||= {}
|
52
|
-
@responses.dig('patch', uri.to_s + hash(data))
|
20
|
+
connection.response_for(type, uri, data: data, response: response)
|
53
21
|
end
|
54
22
|
|
55
|
-
def
|
56
|
-
@
|
57
|
-
@responses.dig('put', uri.to_s + hash(data))
|
23
|
+
def connection
|
24
|
+
@connection ||= FakeRestClient.new
|
58
25
|
end
|
59
26
|
end
|
60
27
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SkullIsland
|
4
|
+
module RSpec
|
5
|
+
module FakeClient
|
6
|
+
# A Fake Rest Client Request for RSpec testing
|
7
|
+
class Request
|
8
|
+
attr_reader :uri
|
9
|
+
|
10
|
+
def initialize(rest_client, uri)
|
11
|
+
@rest_client = rest_client
|
12
|
+
@uri = uri
|
13
|
+
end
|
14
|
+
|
15
|
+
def hash(data)
|
16
|
+
@rest_client.hash(JSON.parse(data))
|
17
|
+
end
|
18
|
+
|
19
|
+
def responses
|
20
|
+
@rest_client.responses
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(_data = nil, _opts = nil)
|
24
|
+
responses.dig('get', uri.to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
def post(data = nil, _opts = nil)
|
28
|
+
responses.dig('post', uri.to_s + hash(data))
|
29
|
+
end
|
30
|
+
|
31
|
+
def patch(data, _opts = nil)
|
32
|
+
responses.dig('patch', uri.to_s + hash(data))
|
33
|
+
end
|
34
|
+
|
35
|
+
def put(data, _opts = nil)
|
36
|
+
responses.dig('put', uri.to_s + hash(data))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SkullIsland
|
4
|
+
module RSpec
|
5
|
+
# A Fake Rest Client for RSpec testing
|
6
|
+
class FakeRestClient
|
7
|
+
attr_reader :responses
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@responses = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def hash(data)
|
14
|
+
if data
|
15
|
+
Digest::MD5.hexdigest(data.sort.to_s)
|
16
|
+
else
|
17
|
+
''
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def response_for(type, uri, data: nil, response: {})
|
22
|
+
@responses[type.to_s] ||= {}
|
23
|
+
key = data ? uri.to_s + hash(data) : uri.to_s
|
24
|
+
@responses[type.to_s][key] = JSON.dump(response)
|
25
|
+
end
|
26
|
+
|
27
|
+
def [](uri)
|
28
|
+
FakeClient::Request.new(self, uri)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/skull_island/rspec.rb
CHANGED
data/lib/skull_island/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skull_island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deepsort
|
@@ -277,6 +277,8 @@ files:
|
|
277
277
|
- lib/skull_island/resources/upstream_target.rb
|
278
278
|
- lib/skull_island/rspec.rb
|
279
279
|
- lib/skull_island/rspec/fake_api_client.rb
|
280
|
+
- lib/skull_island/rspec/fake_client/request.rb
|
281
|
+
- lib/skull_island/rspec/fake_rest_client.rb
|
280
282
|
- lib/skull_island/simple_api_client.rb
|
281
283
|
- lib/skull_island/validations/api_client.rb
|
282
284
|
- lib/skull_island/validations/resource.rb
|