Skip to content

Commit

Permalink
Migrate to using latest version of Fastlane (which includes the lates…
Browse files Browse the repository at this point in the history
…t version of Spaceship) instead of using an old version of Spaceship. Fix failing test suite.
  • Loading branch information
andrewhavens committed Mar 16, 2018
1 parent 32b5f19 commit 001ca67
Show file tree
Hide file tree
Showing 11 changed files with 198 additions and 80 deletions.
152 changes: 123 additions & 29 deletions Gemfile.lock
Expand Up @@ -9,46 +9,122 @@ GIT
PATH
remote: .
specs:
motion-provisioning (0.0.6)
spaceship (~> 0.38)
motion-provisioning (0.0.7)
fastlane (~> 2.85)
highline (>= 1.7.2, < 2.0.0)

GEM
remote: https://rubygems.org/
specs:
addressable (2.3.8)
CFPropertyList (2.3.6)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
atomos (0.1.2)
babosa (1.0.2)
builder (3.2.2)
claide (1.0.2)
colored (1.2)
commander (4.4.0)
colored2 (3.1.2)
commander-fastlane (4.4.6)
highline (~> 1.7.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
credentials_manager (0.16.2)
colored
commander (>= 4.3.5)
highline (>= 1.7.1)
security
declarative (0.0.10)
declarative-option (0.1.0)
diff-lcs (1.2.5)
docile (1.1.5)
domain_name (0.5.20161021)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
faraday (0.10.0)
dotenv (2.2.1)
excon (0.60.0)
faraday (0.14.0)
multipart-post (>= 1.2, < 3)
faraday-cookie_jar (0.0.6)
faraday (>= 0.7.4)
http-cookie (~> 1.0.0)
faraday_middleware (0.10.1)
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fastimage (1.9.0)
addressable (~> 2.3.5)
fastimage (2.1.1)
fastlane (2.85.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
bundler (>= 1.12.0, < 2.0.0)
colored
commander-fastlane (>= 4.4.6, < 5.0.0)
dotenv (>= 2.1.1, < 3.0.0)
excon (>= 0.45.0, < 1.0.0)
faraday (~> 0.9)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 0.9)
fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-api-client (>= 0.13.1, < 0.14.0)
highline (>= 1.7.2, < 2.0.0)
json (< 3.0.0)
mini_magick (~> 4.5.1)
multi_json
multi_xml (~> 0.5)
multipart-post (~> 2.0.0)
plist (>= 3.1.0, < 4.0.0)
public_suffix (~> 2.0.0)
rubyzip (>= 1.1.0, < 2.0.0)
security (= 0.1.3)
slack-notifier (>= 2.0.0, < 3.0.0)
terminal-notifier (>= 1.6.2, < 2.0.0)
terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.5.2, < 2.0.0)
xcpretty (>= 0.2.4, < 1.0.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.1.3)
google-api-client (0.13.6)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 0.5)
httpclient (>= 2.8.1, < 3.0)
mime-types (~> 3.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.0)
googleauth (0.6.2)
faraday (~> 0.12)
jwt (>= 1.4, < 3.0)
logging (~> 2.0)
memoist (~> 0.12)
multi_json (~> 1.11)
os (~> 0.9)
signet (~> 0.7)
hashdiff (0.3.0)
highline (1.7.8)
highline (1.7.10)
http-cookie (1.0.3)
domain_name (~> 0.5)
json (2.0.2)
multi_xml (0.5.5)
httpclient (2.8.3)
json (2.1.0)
jwt (2.1.0)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
memoist (0.16.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.5.1)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
plist (3.2.0)
nanaimo (0.2.3)
os (0.9.6)
plist (3.4.0)
public_suffix (2.0.5)
rake (10.5.0)
representable (3.0.4)
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.1)
rouge (2.0.7)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
Expand All @@ -66,29 +142,47 @@ GEM
builder (< 4)
rspec-core (>= 2, < 4, != 2.12.0)
ruby-prof (0.15.9)
rubyzip (1.2.1)
safe_yaml (1.0.4)
security (0.1.3)
signet (0.8.1)
addressable (~> 2.3)
faraday (~> 0.9)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simplecov (0.12.0)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
spaceship (0.38.1)
colored
credentials_manager (>= 0.16.0)
faraday (~> 0.9)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 0.9)
fastimage (~> 1.6)
multi_xml (~> 0.5)
plist (>= 3.1.0, < 4.0.0)
slack-notifier (2.3.2)
terminal-notifier (1.8.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
tty-cursor (0.5.0)
tty-screen (0.6.4)
tty-spinner (0.8.0)
tty-cursor (>= 0.5.0)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unf_ext (0.0.7.5)
unicode-display_width (1.3.0)
webmock (1.24.6)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
word_wrap (1.0.0)
xcodeproj (1.5.6)
CFPropertyList (~> 2.3.3)
atomos (~> 0.1.2)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.3)
xcpretty (0.2.8)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.0)
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
ruby
Expand All @@ -104,4 +198,4 @@ DEPENDENCIES
webmock (~> 1.21)

BUNDLED WITH
1.13.6
1.16.0
5 changes: 4 additions & 1 deletion lib/motion-provisioning.rb
Expand Up @@ -64,10 +64,12 @@ def self.client
Security::InternetPassword.add(server_name, email, password)
end

# TODO: need to check if two factor auth!

Utils.log("Info", "Logging into the Developer Portal with email '#{email}'.")
begin
client.user = email
client.send("do_login", email, password)
client.send_shared_login_request(email, password)
rescue Spaceship::Client::InvalidUserCredentialsError => ex
Utils.log("Error", "There was an error logging into your account. Your password may be wrong.")

Expand All @@ -88,6 +90,7 @@ def self.client
end

if self.free
self.team = client.teams.first
client.teams.each do |team|
if team['currentTeamMember']['roles'].include?('XCODE_FREE_USER')
client.team_id = team['teamId']
Expand Down
10 changes: 5 additions & 5 deletions lib/motion-provisioning/provisioning_profile.rb
Expand Up @@ -35,7 +35,7 @@ def provisioning_profile(bundle_id, app_name, platform, type)

app = Application.find_or_create(bundle_id: bundle_id, name: app_name, mac: platform == :mac)

profile = profile_type.find_by_bundle_id(bundle_id, mac: platform == :mac).detect do |profile|
profile = profile_type.find_by_bundle_id(bundle_id: bundle_id, mac: platform == :mac, sub_platform: ('tvOS' if platform == :tvos)).detect do |profile|
next if profile.platform.downcase.include?("tvos") && platform != :tvos
next if !profile.platform.downcase.include?("tvos") && platform == :tvos
profile.name == provisioning_profile_name
Expand Down Expand Up @@ -124,10 +124,10 @@ def provisioning_profile(bundle_id, app_name, platform, type)
# The kind of provisioning profile we're interested in
def profile_type
return @profile_type if @profile_type
@profile_type = Spaceship.provisioning_profile.app_store
@profile_type = Spaceship.provisioning_profile.in_house if client.in_house?
@profile_type = Spaceship.provisioning_profile.ad_hoc if self.type == :adhoc
@profile_type = Spaceship.provisioning_profile.development if self.type == :development
@profile_type = Spaceship::Portal.provisioning_profile.app_store
@profile_type = Spaceship::Portal.provisioning_profile.in_house if client.in_house?
@profile_type = Spaceship::Portal.provisioning_profile.ad_hoc if self.type == :adhoc
@profile_type = Spaceship::Portal.provisioning_profile.development if self.type == :development
@profile_type
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/motion-provisioning/spaceship/free_portal_client.rb
@@ -1,7 +1,7 @@
module Spaceship
class FreePortalClient < Spaceship::PortalClient

def create_provisioning_profile!(name, distribution_method, app_id, certificate_ids, device_ids, mac: false, sub_platform: nil)
def create_provisioning_profile!(name, distribution_method, app_id, certificate_ids, device_ids, mac: false, sub_platform: nil, template_name: nil)
ensure_csrf(Spaceship::App)

params = {
Expand Down
16 changes: 1 addition & 15 deletions lib/motion-provisioning/spaceship/portal_client.rb
@@ -1,5 +1,6 @@
module Spaceship
class PortalClient < Spaceship::Client

def distribution_certificates(mac: false)
paging do |page_number|
r = request(:post, "https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/downloadDistributionCerts.action?clientId=XABBG36SBA&teamId=#{team_id}")
Expand All @@ -13,20 +14,5 @@ def development_certificates(mac: false)
parse_response(r, 'certificates')
end
end

# Fix a bug in Fastlane where the slug is hardcoded to ios
def create_certificate!(type, csr, app_id = nil)
ensure_csrf(Spaceship::Certificate)

mac = Spaceship::Portal::Certificate::MAC_CERTIFICATE_TYPE_IDS.keys.include?(type)

r = request(:post, "account/#{platform_slug(mac)}/certificate/submitCertificateRequest.action", {
teamId: team_id,
type: type,
csrContent: csr,
appIdId: app_id # optional
})
parse_response(r, 'certRequest')
end
end
end
2 changes: 1 addition & 1 deletion motion-provisioning.gemspec
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|

# Spaceship depends on the `plist` and `security` gems which we use too
spec.add_dependency 'highline', '>= 1.7.2', '< 2.0.0' # user inputs (e.g. passwords)
spec.add_dependency 'spaceship', '~> 0.38'
spec.add_dependency 'fastlane', '~> 2.85'

spec.add_development_dependency 'bundler', '~> 1.12'
spec.add_development_dependency 'rake', '~> 10.0'
Expand Down
Expand Up @@ -17,6 +17,8 @@
<string>store</string>
<key>proProPlatform</key>
<string>{platform}</string>
<key>proProSubPlatform</key>
<string>{subPlatform}</string>
<key>UUID</key>
<string>aad7df3b-9767-4e85-a1ea-1df4d8f32faa</string>
<key>version</key>
Expand Down Expand Up @@ -99,6 +101,8 @@
<string>limited</string>
<key>proProPlatform</key>
<string>{platform}</string>
<key>proProSubPlatform</key>
<string>{subPlatform}</string>
<key>UUID</key>
<string>897b1089-906a-4ecf-84c5-ffaae80ac0dd</string>
<key>version</key>
Expand Down Expand Up @@ -181,6 +185,8 @@
<string>store</string>
<key>proProPlatform</key>
<string>{platform}</string>
<key>proProSubPlatform</key>
<string>{subPlatform}</string>
<key>UUID</key>
<string>a8b1563e-7559-41f7-854b-6cd09f950d11</string>
<key>version</key>
Expand Down
Expand Up @@ -17,6 +17,8 @@
<string>store</string>
<key>proProPlatform</key>
<string>{platform}</string>
<key>proProSubPlatform</key>
<string>{subPlatform}</string>
<key>UUID</key>
<string>aad7df3b-9767-4e85-a1ea-1df4d8f32faa</string>
<key>version</key>
Expand Down Expand Up @@ -99,6 +101,8 @@
<string>limited</string>
<key>proProPlatform</key>
<string>{platform}</string>
<key>proProSubPlatform</key>
<string>{subPlatform}</string>
<key>UUID</key>
<string>897b1089-906a-4ecf-84c5-ffaae80ac0dd</string>
<key>version</key>
Expand Down Expand Up @@ -181,6 +185,8 @@
<string>store</string>
<key>proProPlatform</key>
<string>{platform}</string>
<key>proProSubPlatform</key>
<string>{subPlatform}</string>
<key>UUID</key>
<string>a8b1563e-7559-41f7-854b-6cd09f950d11</string>
<key>version</key>
Expand Down
3 changes: 2 additions & 1 deletion spec/provisioning_profile_spec.rb
Expand Up @@ -31,9 +31,10 @@ def mobileprovision_path(bundle_id, platform, type)
File.join(MotionProvisioning.output_path, "#{bundle_id}_#{platform}_#{type}_provisioning_profile.mobileprovision")
end

it "can use cached .mobileprovision" do
it "can use cached .mobileprovision that has not yet expired" do
cert = SPEC_CERTIFICATES[platform][cert_type][:content]
mobileprovision = File.read("spec/fixtures/#{platform}/#{type}_provisioning_profile.mobileprovision").gsub('{certificate}', Base64.encode64(cert))
mobileprovision.sub!(/<key>ExpirationDate<\/key>\n\t<date>(.+)<\/date>/, "<key>ExpirationDate</key>\n\t<date>#{DateTime.now.next_year.iso8601}</date>")
File.write(mobileprovision_path(bundle_id, platform, type), mobileprovision)

path = MotionProvisioning.profile(bundle_identifier: bundle_id,
Expand Down

0 comments on commit 001ca67

Please sign in to comment.