Skip to content

Commit

Permalink
Set default ITMSTransporter transport flag to blank #16749
Browse files Browse the repository at this point in the history
  • Loading branch information
castus committed Jul 7, 2020
1 parent f3ed1bb commit 977f872
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 17 deletions.
22 changes: 15 additions & 7 deletions fastlane_core/lib/fastlane_core/itunes_transporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,22 @@ def parse_line(line, hide_output)
end

def additional_upload_parameters
# Workaround because the traditional transporter broke on 1st March 2018
# More information https://github.com/fastlane/fastlane/issues/11958
# As there was no communication from Apple, we don't know if this is a temporary
# server outage, or something they changed without giving a heads-up
if ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"].to_s.length == 0
ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV,Signiant"
# As Apple recommends in Transporter User Guide we shouldn't specify the -t transport parameter
# and instead allow Transporter to use automatic transport discovery
# to determine the best transport mode for packages.
# It became crucial after WWDC 2020 as it leaded to "Broken pipe (Write failed)" exception
# More information https://github.com/fastlane/fastlane/issues/16749
env_deliver_additional_params = ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"]
if env_deliver_additional_params.nil?
return nil
end

deliver_additional_params = env_deliver_additional_params.to_s.strip
if !deliver_additional_params.include?("-t ")
UI.user_error!("Invalid transport parameter")
else
return deliver_additional_params
end
return ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"]
end
end

Expand Down
84 changes: 74 additions & 10 deletions fastlane_core/spec/itunes_transporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let(:email) { 'fabric.devtools@gmail.com' }

describe FastlaneCore::ItunesTransporter do
def shell_upload_command(provider_short_name = nil)
def shell_upload_command(provider_short_name: nil, transporter: nil)
escaped_password = password.shellescape
unless FastlaneCore::Helper.windows?
escaped_password = escaped_password.gsub("\\'") do
Expand All @@ -20,7 +20,7 @@ def shell_upload_command(provider_short_name = nil)
"-u #{email.shellescape}",
"-p #{escaped_password}",
"-f \"/tmp/my.app.id.itmsp\"",
"-t DAV,Signiant",
(transporter.to_s if transporter),
"-k 100000",
("-WONoPause true" if FastlaneCore::Helper.windows?),
("-itc_provider #{provider_short_name}" if provider_short_name)
Expand Down Expand Up @@ -55,7 +55,7 @@ def shell_provider_id_command
].compact.join(' ')
end

def java_upload_command(provider_short_name = nil)
def java_upload_command(provider_short_name: nil, transporter: nil)
[
FastlaneCore::Helper.transporter_java_executable_path.shellescape,
"-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}",
Expand All @@ -71,7 +71,7 @@ def java_upload_command(provider_short_name = nil)
"-u #{email.shellescape}",
"-p #{password.shellescape}",
"-f /tmp/my.app.id.itmsp",
"-t DAV,Signiant",
(transporter.to_s if transporter),
"-k 100000",
("-itc_provider #{provider_short_name}" if provider_short_name),
'2>&1'
Expand Down Expand Up @@ -119,7 +119,7 @@ def java_provider_id_command
].compact.join(' ')
end

def java_upload_command_9(provider_short_name = nil)
def java_upload_command_9(provider_short_name: nil, transporter: nil)
[
FastlaneCore::Helper.transporter_java_executable_path.shellescape,
"-Djava.ext.dirs=#{FastlaneCore::Helper.transporter_java_ext_dir.shellescape}",
Expand All @@ -134,7 +134,7 @@ def java_upload_command_9(provider_short_name = nil)
"-u #{email.shellescape}",
"-p #{password.shellescape}",
"-f /tmp/my.app.id.itmsp",
"-t DAV,Signiant",
(transporter.to_s if transporter),
"-k 100000",
("-itc_provider #{provider_short_name}" if provider_short_name),
'2>&1'
Expand Down Expand Up @@ -162,14 +162,14 @@ def java_download_command_9(provider_short_name = nil)
].compact.join(' ')
end

def xcrun_upload_command(provider_short_name = nil)
def xcrun_upload_command(provider_short_name: nil, transporter: nil)
[
"xcrun iTMSTransporter",
"-m upload",
"-u #{email.shellescape}",
"-p #{password.shellescape}",
"-f /tmp/my.app.id.itmsp",
"-t DAV,Signiant",
(transporter.to_s if transporter),
"-k 100000",
("-itc_provider #{provider_short_name}" if provider_short_name),
'2>&1'
Expand Down Expand Up @@ -205,6 +205,17 @@ def xcrun_download_command(provider_short_name = nil)
end
end

describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set" do
before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV,Signiant" }

it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password)
expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(transporter: "-t DAV,Signiant"))
end

after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") }
end

describe "download command generation" do
it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password)
Expand All @@ -224,7 +235,7 @@ def xcrun_download_command(provider_short_name = nil)
describe "upload command generation" do
it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password, false, 'abcd1234')
expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command('abcd1234'))
expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command(provider_short_name: 'abcd1234'))
end
end

Expand All @@ -247,7 +258,7 @@ def xcrun_download_command(provider_short_name = nil)
describe "upload command generation" do
it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password, true, 'abcd1234')
expect(transporter.upload('my.app.id', '/tmp')).to eq(shell_upload_command('abcd1234'))
expect(transporter.upload('my.app.id', '/tmp')).to eq(shell_upload_command(provider_short_name: 'abcd1234'))
end
end

Expand Down Expand Up @@ -357,6 +368,17 @@ def xcrun_download_command(provider_short_name = nil)
end
end

describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set" do
before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV,Signiant" }

it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password)
expect(transporter.upload('my.app.id', '/tmp')).to eq(shell_upload_command(transporter: "-t DAV,Signiant"))
end

after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") }
end

describe "download command generation" do
it 'generates a call to the shell script' do
transporter = FastlaneCore::ItunesTransporter.new(email, password, false)
Expand Down Expand Up @@ -387,6 +409,17 @@ def xcrun_download_command(provider_short_name = nil)
end
end

describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set" do
before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV,Signiant" }

it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password)
expect(transporter.upload('my.app.id', '/tmp')).to eq(java_upload_command_9(transporter: "-t DAV,Signiant"))
end

after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") }
end

describe "download command generation" do
it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password, false)
Expand All @@ -410,6 +443,17 @@ def xcrun_download_command(provider_short_name = nil)
end
end

describe "upload command generation with DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS set" do
before(:each) { ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV,Signiant" }

it 'generates a call to java directly' do
transporter = FastlaneCore::ItunesTransporter.new(email, password)
expect(transporter.upload('my.app.id', '/tmp')).to eq(xcrun_upload_command(transporter: "-t DAV,Signiant"))
end

after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") }
end

describe "download command generation" do
it 'generates a call to xcrun iTMSTransporter' do
transporter = FastlaneCore::ItunesTransporter.new(email, password, false)
Expand Down Expand Up @@ -441,6 +485,26 @@ def xcrun_download_command(provider_short_name = nil)
after(:each) { ENV.delete("FASTLANE_ITUNES_TRANSPORTER_USE_SHELL_SCRIPT") }
end

describe "with `DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS` set to wrong value" do
it 'failed to generate command for upload with lack of space' do
ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-tDAV,Signiant"
transporter = FastlaneCore::ItunesTransporter.new(email, password)
expect do
transporter.upload('my.app.id', '/tmp')
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end

it 'failed to generate command for upload with incorrect value' do
ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-x DAV,Signiant"
transporter = FastlaneCore::ItunesTransporter.new(email, password)
expect do
transporter.upload('my.app.id', '/tmp')
end.to raise_error(FastlaneCore::Interface::FastlaneError)
end

after(:each) { ENV.delete("DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS") }
end

describe "with no special configuration" do
before(:each) do
allow(File).to receive(:exist?).and_return(true) unless FastlaneCore::Helper.mac?
Expand Down

0 comments on commit 977f872

Please sign in to comment.