diff --git a/pilot/lib/pilot/build_manager.rb b/pilot/lib/pilot/build_manager.rb index 22a4e06d856..454b98520bc 100644 --- a/pilot/lib/pilot/build_manager.rb +++ b/pilot/lib/pilot/build_manager.rb @@ -366,9 +366,6 @@ def expire_previous_builds(build) # If there are multiple teams, infer the provider from the selected team name. # If there are fewer than two teams, don't infer the provider. def transporter_for_selected_team(options) - # Ensure that user is authenticated - start(options) - # Use JWT auth api_token = Spaceship::ConnectAPI.token unless api_token.nil? diff --git a/pilot/lib/pilot/manager.rb b/pilot/lib/pilot/manager.rb index 8624863dc89..d4bb43ab749 100644 --- a/pilot/lib/pilot/manager.rb +++ b/pilot/lib/pilot/manager.rb @@ -13,7 +13,10 @@ class Manager def start(options, should_login: true) return if @config # to not login multiple times @config = options - login if should_login + + # we will always start with App Store Connect API login 'if possible' + # else fallback to 'should_login' param for 'apple_id' login + login if options[:api_key_path] || options[:api_key] || should_login end def login diff --git a/pilot/spec/manager_spec.rb b/pilot/spec/manager_spec.rb index acbb604c7f4..b672c8c9b7f 100644 --- a/pilot/spec/manager_spec.rb +++ b/pilot/spec/manager_spec.rb @@ -58,15 +58,43 @@ end context "when passing 'should_login' value as FALSE" do - before(:each) do - expect(fake_manager).not_to receive(:login) + context "when input options has no 'api_key' or 'api_key_path' param" do + before(:each) do + expect(fake_manager).not_to receive(:login) + end + + it "sets the 'config' variable value and doesn't call login" do + options = {} + fake_manager.start(options, should_login: false) + + expect(fake_manager.instance_variable_get(:@config)).to eq(options) + end end - it "sets the 'config' variable value and doesn't call login" do - options = {} - fake_manager.start(options, should_login: false) + context "when input options has 'api_key' param" do + before(:each) do + expect(fake_manager).to receive(:login) + end - expect(fake_manager.instance_variable_get(:@config)).to eq(options) + it "sets the 'config' variable value and calls login for appstore connect api token" do + options = { api_key: "fake_api_key" } + fake_manager.start(options, should_login: false) + + expect(fake_manager.instance_variable_get(:@config)).to eq(options) + end + end + + context "when input options has 'api_key_path' param" do + before(:each) do + expect(fake_manager).to receive(:login) + end + + it "sets the 'config' variable value and calls login for appstore connect api token" do + options = { api_key_path: "fake api_key_path" } + fake_manager.start(options, should_login: false) + + expect(fake_manager.instance_variable_get(:@config)).to eq(options) + end end end end