aranea 0.0.2 → 0.0.3

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
- SHA1:
3
- metadata.gz: 6a184b98902cedd5d8be59b73ee94754d5c0fa7b
4
- data.tar.gz: f872ebf508064ad595d241adab883a6395a417ca
2
+ SHA256:
3
+ metadata.gz: '019581a335c3958a31655effdf3af83cb79aa2987b9d79539a19d355b6643023'
4
+ data.tar.gz: d96ba0a406b2b69898747da9c6d03a91d9ac954fd948d53d5872109d4e4a9f4f
5
5
  SHA512:
6
- metadata.gz: 214640adf11d303b1e2a9596ddff42ce46742342c469dbbb8c811126716d14780f5719a189b3d528822930c2e094afcb104f3e44bb19253cf8a4f5262d4281f4
7
- data.tar.gz: 872111ae07fdffee852754d94e07f495ad17b0804a16d6e9940b761d6ea4a83077ab7d896bc17a7fcf3a75100f31ad6230d7fec78a7d1175ba6d2632be8bda09
6
+ metadata.gz: c5487fd366ef3dd6b4ed5cd0e4af82964e92babae887cb9d9dfdc8f08a200d8a17d7f5fc2e7d39e0b8ec31db7bd06421cb9f739ded22dc784a3de1b48c8a82ea
7
+ data.tar.gz: 832d65d2819bd27a0fb62256fbdc3eac4a44238a54b8669c184cd48336b362edb767931c780e6677324be2f203851430eea68b9f1cdecc790f54b471370c1ec9
@@ -1,5 +1,7 @@
1
1
  require 'faraday'
2
2
  require 'active_support/core_ext/numeric/time'
3
+ require 'json'
4
+
3
5
  module Aranea
4
6
 
5
7
  # TODO: Look into moving whitelisting of consumer hostnames to here and allowing it to be configurable via the consuming application
@@ -33,6 +35,8 @@ module Aranea
33
35
  def initialize(params)
34
36
  @pattern = Regexp.new(params[:pattern])
35
37
  @response = params[:failure]
38
+ @response_hash = params[:response_hash] || {}
39
+ @response_headers_hash = params[:response_headers_hash] || {}
36
40
  end
37
41
 
38
42
  def should_fail?(request_env, app)
@@ -45,7 +49,11 @@ module Aranea
45
49
  elsif @response == 'ssl_error'
46
50
  raise ::Faraday::SSLError, 'Fake failure from Aranea'
47
51
  else
48
- ::Faraday::Response.new(status: @response.to_i, body: 'Fake failure from Aranea', response_headers: {})
52
+ ::Faraday::Response.new(
53
+ status: @response.to_i,
54
+ body: @response_hash.to_json,
55
+ response_headers: @response_headers_hash
56
+ )
49
57
  end
50
58
  end
51
59
 
@@ -1,5 +1,6 @@
1
1
  require 'aranea/failure_repository'
2
2
  require 'rack'
3
+ require 'json'
3
4
 
4
5
  module Aranea
5
6
 
@@ -41,6 +42,12 @@ module Aranea
41
42
  dependency = options.fetch('dependency') { raise FailureFailure, 'Please provide a dependency to simulate failing' }
42
43
  minutes = options.fetch('minutes') { 5 }
43
44
  failure = options.fetch('failure') { '500' }
45
+ response = options.fetch('response') { '{}' } # Expect URI encoded
46
+ headers = options.fetch('headers') { '{}' }
47
+
48
+ # These will emit a parsing error if the response/headers URI encoded string is malformed.
49
+ response_hash = JSON.parse(CGI.unescape(response)).to_hash
50
+ response_headers_hash = JSON.parse(CGI.unescape(headers)).to_hash
44
51
 
45
52
  unless failure =~ /\A((4|5)\d\d|timeout|ssl_error)\Z/i
46
53
  raise FailureFailure, "failure should be a 4xx or 5xx status code, timeout, or ssl_error; got #{failure}"
@@ -50,7 +57,13 @@ module Aranea
50
57
  raise FailureFailure, "minutes should be an integer from #{ALLOWED_MINUTES.begin} to #{ALLOWED_MINUTES.end}, got #{minutes}"
51
58
  end
52
59
 
53
- Failure.create(pattern: dependency, minutes: minutes.to_i, failure: failure)
60
+ Failure.create(
61
+ pattern: dependency,
62
+ minutes: minutes.to_i,
63
+ failure: failure,
64
+ response_hash: response_hash,
65
+ response_headers_hash: response_headers_hash
66
+ )
54
67
 
55
68
  result = "For the next #{minutes} minutes, all requests to urls containing '#{dependency}' will #{failure.downcase}"
56
69
 
@@ -1,5 +1,5 @@
1
1
  module Aranea
2
2
 
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Weiner
8
8
  - Matthew Szenher
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-24 00:00:00.000000000 Z
12
+ date: 2021-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -127,7 +127,7 @@ homepage: https://github.com/mdsol/aranea
127
127
  licenses:
128
128
  - MIT
129
129
  metadata: {}
130
- post_install_message:
130
+ post_install_message:
131
131
  rdoc_options: []
132
132
  require_paths:
133
133
  - lib
@@ -142,9 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: 1.3.5
144
144
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.6.12
147
- signing_key:
145
+ rubygems_version: 3.2.16
146
+ signing_key:
148
147
  specification_version: 4
149
148
  summary: Middleware for fault tolerance testing
150
149
  test_files: []