Class: Fastlane::Actions::VerifyIpaEntitlementsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



50
51
52
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 50

def self.authors
  ['Derek Yang']
end

.available_optionsObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 54

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :ipa_path,
                            env_name: 'VERIFY_IPA_IPA_PATH',
                         description: 'Explicitly set the ipa path',
                            optional: true),
    FastlaneCore::ConfigItem.new(key: :application_identifier,
                            env_name: 'VERIFY_IPA_APPLICATION_IDENTIFIER',
                         description: 'Key application-identifier in Entitlements',
                            optional: true),
    FastlaneCore::ConfigItem.new(key: :team_identifier,
                            env_name: 'VERIFY_IPA_TEAM_IDENTIFIER',
                         description: 'Key com.apple.developer.team-identifier in Entitlements',
                            optional: true),
    FastlaneCore::ConfigItem.new(key: :aps_environment,
                            env_name: 'VERIFY_IPA_APS_ENVIRONMENT',
                         description: 'Key aps-environment in Entitlements',
                            optional: true),
    FastlaneCore::ConfigItem.new(key: :other_params,
                            env_name: 'VERIFY_IPA_OTHER_PARAMS',
                         description: 'A hash of entitlement key and expected values',
                            optional: true,
                                type: Hash)
  ]
end

.descriptionObject



46
47
48
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 46

def self.description
  'Verify ipa entitlements'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 80

def self.is_supported?(platform)
  [:ios].include?(platform)
end

.read_entitlements(params, app_path) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 14

def self.read_entitlements(params, app_path)
  profile_path = "#{app_path}/embedded.mobileprovision"
  profile_plist = sh("security cms -D -i #{profile_path}")
  UI.user_error!("Unable to extract profile") unless $? == 0

  profile = Plist.parse_xml(profile_plist)
  profile['Entitlements']
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 6

def self.run(params)
  Dir.mktmpdir do |dir|
    app_path = Helper::VerifyIpaHelper.app_path(params, dir)
    entitlements = self.read_entitlements(params, app_path)
    self.verify_entitlements(params, entitlements)
  end
end

.verify_entitlements(params, entitlements) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 23

def self.verify_entitlements(params, entitlements)
  if params[:application_identifier]
    self.verify_param(:application_identifier, params[:application_identifier], entitlements['application-identifier'])
  end
  if params[:team_identifier]
    self.verify_param(:team_identifier, params[:team_identifier], entitlements['com.apple.developer.team-identifier'])
  end
  if params[:aps_environment]
    self.verify_param(:aps_environment, params[:aps_environment], entitlements['aps-environment'])
  end
  if params[:other_params]
    params[:other_params].keys.each do |key|
      self.verify_param(key, params[:other_params][key], entitlements[key.to_s.tr('_', '-')])
    end
  end

  UI.success("Entitlements are verified.")
end

.verify_param(param, expected, actual) ⇒ Object



42
43
44
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_entitlements_action.rb', line 42

def self.verify_param(param, expected, actual)
  UI.user_error!("Mismatched #{param}. Expected: '#{expected}'; Found: '#{actual}'") unless expected == actual
end