Skip to content

Commit

Permalink
Merge pull request #695 from bugsnag/tms/https-doc-server
Browse files Browse the repository at this point in the history
Add basic https support
  • Loading branch information
twometresteve authored Nov 1, 2024
2 parents 686b74a + d30d922 commit fb6c148
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 44 deletions.
27 changes: 14 additions & 13 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ steps:
key: ios-test-fixture
agents:
queue: macos-14
env:
XCODE_VERSION: "15.4.0"
command:
- cd bugsnag-cocoa
- bundle install
- make test-fixtures
- ./features/scripts/export_ios_app.sh Release
plugins:
artifacts#v1.9.0:
upload: "bugsnag-cocoa/features/fixtures/ios/output/iOSTestApp.ipa"
upload: "bugsnag-cocoa/features/fixtures/ios/output/iOSTestApp_Release.ipa"

- label: ':docker: Build CI image for Ruby 2'
timeout_in_minutes: 30
Expand Down Expand Up @@ -240,14 +241,14 @@ steps:
concurrency_group: 'browserstack-app'
concurrency_method: eager

- label: ':browserstack: iOS 15 - W3C'
- label: ':browserstack: iOS 16 - W3C'
timeout_in_minutes: 20
depends_on:
- "ios-test-fixture"
- "push-branch-cli"
plugins:
artifacts#v1.9.0:
download: "bugsnag-cocoa/features/fixtures/ios/output/iOSTestApp.ipa"
download: "bugsnag-cocoa/features/fixtures/ios/output/iOSTestApp_Release.ipa"
upload: "bugsnag-cocoa/maze_output/**/*"
docker-compose#v4.14.0:
pull: appium-test-bs
Expand All @@ -257,11 +258,11 @@ steps:
- "./bugsnag-cocoa/features:/app/features"
- "./bugsnag-cocoa/maze_output:/app/maze_output"
command:
- "--app=features/fixtures/ios/output/iOSTestApp.ipa"
- "--app=features/fixtures/ios/output/iOSTestApp_Release.ipa"
- "--farm=bs"
- "--device=IOS_15"
- "--device=IOS_16"
- "--fail-fast"
- "features/barebone_tests.feature"
- "features/release/barebone_tests.feature"
image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner
cache-from:
- cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli
Expand Down Expand Up @@ -308,7 +309,7 @@ steps:
# BitBar tests
#

- label: ':bitbar: Safari 15'
- label: ':bitbar: Safari 16'
depends_on: "push-branch-cli"
timeout_in_minutes: 10
plugins:
Expand All @@ -322,7 +323,7 @@ steps:
verbose: true
command:
- "--farm=bb"
- "--browser=safari_15"
- "--browser=safari_16"
- "--aws-public-ip"
- "--fail-fast"
- "--no-tunnel"
Expand Down Expand Up @@ -372,7 +373,7 @@ steps:
- "push-branch-cli"
plugins:
artifacts#v1.9.0:
download: "bugsnag-cocoa/features/fixtures/ios/output/iOSTestApp.ipa"
download: "bugsnag-cocoa/features/fixtures/ios/output/iOSTestApp_Release.ipa"
upload: "bugsnag-cocoa/maze_output/**/*"
docker-compose#v4.14.0:
pull: appium-test-bb
Expand All @@ -383,13 +384,13 @@ steps:
- "./bugsnag-cocoa/maze_output:/app/maze_output"
service-ports: true
command:
- "--app=features/fixtures/ios/output/iOSTestApp.ipa"
- "--app=features/fixtures/ios/output/iOSTestApp_Release.ipa"
- "--farm=bb"
- "--device=IOS_14|IOS_15|IOS_16"
- "--fail-fast"
- "--no-tunnel"
- "--aws-public-ip"
- "features/barebone_tests.feature"
- "features/release/barebone_tests.feature"
image-repository: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner
cache-from:
- cli:855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner:${BRANCH_NAME}-cli
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 9.16.0 - 2024-11-01

## Enhancements

- Add https support for document servers [695](https://github.com/bugsnag/maze-runner/pull/695)

# 9.15.1 - 2024-10-29

## Fixes
Expand Down
2 changes: 1 addition & 1 deletion bugsnag-cocoa
Submodule bugsnag-cocoa updated 75 files
+62 −52 .buildkite/pipeline.full.yml
+169 −57 .buildkite/pipeline.yml
+4 −4 .github/workflows/pull_request.yml
+2 −2 .jazzy.yaml
+2 −2 Bugsnag.podspec.json
+5 −7 Bugsnag.xcodeproj/project.pbxproj
+16 −4 Bugsnag/Bugsnag.m
+20 −0 Bugsnag/Client/BugsnagClient+Private.h
+18 −34 Bugsnag/Client/BugsnagClient.m
+1 −1 Bugsnag/Helpers/BSGRunContext.m
+2 −0 Bugsnag/Helpers/BSGUtils.h
+7 −0 Bugsnag/Helpers/BSGUtils.m
+10 −9 Bugsnag/Payload/BugsnagCorrelation.h
+5 −5 Bugsnag/Payload/BugsnagCorrelation.m
+3 −0 Bugsnag/Payload/BugsnagEvent+Private.h
+6 −3 Bugsnag/Payload/BugsnagEvent.m
+1 −1 Bugsnag/Payload/BugsnagNotifier.m
+0 −26 Bugsnag/include/Bugsnag/BugsnagCorrelation.h
+2 −3 Bugsnag/include/Bugsnag/BugsnagEvent.h
+3 −3 BugsnagNetworkRequestPlugin.podspec.json
+22 −0 CHANGELOG.md
+1 −1 Framework/Info.plist
+4 −2 Makefile
+1 −0 Tests/BugsnagTests/BugsnagClientMirrorTest.m
+23 −0 Tests/BugsnagTests/BugsnagEventPersistLoadTest.m
+1 −1 Tests/BugsnagTests/Info.plist
+1 −1 Tests/TestHost-iOS/Info.plist
+1 −1 VERSION
+1 −1 features/app_hangs.feature
+0 −0 features/debug/crashprobe.feature
+0 −0 features/debug/cross_notifier_notify.feature
+21 −0 features/debug/handled_errors.feature
+0 −0 features/debug/unhandled_nsexception.feature
+1 −1 features/release/app_and_device_attributes.feature
+0 −0 features/release/auto_detect_errors.feature
+2 −2 features/release/barebone_tests.feature
+0 −0 features/release/breadcrumb_callbacks.feature
+0 −0 features/release/breadcrumbs.feature
+0 −0 features/release/config_from_plist.feature
+0 −0 features/release/context.feature
+230 −0 features/release/crashprobe.feature
+64 −0 features/release/cross_notifier_notify.feature
+2 −0 features/release/delivery.feature
+0 −0 features/release/discard_classes.feature
+0 −0 features/release/enabled_error_types.feature
+0 −0 features/release/error_reporting_thread.feature
+0 −0 features/release/event_callbacks.feature
+0 −3 features/release/handled_errors.feature
+0 −0 features/release/internal_workings.feature
+0 −0 features/release/last_run_info.feature
+0 −0 features/release/metadata_merging.feature
+0 −0 features/release/metadata_redaction.feature
+0 −0 features/release/out_of_memory.feature
+0 −0 features/release/plugin_interface.feature
+0 −0 features/release/recrash_reports.feature
+0 −0 features/release/release_stage_errors.feature
+0 −0 features/release/release_stage_sessions.feature
+0 −0 features/release/runtime_versions.feature
+0 −0 features/release/session_callbacks.feature
+0 −0 features/release/session_stopping.feature
+2 −2 features/release/session_tracking.feature
+0 −0 features/release/stress_test.feature
+0 −0 features/release/telemetry.feature
+0 −0 features/release/thermal_state.feature
+0 −0 features/release/threads.feature
+0 −0 features/release/unhandled_cpp_exception.feature
+0 −0 features/release/unhandled_mach_exception.feature
+39 −0 features/release/unhandled_nsexception.feature
+0 −0 features/release/unhandled_signal.feature
+0 −0 features/release/user.feature
+0 −0 features/release/user_persistence.feature
+42 −30 features/scripts/export_ios_app.sh
+45 −37 features/scripts/export_mac_app.sh
+1 −1 features/steps/app_steps.rb
+82 −55 scripts/build-xcframework.sh
2 changes: 1 addition & 1 deletion lib/maze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Glues the various parts of MazeRunner together that need to be accessed globally,
# providing an alternative to the proliferation of global variables or singletons.
module Maze
VERSION = '9.15.1'
VERSION = '9.16.0'

class << self
attr_accessor :check, :driver, :internal_hooks, :mode, :start_time, :dynamic_retry, :public_address,
Expand Down
1 change: 1 addition & 0 deletions lib/maze/client/selenium/bb_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def start_session
capabilities.merge! browsers[config.browser]
capabilities.merge! JSON.parse(config.capabilities_option)
capabilities['bitbar:options']['testTimeout'] = 900
capabilities['acceptInsecureCerts'] = true
config.capabilities = capabilities

if Maze::Client::BitBarClientUtils.use_local_tunnel?
Expand Down
2 changes: 2 additions & 0 deletions lib/maze/client/selenium/bs_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def start_session
capabilities['browserstack.local'] = 'true'
capabilities['browserstack.localIdentifier'] = Maze.run_uuid
capabilities['browserstack.console'] = 'errors'
capabilities['acceptInsecureCerts'] = 'true'

# Convert W3S capabilities to JSON-WP
capabilities['browser'] = browser['browserName']
Expand All @@ -29,6 +30,7 @@ def start_session
config.capabilities = capabilities
else
capabilities = {
'acceptInsecureCerts' => true,
'bstack:options' => {
'local' => 'true',
'localIdentifier' => Maze.run_uuid
Expand Down
3 changes: 3 additions & 0 deletions lib/maze/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def initialize
# Server configuration
#

# Whether the mock server should use https
attr_accessor :https

# Mock server bind address
attr_accessor :bind_address

Expand Down
8 changes: 7 additions & 1 deletion lib/maze/driver/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ def create_driver(driver_for, selenium_url=nil)
capabilities: @capabilities
end
else
driver = ::Selenium::WebDriver.for driver_for
if driver_for == :chrome
options = Selenium::WebDriver::Options.chrome
elsif driver_for == :firefox
options = Selenium::WebDriver::Options.firefox
end
options.accept_insecure_certs = true
driver = ::Selenium::WebDriver.for driver_for, options: options
end
$logger.info "Selenium driver started in #{(Time.now - time).to_i}s"
@driver = driver
Expand Down
3 changes: 2 additions & 1 deletion lib/maze/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ module Option
# Document server options
DS_BIND_ADDRESS = 'document-server-bind-address'
DS_PORT = 'document-server-port'
DS_ROOT = 'document-server-root'

# Server options
HTTPS = 'https'
BIND_ADDRESS = 'bind-address'
NULL_PORT = 'null-port'
PORT = 'port'
DS_ROOT = 'document-server-root'

# Appium options
A11Y_LOCATOR = 'a11y-locator'
Expand Down
5 changes: 5 additions & 0 deletions lib/maze/option/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def parse(args)
text ''
text 'Server options:'

opt Option::HTTPS,
'Use HTTPS for the mock server',
short: :none,
type: :boolean,
default: false
opt Option::BIND_ADDRESS,
'Mock server bind address',
short: :none,
Expand Down
1 change: 1 addition & 0 deletions lib/maze/option/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class << self
def populate(config, options)

# Server options
config.https = options[Maze::Option::HTTPS]
config.bind_address = options[Maze::Option::BIND_ADDRESS]
config.port = options[Maze::Option::PORT]
config.null_port = options[Maze::Option::NULL_PORT]
Expand Down
16 changes: 13 additions & 3 deletions lib/maze/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,20 @@ def start
loop do

@thread = Thread.new do

options = {
Port: Maze.config.port,
Logger: $logger,
AccessLog: []
Port: Maze.config.port,
Logger: $logger,
AccessLog: []
}
# SSL config if enabled
if Maze.config.https
cert_name = [
%w[CN localhost],
]
options[:SSLEnable] = true
options[:SSLCertName] = cert_name
end
options[:BindAddress] = Maze.config.bind_address unless Maze.config.bind_address.nil?
server = WEBrick::HTTPServer.new(options)

Expand Down Expand Up @@ -243,6 +252,7 @@ def start
server.mount '/metrics', Servlets::Servlet, :metrics
server.mount '/reflect', Servlets::ReflectiveServlet
server.mount '/docs', WEBrick::HTTPServlet::FileHandler, Maze.config.document_server_root unless Maze.config.document_server_root.nil?

server.start
rescue StandardError => e
Bugsnag.notify e
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/browser/features/handled_errors.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Browser smoke tests

Scenario: Receiving responses from URLs
Scenario: Receiving responses from URLs using an HTTPS server
When I navigate to the test URL "/test.html"
Then I wait to receive an error
And the error payload field "test" equals "browser"
Expand Down
5 changes: 0 additions & 5 deletions test/fixtures/browser/features/lib/server.rb

This file was deleted.

15 changes: 3 additions & 12 deletions test/fixtures/browser/features/steps/browser_steps.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
require 'socket'

def get_document_server_url
if Maze.config.aws_public_ip
"http://#{Maze.public_document_server_address}"
else
"http://#{get_private_hostname}:#{Maze.config.document_server_port}"
end
end

def get_maze_runner_url
if Maze.config.aws_public_ip
"http://#{Maze.public_address}"
"https://#{Maze.public_address}"
else
"http://#{get_private_hostname}:#{Maze.config.port}"
"https://#{get_private_hostname}:#{Maze.config.port}"
end
end

Expand All @@ -35,8 +27,7 @@ def get_private_hostname

When('I navigate to the test URL {string}') do |test_path|
maze_address = get_maze_runner_url
doc_server = get_document_server_url
url = "#{doc_server}#{test_path}?maze_address=#{CGI.escape(maze_address)}"
url = "#{maze_address}/docs#{test_path}?maze_address=#{CGI.escape(maze_address)}"
step("I navigate to the URL \"#{url}\"")
end

Expand Down
9 changes: 4 additions & 5 deletions test/fixtures/browser/features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'yaml'

Maze.hooks.before_all do
Maze.config.receive_no_requests_wait = 15
Maze.config.enforce_bugsnag_integrity = false
Maze.config.document_server_root = 'features/fixtures'
end
Maze.config.receive_no_requests_wait = 15
Maze.config.enforce_bugsnag_integrity = false
Maze.config.https = true
Maze.config.document_server_root = 'features/fixtures'

at_exit do
# Stop the web page server
Expand Down
3 changes: 3 additions & 0 deletions test/option/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_default_values
# Common options
assert_nil(options[Maze::Option::FARM])
assert_nil(options[Maze::Option::APP])
assert_false(options[Maze::Option::HTTPS])
assert_false(options[Maze::Option::A11Y_LOCATOR])
assert_equal('{}', options[Maze::Option::CAPABILITIES])

Expand Down Expand Up @@ -72,6 +73,7 @@ def test_overwritten_values
--farm=ARG_FARM
--app=ARG_APP
--a11y-locator
--https
--capabilities=ARG_CAPABILITIES
--bs-local=ARG_BS_LOCAL
--device=ARG_DEVICE
Expand All @@ -98,6 +100,7 @@ def test_overwritten_values
assert_equal('ARG_FARM', options[Maze::Option::FARM])
assert_equal('ARG_APP', options[Maze::Option::APP])
assert_true(options[Maze::Option::A11Y_LOCATOR])
assert_true(options[Maze::Option::HTTPS])
assert_equal('ARG_CAPABILITIES', options[Maze::Option::CAPABILITIES])

# Device-farm-only options
Expand Down
4 changes: 3 additions & 1 deletion test/option/processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ def test_default_options
assert_true config.enable_retries
assert_false config.log_requests
assert_false config.always_log
assert_false config.https
assert_nil config.bugsnag_repeater_api_key
end

def test_overriden_defaults
args = %w[--no-bugsnag --no-retries --no-file-log --no-tunnel --log-requests --always-log --bind-address=1.2.3.4 \
args = %w[--no-bugsnag --no-retries --no-file-log --no-tunnel --log-requests --always-log --https --bind-address=1.2.3.4 \
--port=1234]
options = Maze::Option::Parser.parse args
config = Maze::Configuration.new
Expand All @@ -121,6 +122,7 @@ def test_overriden_defaults
assert_false config.enable_bugsnag
assert_false config.enable_retries

assert_true config.https
assert_true config.log_requests
assert_true config.always_log
end
Expand Down

0 comments on commit fb6c148

Please sign in to comment.