class Vantiv::Certification::ValidationTestRunner
Constants
- ENDPOINT_RESPONSE_OBJECT
Attributes
certs_file[R]
filter_by[R]
Public Class Methods
new(save_to:, filter_by: '')
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 24 def initialize(save_to:, filter_by: '') @certs_file = save_to @filter_by = filter_by end
run(save_to:, filter_by: '')
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 20 def self.run(save_to:, filter_by: '') new(save_to: save_to, filter_by: filter_by).run end
Public Instance Methods
run()
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 29 def run fixtures.each do |file_name| cert_name = get_cert_name(file_name) next if filter_by && !/#{filter_by}_\d*/.match(cert_name) contents = JSON.parse(File.read(file_name)) run_request( cert_name: cert_name, endpoint: Vantiv::Api::Endpoints.const_get(contents["endpoint"]), body: create_body(contents["body"]) ) end shutdown end
Private Instance Methods
create_body(base_body)
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 48 def create_body(base_body) compiled_base = request_body_compiler.compile(base_body) request_body = Vantiv::Api::RequestBody.new RequestBodyRepresenter.new(request_body).from_json(compiled_base.to_json) end
fixtures()
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 54 def fixtures @fixtures ||= Dir.glob("#{Vantiv.root}/cert_fixtures/**/*") end
get_cert_name(file_name)
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 58 def get_cert_name(file_name) /.*\/cert_fixtures\/(\w*).json/.match(file_name)[1] end
get_transaction_id(response)
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 120 def get_transaction_id(response) transaction_response_name = response.send(:transaction_response_name) transaction_response = response.body.send(transaction_response_name) transaction_response.transaction_id end
paypage_driver()
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 62 def paypage_driver @paypage_driver ||= Vantiv::Certification::PaypageDriver.new.start end
request_body_compiler()
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 74 def request_body_compiler @request_body_compiler ||= CertRequestBodyCompiler.new( { regex: /.*\$\{eProtect\.(.*)\}.*/, fetcher: lambda do |value, match| value.gsub( /.*\$\{eProtect\.#{match}\}.*/, paypage_driver.get_paypage_registration_id(match) ) end }, { regex: /.*\#\{(.*)\}.*/, fetcher: lambda do |value, match| value.gsub( /\#\{#{match}\}/, response_cache.access_value(match.split(".")) ) end } ) end
response_cache()
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 66 def response_cache @response_cache ||= Vantiv::Certification::ResponseCache.new end
results_file()
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 70 def results_file @results_file ||= File.open(certs_file, "w") end
run_request(cert_name:, endpoint:, body:)
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 102 def run_request(cert_name:, endpoint:, body:) response = Vantiv::Api::Request.new( endpoint: endpoint, body: body, response_object: ENDPOINT_RESPONSE_OBJECT.fetch(endpoint) ).run if response.api_level_failure? error_message = "CERT FAILED: #{cert_name} \n WITH: #{response.raw_body}" raise StandardError.new(error_message) end transaction_id = get_transaction_id(response) response_cache.push(cert_name, response) results_file << "#{cert_name},#{transaction_id}\n" end
shutdown()
click to toggle source
# File lib/vantiv/certification/validation_test_runner.rb, line 97 def shutdown paypage_driver.stop results_file.close end