sauce-archives / sauce_ruby

This is the Ruby client adapter for testing with Sauce Labs, a Selenium-based browser testing service (saucelabs.com).
Apache License 2.0
98 stars 115 forks source link

Fix passing options to Sauce Connect #344

Open Ostrzy opened 9 years ago

Ostrzy commented 9 years ago

Currently when some options are passed to Sauce Connect using

Sauce.config do |config|
  config[:connect_options] = { tunnel_identifier: "Tunnel Name" }
end

it is simply ignored because only first option (which is always readyfile) is return in the first block execution of collect. Additionally I've added some basic escaping for passed parameters using ' - in my case tunnel name was LOCAL(username) and it was simply failing when passed directly to shell as an option. I wanted to create some spec for that, but didn't have any good idea how to test it.

DylanLacey commented 9 years ago

Hey, thanks for the commit! Weird, I thought I fixed the collect issue with a previous commit. I'll have to go digging.

What shell are you using? I'm not entirely sure whether shell escaping is standard or not, that'd be my only concern.

Oh, and... There are no tests. Yet. >.>

Ostrzy commented 9 years ago

I am using zsh, but when I'm trying to pass LOCAL(username) as an option in bash I also get an error. In both cases applying ' solves problem. I can remove this, but then for some identifiers containing forbidden characters or spaces there will be some escaping needed:

Sauce.config do |config|
  tunnel_name = "LOCAL(#{ENV['SAUCE_USERNAME']})"
  config[:connect_options] = { tunnel_identifier: "'#{tunnel_name}'" }
  config["tunnel-identifier"] = tunnel_name
end