bugsnag-maze-runner 9.2.1 → 9.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc79eb9902d0209a3c73e30fec55492e406f49f310c7e186a793705d82641bc2
4
- data.tar.gz: 259c557ff4100a51a9f3b6d3a0e9323139543e94c50d29125bd757750acf4dcc
3
+ metadata.gz: f27ea68dc346c2a0f579cc5469176bb972b410df5c45cb033d133b872c6ececb
4
+ data.tar.gz: d9b56d5caa14ddf01e612e578fcc778cc522ef64dc7e92f2fcf1d343edd0ef00
5
5
  SHA512:
6
- metadata.gz: e28c079a60645e507be8db04d715c886559ded8c34d1e1b36127de943af33b81c11f1b6e4d5f756c06c3442fa90f8b1d6814f8fbe77a16c074f60e56c2a39840
7
- data.tar.gz: b278bf5a9acaed1e348f268442d5477c5ca509452b6ef4c036e8a72c444a810ffac8bb04fc1aa4e6dac4aff42124e1fdea94721713a5a366e69fe4f3d0e3d278
6
+ metadata.gz: 4ed30e0eaa84c7a257b39738b59c9d07199bd6f0d11216964f543f5df2624cb085d70ce653df94e6140577d68cfac03bac9c11526e876c1f70a83b8626cc9fb1
7
+ data.tar.gz: 7c435daa612fb2b91802757845ac706a70ca78fcd84d3d991a71d10ea4e2725e3985956ba5d65f77cd6edcf73a7ea3ad57475ce1fd49771d95474e9a7029d98b
@@ -74,7 +74,7 @@ end
74
74
  # @step_input json_fixture [String] A path to the JSON fixture to compare against
75
75
  Then('the event contains a breadcrumb matching the JSON fixture in {string}') do |json_fixture|
76
76
  breadcrumbs = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], 'events.0.breadcrumbs')
77
- expected = JSON.parse(open(json_fixture, &:read))
77
+ expected = JSON.parse(File.open(json_fixture, &:read))
78
78
  match = breadcrumbs.any? { |breadcrumb| Maze::Compare.value(expected, breadcrumb).equal? }
79
79
  Maze.check.true(match, 'No breadcrumbs in the event matched the given breadcrumb')
80
80
  end
@@ -78,7 +78,7 @@ Then('the {request_type} multipart body does not match the JSON file in {string}
78
78
  payload_list = Maze::Server.list_for request_type
79
79
  raw_payload_value = payload_list.current[:body]
80
80
  payload_value = parse_multipart_body(raw_payload_value)
81
- expected_value = JSON.parse(open(json_path, &:read))
81
+ expected_value = JSON.parse(File.open(json_path, &:read))
82
82
  result = Maze::Compare.value(expected_value, payload_value)
83
83
  Maze.check.false(result.equal?, "Payload:\n#{payload_value}\nExpected:#{expected_value}")
84
84
  end
@@ -93,7 +93,7 @@ Then('the {request_type} multipart body matches the JSON file in {string}') do |
93
93
  payload_list = Maze::Server.list_for request_type
94
94
  raw_payload_value = payload_list.current[:body]
95
95
  payload_value = parse_multipart_body(raw_payload_value)
96
- expected_value = JSON.parse(open(json_path, &:read))
96
+ expected_value = JSON.parse(File.open(json_path, &:read))
97
97
  result = Maze::Compare.value(expected_value, payload_value)
98
98
  Maze.check.true(result.equal?, "The payload field '#{result.keypath}' does not match the fixture:\n #{result.reasons.join('\n')}")
99
99
  end
@@ -108,7 +108,7 @@ Then('the {request_type} multipart field {string} matches the JSON file in {stri
108
108
  Maze.check.true(File.exist?(json_path), "'#{json_path}' does not exist")
109
109
  payload_list = Maze::Server.list_for request_type
110
110
  payload_value = JSON.parse(payload_list.current[:body][field_path].to_s)
111
- expected_value = JSON.parse(open(json_path, &:read))
111
+ expected_value = JSON.parse(File.open(json_path, &:read))
112
112
  result = Maze::Compare.value(expected_value, payload_value)
113
113
  Maze.check.true(result.equal?, "The multipart field '#{result.keypath}' does not match the fixture:\n #{result.reasons.join('\n')}")
114
114
  end
@@ -95,7 +95,7 @@ end
95
95
  # @step_input url [String] The URL to open.
96
96
  When('I open the URL {string}') do |url|
97
97
  begin
98
- URI.open(url, &:read)
98
+ URI(url).open(&:read)
99
99
  rescue OpenURI::HTTPError
100
100
  $logger.debug $!.inspect
101
101
  end
@@ -8,7 +8,7 @@
8
8
  # @step_input fixture_path [String] Path to a JSON fixture
9
9
  Then('the {request_type} payload body does not match the JSON fixture in {string}') do |request_type, fixture_path|
10
10
  payload_value = Maze::Server.list_for(request_type).current[:body]
11
- expected_value = JSON.parse(open(fixture_path, &:read))
11
+ expected_value = JSON.parse(File.open(fixture_path, &:read))
12
12
  result = Maze::Compare.value(expected_value, payload_value)
13
13
  Maze.check.false(result.equal?, "Payload:\n#{payload_value}\nExpected:#{expected_value}")
14
14
  end
@@ -19,7 +19,7 @@ end
19
19
  # @step_input fixture_path [String] Path to a JSON fixture
20
20
  Then('the {request_type} payload body matches the JSON fixture in {string}') do |request_type, fixture_path|
21
21
  payload_value = Maze::Server.list_for(request_type).current[:body]
22
- expected_value = JSON.parse(open(fixture_path, &:read))
22
+ expected_value = JSON.parse(File.open(fixture_path, &:read))
23
23
  result = Maze::Compare.value(expected_value, payload_value)
24
24
  Maze.check.true(result.equal?,
25
25
  "The payload field '#{result.keypath}' does not match the fixture:\n #{result.reasons.join('\n')}")
@@ -34,7 +34,7 @@ Then('the {request_type}(|a b) payload field {string} matches the JSON fixture i
34
34
  do |request_type, field_path, fixture_path|
35
35
  list = Maze::Server.list_for(request_type)
36
36
  payload_value = Maze::Helper.read_key_path(list.current[:body], field_path)
37
- expected_value = JSON.parse(open(fixture_path, &:read))
37
+ expected_value = JSON.parse(File.open(fixture_path, &:read))
38
38
  result = Maze::Compare.value(expected_value, payload_value)
39
39
  Maze.check.true(result.equal?,
40
40
  "The payload field '#{result.keypath}' does not match the fixture:\n #{result.reasons.join('\n')}")
@@ -22,7 +22,10 @@ module Maze
22
22
  when 'android'
23
23
  Maze.driver.session_capabilities['appPackage']
24
24
  when 'ios'
25
- Maze.driver.session_capabilities['CFBundleIdentifier'] # Present on BS and locally
25
+ unless app_id = Maze.driver.session_capabilities['CFBundleIdentifier']
26
+ app_id = Maze.driver.session_capabilities['bundleID']
27
+ end
28
+ app_id
26
29
  end
27
30
 
28
31
  # Ensure the device is unlocked
@@ -32,6 +32,8 @@ module Maze
32
32
  interval = 120
33
33
  elsif error.message.include? 'Appium Settings app is not running'
34
34
  interval = 10
35
+ elsif error.message.include? 'Could not proxy command to the remote server'
36
+ interval = 10
35
37
  else
36
38
  # Do not retry in any other case
37
39
  end
@@ -9,6 +9,7 @@ module Maze
9
9
  HEX_STRING_32 = '^[A-Fa-f0-9]{32}$'
10
10
  SAMPLING_HEADER_ENTRY = '((1(.0)?|0(\.[0-9]+)?):[0-9]+)'
11
11
  SAMPLING_HEADER = "^#{SAMPLING_HEADER_ENTRY}(;#{SAMPLING_HEADER_ENTRY})*$"
12
+ HOUR_TOLERANCE = 60 * 60 * 1000 * 1000 * 1000 # 1 hour in nanoseconds
12
13
 
13
14
  # Contains a set of pre-defined validations for ensuring traces are correct
14
15
  class TraceValidator
@@ -38,15 +39,39 @@ module Maze
38
39
  element_int_in_range('resourceSpans.0.scopeSpans.0.spans.0.kind', 0..5)
39
40
  regex_comparison('resourceSpans.0.scopeSpans.0.spans.0.startTimeUnixNano', '^[0-9]+$')
40
41
  regex_comparison('resourceSpans.0.scopeSpans.0.spans.0.endTimeUnixNano', '^[0-9]+$')
42
+ element_contains('resourceSpans.0.resource.attributes', 'device.id')
43
+ each_element_contains('resourceSpans.0.scopeSpans.0.spans', 'attributes', 'bugsnag.sampling.p')
41
44
  element_contains('resourceSpans.0.resource.attributes', 'deployment.environment')
42
45
  element_contains('resourceSpans.0.resource.attributes', 'telemetry.sdk.name')
43
46
  element_contains('resourceSpans.0.resource.attributes', 'telemetry.sdk.version')
47
+ validate_timestamp('resourceSpans.0.scopeSpans.0.spans.0.startTimeUnixNano', HOUR_TOLERANCE)
48
+ validate_timestamp('resourceSpans.0.scopeSpans.0.spans.0.endTimeUnixNano', HOUR_TOLERANCE)
44
49
  element_a_greater_or_equal_element_b(
45
50
  'resourceSpans.0.scopeSpans.0.spans.0.endTimeUnixNano',
46
51
  'resourceSpans.0.scopeSpans.0.spans.0.startTimeUnixNano'
47
52
  )
48
53
  end
49
54
 
55
+ def validate_timestamp(path, tolerance)
56
+ timestamp = Maze::Helper.read_key_path(@body, path)
57
+ unless timestamp.kind_of?(String)
58
+ @success = false
59
+ @errors << "Timestamp was expected to be a string, was '#{timestamp.class.name}'"
60
+ return
61
+ end
62
+ parsed_timestamp = timestamp.to_i
63
+ unless parsed_timestamp > 0
64
+ @success = false
65
+ @errors << "Timestamp was expected to be a positive integer, was '#{parsed_timestamp}'"
66
+ return
67
+ end
68
+ time_in_nanos = Time.now.to_i * 1000000000
69
+ unless (time_in_nanos - parsed_timestamp).abs < tolerance
70
+ @success = false
71
+ @errors << "Timestamp was expected to be within #{tolerance} nanoseconds of the current time (#{time_in_nanos}), was '#{parsed_timestamp}'"
72
+ end
73
+ end
74
+
50
75
  def validate_header(name)
51
76
  value = @headers[name]
52
77
  if value.nil? || value.size > 1
@@ -133,6 +158,18 @@ module Maze
133
158
  end
134
159
  end
135
160
 
161
+ def each_element_contains(container_path, attribute_path, key_value)
162
+ container = Maze::Helper.read_key_path(@body, container_path)
163
+ if container.nil? || !container.kind_of?(Array)
164
+ @success = false
165
+ @errors << "Element '#{container_path}' was expected to be an array, was '#{container}'"
166
+ return
167
+ end
168
+ container.each_with_index do |_item, index|
169
+ element_contains("#{container_path}.#{index}.#{attribute_path}", key_value)
170
+ end
171
+ end
172
+
136
173
  def element_a_greater_or_equal_element_b(path_a, path_b)
137
174
  element_a = Maze::Helper.read_key_path(@body, path_a)
138
175
  element_b = Maze::Helper.read_key_path(@body, path_b)
data/lib/maze.rb CHANGED
@@ -7,7 +7,7 @@ require_relative 'maze/timers'
7
7
  # Glues the various parts of MazeRunner together that need to be accessed globally,
8
8
  # providing an alternative to the proliferation of global variables or singletons.
9
9
  module Maze
10
- VERSION = '9.2.1'
10
+ VERSION = '9.3.1'
11
11
 
12
12
  class << self
13
13
  attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag-maze-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.2.1
4
+ version: 9.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Kirkland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-16 00:00:00.000000000 Z
11
+ date: 2024-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber