Skip to content

Commit

Permalink
Debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec committed Sep 6, 2024
1 parent a7cb5ed commit a68f3ce
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,73 +21,73 @@
end
end

# notifier_name = Maze::Helper.read_key_path(validator.body, 'notifier.name')
# if notifier_name.nil? || !notifier_name.eql?('Bugsnag Go')
# validator.success = false
# validator.errors << "Notifier name in body was expected to be 'Bugsnag Go', but was '#{notifier_name}'"
# end
notifier_name = Maze::Helper.read_key_path(validator.body, 'notifier.name')
if notifier_name.nil? || !notifier_name.eql?('Bugsnag Go')
validator.success = false
validator.errors << "Notifier name in body was expected to be 'Bugsnag Go', but was '#{notifier_name}'"
end

# error_elements = ['notifier.url', 'notifier.version', 'events']
# error_elements_present = error_elements.all? do |element_key|
# element = Maze::Helper.read_key_path(validator.body, element)
# !element.nil? && (!element.is_a?(Array) || !element.empty?)
# end
error_elements = ['notifier.url', 'notifier.version', 'events']
error_elements_present = error_elements.all? do |element_key|
element = Maze::Helper.read_key_path(validator.body, element)
!element.nil? && (!element.is_a?(Array) || !element.empty?)
end

# unless error_elements_present
# validator.success = false
# validator.errors << "Not all of the error payload elements were present"
# end
unless error_elements_present
validator.success = false
validator.errors << "Not all of the error payload elements were present"
end

# event_elements = ['severity', 'severityReason.type', 'unhandled', 'exceptions']
# events = Maze::Helper.read_key_path(validator.body, 'events')
# event_elements_present = events.all? do |event|
# event_elements.all? do |element_key|
# element = Maze::Helper.read_key_path(event, element_key)
# !element.nil?
# end
# end
event_elements = ['severity', 'severityReason.type', 'unhandled', 'exceptions']
events = Maze::Helper.read_key_path(validator.body, 'events')
event_elements_present = events.all? do |event|
event_elements.all? do |element_key|
element = Maze::Helper.read_key_path(event, element_key)
!element.nil?
end
end

# unless event_elements_present
# validator.success = false
# validator.errors << "Not all of the event elements were present"
# end
unless event_elements_present
validator.success = false
validator.errors << "Not all of the event elements were present"
end
pp "Error validation complete"
pp validator.success
pp validator.errors
end

# Maze.config.add_validator('session') do |validator|
# pp "Running session validation"
# validator.validate_header('Bugsnag-Api-Key') { |value| value.eql?($api_key) }
# validator.validate_header('Content-Type') { |value| value.eql?('application/json') }
# validator.validate_header('Bugsnag-Payload-Version') { |value| value.eql?('1.0') }
# validator.validate_header('Bugsnag-Sent-At') do |value|
# begin
# Date.iso8601(date)
# rescue Date::Error
# validator.success = false
# validator.errors << "bugsnag-sent-at header was expected to be an IOS 8601 date, but was '#{date}'"
# end
# end
Maze.config.add_validator('session') do |validator|
pp "Running session validation"
validator.validate_header('Bugsnag-Api-Key') { |value| value.eql?($api_key) }
validator.validate_header('Content-Type') { |value| value.eql?('application/json') }
validator.validate_header('Bugsnag-Payload-Version') { |value| value.eql?('1.0') }
validator.validate_header('Bugsnag-Sent-At') do |value|
begin
Date.iso8601(date)
rescue Date::Error
validator.success = false
validator.errors << "bugsnag-sent-at header was expected to be an IOS 8601 date, but was '#{date}'"
end
end

# notifier_name = Maze::Helper.read_key_path(validator.body, 'notifier.name')
# if notifier_name.nil? || !notifier_name.eql?('Bugsnag Go')
# validator.success = false
# validator.errors << "Notifier name in body was expected to be 'Bugsnag Go', but was '#{notifier_name}'"
# end
notifier_name = Maze::Helper.read_key_path(validator.body, 'notifier.name')
if notifier_name.nil? || !notifier_name.eql?('Bugsnag Go')
validator.success = false
validator.errors << "Notifier name in body was expected to be 'Bugsnag Go', but was '#{notifier_name}'"
end

# session_elements = ['notifier.url', 'notifier.version', 'events']
# session_elements_present = session_elements.all? do |element_key|
# element = Maze::Helper.read_key_path(validator.body, element)
# !element.nil? && (!element.is_a?(Array) || !element.empty?)
# end
session_elements = ['notifier.url', 'notifier.version', 'events']
session_elements_present = session_elements.all? do |element_key|
element = Maze::Helper.read_key_path(validator.body, element)
!element.nil? && (!element.is_a?(Array) || !element.empty?)
end

# unless session_elements_present
# validator.success = false
# validator.errors << "Not all of the session payload elements were present"
# end
unless session_elements_present
validator.success = false
validator.errors << "Not all of the session payload elements were present"
end

# pp "Session validation complete"
# pp validator.success
# pp validator.errors
# end
pp "Session validation complete"
pp validator.success
pp validator.errors
end

0 comments on commit a68f3ce

Please sign in to comment.