Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression][pilot] Fix upload using api_key_path + apple_id CLI options #18860

Merged
Merged
3 changes: 0 additions & 3 deletions pilot/lib/pilot/build_manager.rb
Expand Up @@ -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?
Expand Down
5 changes: 4 additions & 1 deletion pilot/lib/pilot/manager.rb
Expand Up @@ -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
Expand Down
40 changes: 34 additions & 6 deletions pilot/spec/manager_spec.rb
Expand Up @@ -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
Expand Down