tshield 0.5.2.0 → 0.6.0.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
  SHA1:
3
- metadata.gz: b0b94c2d88dce848c777da771bf9998367c34614
4
- data.tar.gz: 7bf66c15f1956234c3f50237ea151eadc9248637
3
+ metadata.gz: 19c70680e289c5c8b514feeca2fc6a276fc7edc8
4
+ data.tar.gz: 68c61ad023d98d721bf2c88570e1f3170823b968
5
5
  SHA512:
6
- metadata.gz: f22f267fe74d698b0f26648f41422bb500db7f3aae9691e66f5a35025d27c424bcca5d94381e238b029747208aef31494dbca806a2edde5da9e76c2b644e0df0
7
- data.tar.gz: 8ba0e3ccbd325d415564b9f0d77424ecfdc781427caecb904053a78a61d5e44a2e3d2d12cfe7f6732268b0b8533ebc2fa1c13ed0409c19cda46730b413f02260
6
+ metadata.gz: 257777b038cf582aaf4d62e354a11cf976e0bdf55f3f018b3f8c60e1c18d7be81331570bd70a26e0ce461b9c5082f7840371fd7b5bf83187cdbc7865a2147ef1
7
+ data.tar.gz: 12df75edf9427185e53f67b12d01fab27b015735d78b62a0cf8489b1108f6e8d3af009f25035272d36502c000930b9b78780b59705983e0043da72b13d21fd18
data/README.md CHANGED
@@ -0,0 +1,60 @@
1
+ TShield
2
+ =======
3
+
4
+ ## Install
5
+
6
+ gem install tshield
7
+
8
+ ## Using
9
+
10
+ To run server execute this command
11
+
12
+ tshield
13
+
14
+ ### Config example
15
+
16
+ Before run `tshield` command is necessary to create config file.
17
+ This is an example of `config/tshield.yml`
18
+
19
+ ```yaml
20
+ request:
21
+ # wait time for real service
22
+ timeout: 8
23
+
24
+ # list of domains that will be used
25
+ domains:
26
+ # Base URI of service
27
+ 'https://service.com':
28
+ # name to identify the domain in the generated files
29
+ name: 'service'
30
+
31
+ # paths list of all services that will be called
32
+ paths:
33
+ - /users
34
+ ```
35
+
36
+ ### Custom controllers
37
+
38
+ All custom controller should be created in `controllers` directory.
39
+
40
+ Example of controller file called `controllers/foo_controller.rb`
41
+
42
+ ```ruby
43
+ require 'json'
44
+ require 'tshield/controller'
45
+
46
+ module FooController
47
+ include TShield::Controller
48
+ action :tracking, methods: [:post], path: '/foo'
49
+
50
+ module Actions
51
+ def tracking(params, request)
52
+ status 201
53
+ headers 'Content-Type' => 'application/json'
54
+ {message: 'foo'}.to_json
55
+ end
56
+ end
57
+ end
58
+ ```
59
+
60
+
data/bin/tshield CHANGED
@@ -3,5 +3,16 @@
3
3
  require 'tshield'
4
4
 
5
5
  TShield::Options.init
6
- TShield::Server.run!
6
+
7
+ tshield = Thread.new {TShield::Server.run!}
8
+
9
+ configuration = TShield::Configuration.load_configuration
10
+ (configuration.tcp_servers || []).each do |tcp_server|
11
+ puts "initializing #{tcp_server['name']}"
12
+ require "./servers/#{tcp_server['file']}"
13
+ klass = Object.const_get(tcp_server['name'])
14
+ Thread.new { klass.new.listen(tcp_server['port']) }
15
+ end
16
+
17
+ tshield.join
7
18
 
data/lib/tshield.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'tshield/simple_tcp_server'
1
2
  require 'tshield/server'
2
3
  require 'tshield/options'
3
4
 
@@ -5,6 +5,7 @@ module TShield
5
5
 
6
6
  attr_accessor :request
7
7
  attr_accessor :domains
8
+ attr_accessor :tcp_servers
8
9
  attr_writer :session_path
9
10
 
10
11
  def initialize(attributes)
@@ -36,9 +37,6 @@ module TShield
36
37
  domains[domain]['excluded_headers'] || []
37
38
  end
38
39
 
39
- def options(path)
40
- end
41
-
42
40
  def session_path
43
41
  @session_path || '/sessions'
44
42
  end
@@ -20,6 +20,7 @@ module TShield
20
20
  @options = options
21
21
  @configuration = TShield::Configuration.singleton
22
22
  @options[:timeout] = @configuration.request['timeout']
23
+ @options[:verify] = @configuration.request['verify_ssl'] == 'true'
23
24
  request
24
25
  end
25
26
 
@@ -0,0 +1,27 @@
1
+ require 'socket'
2
+
3
+ module TShield
4
+ class SimpleTCPServer
5
+ def initialize
6
+ @running = true
7
+ end
8
+
9
+ def on_connect(client)
10
+ raise 'should implement method on_connect'
11
+ end
12
+
13
+ def close
14
+ @running = false
15
+ end
16
+
17
+ def listen(port)
18
+ puts "listening #{port}"
19
+ @server = TCPServer.new(port)
20
+ while @running
21
+ client = @server.accept
22
+ on_connect(client)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
@@ -1,8 +1,8 @@
1
1
  module TShield
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 5
5
- PATCH = 2
4
+ MINOR = 6
5
+ PATCH = 0
6
6
  PRE = 0
7
7
 
8
8
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tshield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2.0
4
+ version: 0.6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Rubin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-03 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -201,6 +201,7 @@ files:
201
201
  - lib/tshield/response.rb
202
202
  - lib/tshield/server.rb
203
203
  - lib/tshield/sessions.rb
204
+ - lib/tshield/simple_tcp_server.rb
204
205
  - lib/tshield/version.rb
205
206
  - lib/tshield/views/admin/requests/index.haml
206
207
  - lib/tshield/views/admin/requests/show.haml
@@ -231,12 +232,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
232
  version: '0'
232
233
  requirements: []
233
234
  rubyforge_project:
234
- rubygems_version: 2.4.8
235
+ rubygems_version: 2.5.2.1
235
236
  signing_key:
236
237
  specification_version: 4
237
238
  summary: Proxy for mocks API responses
238
239
  test_files:
239
- - spec/spec_helper.rb
240
- - spec/tshield/fixtures/config/tshield.yml
241
240
  - spec/tshield/configuration_spec.rb
241
+ - spec/tshield/fixtures/config/tshield.yml
242
242
  - spec/tshield/request_spec.rb
243
+ - spec/spec_helper.rb