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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc28c229371cd2d9f0cfef962e87ac95f27da4bd38d4a1990d2ba43ff0b9c275
4
- data.tar.gz: 2d61dbedf12cca6c6d05c4b587a842dd0251d04182db207b14767f6b1aa34f1d
3
+ metadata.gz: 9041d8426e20bd746ce9efe08b5b16a30e6b3ce4f176246c207e45e450321262
4
+ data.tar.gz: a31475d45dc6cf1716bd8512fd0e1e7014dfa63c080f0197ae533bdfbcdc9ef5
5
5
  SHA512:
6
- metadata.gz: 100978336f6bbb9b8c7ef129c84ce98cf32139564e44818024ba4026118bbd5e75895a03e1ecd66bea299ef7bc0d9d3f7c424340d1676850e11b6af44bba5a1d
7
- data.tar.gz: f1b508505ac2dbbfaab2e1091cc4c59f9b7be19337b44ee38de9132bc6ef05c3db5306563d0fe40c7350e3bf3041c93316759f51cacb470812e5163d8c35204b
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.10)
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.8.0)
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.17.0)
65
- parser (2.6.4.0)
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.8.0)
78
- rspec-core (~> 3.8.0)
79
- rspec-expectations (~> 3.8.0)
80
- rspec-mocks (~> 3.8.0)
81
- rspec-core (3.8.2)
82
- rspec-support (~> 3.8.0)
83
- rspec-expectations (3.8.4)
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.8.0)
86
- rspec-mocks (3.8.1)
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.8.0)
89
- rspec-support (3.8.2)
90
- rubocop (0.74.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.0)
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.8)
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 = data[key].is_a?(String) ? eval(Erubi::Engine.new(data[key]).src) : data[key]
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 = resource_data['config'].deep_sort if resource_data['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 = rdata['hosts'] if rdata['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 = rdata['snis'] if rdata['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
- @responses ||= {}
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 put(uri, data)
56
- @responses ||= {}
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
@@ -1,3 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'skull_island/rspec/fake_client/request'
4
+ require 'skull_island/rspec/fake_rest_client'
3
5
  require 'skull_island/rspec/fake_api_client'
@@ -4,6 +4,6 @@ module SkullIsland
4
4
  VERSION = [
5
5
  1, # Major
6
6
  2, # Minor
7
- 10 # Patch
7
+ 11 # Patch
8
8
  ].join('.')
9
9
  end
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.10
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-09-12 00:00:00.000000000 Z
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