Skip to content

Commit

Permalink
Merge pull request #248 from bugsnag/tests/builtin-error-validation
Browse files Browse the repository at this point in the history
Adds custom error validation
  • Loading branch information
Cawllec authored Sep 24, 2024
2 parents 82e2d24 + d251a0a commit f6b701e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gem "bugsnag-maze-runner", "~> 9.0"
gem "bugsnag-maze-runner", "~> 9.14"
2 changes: 0 additions & 2 deletions features/net-http/appversion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Scenario: A error report contains the configured app type when using a net http
And I open the URL "http://localhost:4512/handled"
And I wait to receive an error
And I should receive no sessions
And the error is valid for the error reporting API version "4" for the "Bugsnag Go" notifier
And the event "app.version" equals "3.1.2"

Scenario: A session report contains the configured app type when using a net http app
Expand All @@ -21,5 +20,4 @@ Scenario: A session report contains the configured app type when using a net htt
And I wait for the host "localhost" to open port "4512"
And I open the URL "http://localhost:4512/session"
And I wait to receive a session
And the session is valid for the session reporting API version "1.0" for the "Bugsnag Go" notifier
And the session payload field "app.version" equals "3.1.2"
3 changes: 0 additions & 3 deletions features/sessioncontext.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@ Scenario: An error report contains a session count when part of a session
Then I wait to receive 1 error
# one session is created on start
And I wait to receive 2 session
And the error is valid for the error reporting API version "4" for the "Bugsnag Go" notifier
And the session is valid for the session reporting API version "1.0" for the "Bugsnag Go" notifier
And I discard the oldest session
And the session is valid for the session reporting API version "1.0" for the "Bugsnag Go" notifier
And the session payload has a valid sessions array
23 changes: 22 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,25 @@
steps %(
When I configure the base endpoint
)
end
end

Maze.config.add_validator('error') do |validator|
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?('4') }
validator.validate_header('bugsnag-sent-at') { |value| Date.iso8601(value) }

validator.element_has_value('notifier.name', 'Bugsnag Go')
validator.each_element_exists(['notifier.url', 'notifier.version', 'events'])
validator.each_event_contains_each(['severity', 'severityReason.type', 'unhandled', 'exceptions'])
end

Maze.config.add_validator('session') do |validator|
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') { |value| Date.iso8601(value) }

validator.element_has_value('notifier.name', 'Bugsnag Go')
validator.each_element_exists(['notifier.url', 'notifier.version', 'app', 'device'])
end

0 comments on commit f6b701e

Please sign in to comment.