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

Extract Sauce authentication ENV vars from Jenkins Plugin #314

Open bootstraponline opened 9 years ago

bootstraponline commented 9 years ago

The Sauce on demand plugin looks for SAUCE_API_KEY and the sauce_ruby gem supports only SAUCE_ACCESS_KEY. The ENV situation with sauce is a nightmare. I'd expect the gem to support all 4 variations and work out of the box with the Jenkins plugin.

-----------------------------------------------------------------------
    Your Sauce username and/or access key are unavailable. Please:
    1.  Set the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables. 
bootstraponline commented 9 years ago
username = hash.delete("SAUCE_USERNAME") || hash.delete("SAUCE_USER_NAME")
access_key = hash.delete("SAUCE_ACCESS_KEY") || hash.delete("SAUCE_API_KEY")

I see at least one place in the Ruby code that checks all four so it's not clear why the ENVs being set by the Java plugin aren't being detected.

DylanLacey commented 9 years ago

Hmm, I'll investigate when I get a chance. I agree the gem should be overly permissive about what you call your vars.

bootstraponline commented 9 years ago

I think this is it since I'm running the tests via Rake.

def run_parallel_tests(t, args, command)
  if ParallelTests.number_of_running_processes == 0
    username    = ENV["SAUCE_USERNAME"].to_s
    access_key  = ENV["SAUCE_ACCESS_KEY"].to_s

It's only checking those exact env vars.

bootstraponline commented 9 years ago

There are multiple places where only one ENV variable is checked so they'd all have to be fixed (ideally using a helper method).

 SAUCE_USERNAME = ENV["SAUCE_USERNAME"]
 SAUCE_ACCESS_KEY = ENV["SAUCE_ACCESS_KEY"]
 AUTH_DETAILS = "#{SAUCE_USERNAME}:#{SAUCE_ACCESS_KEY}"