active_elastic_job 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 23ebae0278f2915ef56c50b3387a2d862c697a0a
         | 
| 4 | 
            +
              data.tar.gz: 60f652aab799782e51bfe1eaae1fcc7c12abb234
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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  | 
| 48 | 
            -
                      encoded[name] << encode_length_and_string(string_value)
         | 
| 49 | 
            -
                    elsif  | 
| 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 ,
         | 
| @@ -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 | 
| 69 | 
            -
                        "on the original request | 
| 70 | 
            -
                        "#{message_id} sent to SQS might be  | 
| 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 | 
            -
                       | 
| 167 | 
            -
             | 
| 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 | 
            -
                         | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 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. | 
| 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- | 
| 11 | 
            +
            date: 2016-02-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: aws-sdk
         |