active_elastic_job 1.4.1 → 1.4.2

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: f7f80373d7f57286083c91bfb62632d463df9b7a
4
- data.tar.gz: 30ad4c79acf1d9a8393092bdf430f7416b606239
3
+ metadata.gz: 23ebae0278f2915ef56c50b3387a2d862c697a0a
4
+ data.tar.gz: 60f652aab799782e51bfe1eaae1fcc7c12abb234
5
5
  SHA512:
6
- metadata.gz: 72d3f884abb6f6b16d0c43fe2c537ba64d80acba7e65ff2a97faaea99d16b4e6b45666aeb33f232b95cf227b8d16af172385bc9dfcc5d978720fe97f3ea6742a
7
- data.tar.gz: b5f4204e84cc39de88f67f321fbc758021b1fbcbb698cc7c991e1a1e0e14b0b9d6d177f92f92191840a01e9e72e29e4b5796886dfa4d2482e310889b89eafda1
6
+ metadata.gz: 6177ea2b5c0b2eaf15787a3421bb08696862a4b70e03f61702a1ddc0d3df059e1d89440b4cc70cfcb5c9b7d15304c68cbda832c386777710ca91a4aa7117fb5c
7
+ data.tar.gz: 630e3c61425608800d84e402a2de004ef65ec8424ce19df24be19c942eac75425a1389ac5502110af9042b3c541c2c5ae516516018e18c592c58e586df480543
@@ -44,10 +44,10 @@ module ActiveElasticJob
44
44
  encode_length_and_bytes(attribute[:data_type]) <<
45
45
  [TRANSPORT_TYPE_ENCODINGS[attribute[:data_type]]].pack('C'.freeze)
46
46
 
47
- if string_value = attribute[:string_value]
48
- encoded[name] << encode_length_and_string(string_value)
49
- elsif binary_value = attribute[:binary_value]
50
- encoded[name] << encode_length_and_bytes(binary_value)
47
+ if attribute[:string_value] != nil
48
+ encoded[name] << encode_length_and_string(attribute[:string_value])
49
+ elsif attribute[:binary_value] != nil
50
+ encoded[name] << encode_length_and_bytes(attribute[:binary_value])
51
51
  end
52
52
  end
53
53
 
@@ -40,11 +40,6 @@ module ActiveElasticJob
40
40
  '403',
41
41
  {CONTENT_TYPE_HEADER_NAME => 'text/plain' },
42
42
  ["incorrect digest"]]
43
- rescue StandardError => e
44
- return [
45
- '500',
46
- {CONTENT_TYPE_HEADER_NAME => 'text/plain' },
47
- [e.message]]
48
43
  end
49
44
  return [
50
45
  OK_RESPONSE_CODE ,
@@ -2,7 +2,7 @@ module ActiveElasticJob
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- TINY = 1
5
+ TINY = 2
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -64,10 +64,11 @@ which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon
64
64
  # Raised when calculated MD5 digest does not match the MD5 Digest
65
65
  # of the response from Amazon SQS.
66
66
  class MD5MismatchError < Error
67
- def initialize(message_id)
68
- msg = "MD5 returned by Amazon SQS does not match the calculation " <<
69
- "on the original request. The message with Message ID " <<
70
- "#{message_id} sent to SQS might be corrupted."
67
+ def initialize(message_id, calculated, returned)
68
+ msg = "MD5 '#{returned}' returned by Amazon SQS does not match the" <<
69
+ " calculation on the original request which was '#{calculated}'. " <<
70
+ "The message with Message ID #{message_id} sent to SQS might be " <<
71
+ "corrupted."
71
72
 
72
73
  super msg
73
74
  end
@@ -157,23 +158,29 @@ which exceeds the allowed maximum of #{MAX_MESSAGE_SIZE} bytes imposed by Amazon
157
158
  end
158
159
 
159
160
  def message_digest(messsage_body)
160
- secret_key_base = Rails.application.secrets[:secret_key_base]
161
161
  @verifier ||= ActiveElasticJob::MessageVerifier.new(secret_key_base)
162
162
  @verifier.generate_digest(messsage_body)
163
163
  end
164
164
 
165
165
  def verify_md5_digests!(response, messsage_body, message_attributes)
166
- if md5_of_message_body(messsage_body) != response.md5_of_message_body
167
- raise MD5MismatchError, response.message_id
166
+ calculated = md5_of_message_body(messsage_body)
167
+ returned = response.md5_of_message_body
168
+ if calculated != returned
169
+ raise MD5MismatchError.new response.message_id, calculated, returned
168
170
  end
169
171
 
170
172
  if message_attributes
171
- if md5_of_message_attributes(message_attributes) !=
172
- response.md5_of_message_attributes
173
- raise MD5MismatchError, response.message_id
173
+ calculated = md5_of_message_attributes(message_attributes)
174
+ returned = response.md5_of_message_attributes
175
+ if calculated != returned
176
+ raise MD5MismatchError.new response.message_id, calculated, returned
174
177
  end
175
178
  end
176
179
  end
180
+
181
+ def secret_key_base
182
+ @secret_key_base ||= Rails.application.secrets[:secret_key_base]
183
+ end
177
184
  end
178
185
  end
179
186
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_elastic_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tawan Sierek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-14 00:00:00.000000000 Z
11
+ date: 2016-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk