tshield 0.13.4.0 → 0.13.5.0

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: 66ce1246fb18f0ac3ca8988aa3dcbdaf6ac93f3605181bffd79ad0b831bf94c5
4
- data.tar.gz: a640d69531493ef2c8513377b1671e51b9f2d231a0eeaf158b175526a42f45f9
3
+ metadata.gz: ab5c5057fe81ae295f572912c6955ce0ea0bd9be6b42fb515a7832fe3451459a
4
+ data.tar.gz: 9c785dc23adb245fdfcc416698c551f7a45eaa32b5892a2cabea708f16fa2859
5
5
  SHA512:
6
- metadata.gz: ec4005538a4fdbe3352874f7485e8e60303ab2e8a51441621cd181d73dd236267d08d03363052632e794f1701e6de0eafaa9448a6ca8cabec7680505e1902234
7
- data.tar.gz: 319ccdbccc47a05d783403de7fff5022f928520f18d1aedb06929de0b40f1d6a74e6db94219835f8e8edd15636acbc0ff3f3d2999a787446420fdda916e3bf12
6
+ metadata.gz: 58fd33ddf9e466af5882e6522612b2b0fa05c95f728578fe50b014dca0777357bf5ccfa17605a86309c5742cb828dd2e52eb9bb2839096f594e1e75fef80e81b
7
+ data.tar.gz: f085f1dcc7a3d861da1b28a0d07f3338f03dd5b27cdd234c283cecf0bce8a0dc66f26193755ea8f5b442cbf4953fb2bd4ce295f90257b76121ac7fdbcbdd38b0
@@ -65,6 +65,10 @@ module TShield
65
65
  nil
66
66
  end
67
67
 
68
+ def windows_compatibility?
69
+ windows_compatibility || false
70
+ end
71
+
68
72
  def get_headers(domain)
69
73
  (domains[domain] || {})['headers'] || {}
70
74
  end
@@ -109,10 +113,6 @@ module TShield
109
113
  session_path || '/sessions'
110
114
  end
111
115
 
112
- def get_questionmark_char
113
- windows_compatibility ? '%3f' : '?'
114
- end
115
-
116
116
  def grpc
117
117
  defaults = { 'port' => 5678, 'proto_dir' => 'proto', 'services' => {} }
118
118
  defaults.merge(@grpc || {})
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'tshield/configuration'
3
4
  require 'tshield/sessions'
4
5
 
5
6
  module TShield
6
7
  module Grpc
7
8
  module VCR
9
+ def initialize
10
+ @configuration = TShield::Configuration.singleton
11
+ end
8
12
  def handler_in_vcr_mode(method_name, request, parameters, options)
9
13
  parameters.peer =~ /ipv6:\[(.+?)\]|ipv4:(.+?):/
10
14
  peer = Regexp.last_match(1) || Regexp.last_match(2)
@@ -31,6 +35,10 @@ module TShield
31
35
  response
32
36
  end
33
37
 
38
+ def encode_colon(value)
39
+ value.gsub(':','%3a')
40
+ end
41
+
34
42
  def saved_response(path)
35
43
  response_file = File.join(path, 'response')
36
44
  return false unless File.exist? response_file
@@ -58,6 +66,7 @@ module TShield
58
66
 
59
67
  def complete_path(module_name, method_name, request)
60
68
  @session_name = (@session || {})[:name]
69
+ module_name = @configuration.windows_compatibility? ? encode_colon(module_name) : module_name
61
70
  path = ['requests', 'grpc', @session_name, module_name, method_name.to_s, hexdigest(request)].compact
62
71
  path
63
72
  end
@@ -155,14 +155,23 @@ module TShield
155
155
  content[:body] = body
156
156
  end
157
157
 
158
+ def encode_for_windows_dir(directory)
159
+ replace = [['<','%3c'],['>','%3e'],[':','%3a'],['"','%22'],['?','%3f'],[' ','%20'],['*','%2a'],['/','%2f']]
160
+ replace.each do |value|
161
+ directory = directory.gsub(value.first,value.last)
162
+ end
163
+ directory
164
+ end
165
+
158
166
  def safe_dir(url)
159
167
  if url.size > 225
160
168
  path = url.gsub(/(\?.*)/, '')
161
169
  params = Digest::SHA1.hexdigest Regexp.last_match(1)
162
- "#{path.gsub(%r{/}, '-').gsub(/^-/, '')}#{configuration.get_questionmark_char}#{params}"
170
+ directory = "#{path.gsub(%r{/}, '-').gsub(/^-/, '')}?#{params}"
163
171
  else
164
- url.gsub(%r{/}, '-').gsub(/^-/, '').gsub('?', configuration.get_questionmark_char)
172
+ directory = url.gsub(%r{/}, '-').gsub(/^-/, '')
165
173
  end
174
+ configuration.windows_compatibility? ? encode_for_windows_dir(directory) : directory
166
175
  end
167
176
  end
168
177
  end
@@ -5,7 +5,7 @@ module TShield
5
5
  class Version
6
6
  MAJOR = 0
7
7
  MINOR = 13
8
- PATCH = 4
8
+ PATCH = 5
9
9
  PRE = 0
10
10
 
11
11
  class << self
@@ -71,7 +71,7 @@ describe TShield::Configuration do
71
71
  TShield::Configuration.clear
72
72
  @configuration = TShield::Configuration.singleton
73
73
 
74
- expect(@configuration.get_questionmark_char).to eq('%3f')
74
+ expect(@configuration.windows_compatibility?).to eq(true)
75
75
  end
76
76
 
77
77
  it 'should be compatible with Unix when configuration is false' do
@@ -79,7 +79,7 @@ describe TShield::Configuration do
79
79
  TShield::Configuration.clear
80
80
  @configuration = TShield::Configuration.singleton
81
81
 
82
- expect(@configuration.get_questionmark_char).to eq('?')
82
+ expect(@configuration.windows_compatibility?).to eq(false)
83
83
  end
84
84
 
85
85
  it 'should be compatible with Unix when configuration is missing' do
@@ -87,7 +87,7 @@ describe TShield::Configuration do
87
87
  TShield::Configuration.clear
88
88
  @configuration = TShield::Configuration.singleton
89
89
 
90
- expect(@configuration.get_questionmark_char).to eq('?')
90
+ expect(@configuration.windows_compatibility?).to eq(false)
91
91
  end
92
92
 
93
93
  end
@@ -81,7 +81,7 @@ describe TShield::RequestVCR do
81
81
  }
82
82
  )
83
83
 
84
- allow(@configuration).to receive(:get_questionmark_char).and_return('?')
84
+ allow(@configuration).to receive(:windows_compatibility?).and_return(false)
85
85
 
86
86
  allow(HTTParty).to receive(:send).and_return(RawResponse.new)
87
87
  file_double = double
@@ -106,14 +106,13 @@ describe TShield::RequestVCR do
106
106
  end
107
107
 
108
108
  it 'should create response directory in windows standard' do
109
-
110
109
  allow(@configuration).to receive(:domains).and_return(
111
110
  'example.org' => {
112
111
  'skip_query_params' => []
113
112
  }
114
113
  )
115
114
 
116
- allow(@configuration).to receive(:get_questionmark_char).and_return('%3f')
115
+ allow(@configuration).to receive(:windows_compatibility?).and_return(true)
117
116
 
118
117
  allow(HTTParty).to receive(:send).and_return(RawResponse.new)
119
118
  file_double = double
@@ -150,7 +149,6 @@ describe TShield::RequestVCR do
150
149
  call: 0
151
150
  end
152
151
 
153
-
154
152
  end
155
153
  end
156
154
 
data/tshield.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency('grpc-tools', '~> 1.28', '>= 1.28.0')
29
29
  s.add_dependency('httparty', '~> 0.14', '>= 0.14.0')
30
30
  s.add_dependency('json', '~> 2.0', '>= 2.0')
31
- s.add_dependency('puma', '~> 4.3', '>= 4.3.3')
31
+ s.add_dependency('puma', '>= 4.3.3', '< 6.0')
32
32
  s.add_dependency('sinatra', '~> 2.1', '>= 2.1.0')
33
33
  s.add_dependency('sinatra-cross_origin', '~> 0.4.0', '>= 0.4')
34
34
  s.add_development_dependency('coveralls', '~> 0.8', '>= 0.8.23')
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tshield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.4.0
4
+ version: 0.13.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Rubin
8
8
  - Eduardo Garcia
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-04-15 00:00:00.000000000 Z
12
+ date: 2021-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: grpc
@@ -95,22 +95,22 @@ dependencies:
95
95
  name: puma
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - "~>"
99
- - !ruby/object:Gem::Version
100
- version: '4.3'
101
98
  - - ">="
102
99
  - !ruby/object:Gem::Version
103
100
  version: 4.3.3
101
+ - - "<"
102
+ - !ruby/object:Gem::Version
103
+ version: '6.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '4.3'
111
108
  - - ">="
112
109
  - !ruby/object:Gem::Version
113
110
  version: 4.3.3
111
+ - - "<"
112
+ - !ruby/object:Gem::Version
113
+ version: '6.0'
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: sinatra
116
116
  requirement: !ruby/object:Gem::Requirement
@@ -435,9 +435,7 @@ files:
435
435
  - spec/tshield/fixtures/config/tshield-without-grpc.yml
436
436
  - spec/tshield/fixtures/config/tshield.yml
437
437
  - spec/tshield/fixtures/filters/example_filter.rb
438
- - spec/tshield/fixtures/matching/empty.json
439
438
  - spec/tshield/fixtures/matching/example.json
440
- - spec/tshield/fixtures/matching/invalid_matching_file.json
441
439
  - spec/tshield/fixtures/proto/test_services_pb.rb
442
440
  - spec/tshield/grpc_spec.rb
443
441
  - spec/tshield/options_spec.rb
@@ -449,7 +447,7 @@ homepage: https://github.com/diegorubin/tshield
449
447
  licenses:
450
448
  - MIT
451
449
  metadata: {}
452
- post_install_message:
450
+ post_install_message:
453
451
  rdoc_options: []
454
452
  require_paths:
455
453
  - lib
@@ -464,26 +462,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
464
462
  - !ruby/object:Gem::Version
465
463
  version: '0'
466
464
  requirements: []
467
- rubygems_version: 3.0.8
468
- signing_key:
465
+ rubygems_version: 3.0.3.1
466
+ signing_key:
469
467
  specification_version: 4
470
468
  summary: Proxy for mocks API responses
471
469
  test_files:
472
- - spec/tshield/options_spec.rb
473
470
  - spec/tshield/controllers/requests_spec.rb
474
- - spec/tshield/configuration_spec.rb
475
471
  - spec/tshield/after_filter_spec.rb
476
- - spec/tshield/request_vcr_spec.rb
477
- - spec/tshield/sessions_spec.rb
478
- - spec/tshield/request_matching_spec.rb
479
- - spec/tshield/grpc_spec.rb
472
+ - spec/tshield/configuration_spec.rb
473
+ - spec/tshield/fixtures/proto/test_services_pb.rb
480
474
  - spec/tshield/fixtures/config/tshield-without-grpc.yml
481
- - spec/tshield/fixtures/config/tshield.yml
482
475
  - spec/tshield/fixtures/config/tshield-with-send-content-type-header_as_false.yml
476
+ - spec/tshield/fixtures/config/tshield.yml
483
477
  - spec/tshield/fixtures/config/tshield-with-send-content-type-header.yml
484
- - spec/tshield/fixtures/proto/test_services_pb.rb
485
- - spec/tshield/fixtures/filters/example_filter.rb
486
- - spec/tshield/fixtures/matching/empty.json
487
- - spec/tshield/fixtures/matching/invalid_matching_file.json
488
478
  - spec/tshield/fixtures/matching/example.json
479
+ - spec/tshield/fixtures/filters/example_filter.rb
480
+ - spec/tshield/request_vcr_spec.rb
481
+ - spec/tshield/sessions_spec.rb
482
+ - spec/tshield/grpc_spec.rb
483
+ - spec/tshield/options_spec.rb
484
+ - spec/tshield/request_matching_spec.rb
489
485
  - spec/spec_helper.rb
File without changes