Sha256: ca875c7869055d9dc6f44bd7502fc5fbe4d46525a3d90806e8727bec6af779f3

Contents?: true

Size: 1.32 KB

Versions: 12

Compression:

Stored size: 1.32 KB

Contents

class ResponseHeaderChecker < Checker

  # checks given header against the given expepctation and returns a result object
  def check
    result = Result.new(@testcase, @response)
    begin
      @testcase.response_expectation['headers'].each_pair do |header_name, header_value|
        if is_regex?(header_value)
          if not (excluded?(header_name) or regex_matches?(header_value, @response.headers[header_name]))
            result.succeeded = false
            result.error_message = " expected header identifier --#{header_name}-- to match regex --#{header_value}--\n got --#{@response.headers[header_name]}--"
          end
        else
          if not (excluded?(header_name) or string_matches?(header_value, @response.headers[header_name]))
            result.succeeded = false
            result.error_message = " expected header identifier --#{header_name}-- to match --#{header_value}--\n got --#{@response.headers[header_name]}--"
          end
        end
      end unless (@testcase.response_expectation['headers'].nil? or @testcase.response_expectation['headers'].empty?)
     rescue Exception => e
       result.succeeded = false
       result.error_message = " unexpected error while parsing testcase/response. Check your testcase format!"
       result.error_message = "\n\nException occured: #{e}"
     end
    result
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
apirunner-0.4.6 lib/plugins/plug03_response_header_checker.rb
apirunner-0.4.5 lib/plugins/plug03_response_header_checker.rb
apirunner-0.4.4 lib/plugins/plug03_response_header_checker.rb
apirunner-0.4.3 lib/plugins/plug03_response_header_checker.rb
apirunner-0.4.2 lib/plugins/plug03_response_header_checker.rb
apirunner-0.4.1 lib/plugins/plug03_response_header_checker.rb
apirunner-0.4.0 lib/plugins/plug03_response_header_checker.rb
apirunner-0.3.10 lib/plugins/plug03_response_header_checker.rb
apirunner-0.3.9 lib/plugins/plug03_response_header_checker.rb
apirunner-0.3.8 lib/plugins/plug03_response_header_checker.rb
apirunner-0.3.7 lib/plugins/plug03_response_header_checker.rb
apirunner-0.3.6 lib/plugins/plug03_response_header_checker.rb