repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot.rb | pilot/lib/pilot.rb | require "pilot/options"
require "pilot/manager"
require "pilot/build_manager"
require "pilot/tester_manager"
require "pilot/tester_importer"
require "pilot/tester_exporter"
require_relative 'pilot/module'
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/build_manager.rb | pilot/lib/pilot/build_manager.rb | require 'tmpdir'
require 'terminal-table'
require 'emoji_regex'
require 'fastlane_core/itunes_transporter'
require 'fastlane_core/build_watcher'
require 'fastlane_core/ipa_upload_package_builder'
require_relative 'manager'
module Pilot
# rubocop:disable Metrics/ClassLength
class BuildManager < Manager
def upload(options)
# Only need to login before upload if no apple_id was given
# 'login' will be deferred until before waiting for build processing
should_login_in_start = options[:apple_id].nil?
start(options, should_login: should_login_in_start)
UI.user_error!("No ipa or pkg file given") if config[:ipa].nil? && config[:pkg].nil?
if config[:ipa] && config[:pkg]
UI.important("WARNING: Both `ipa` and `pkg` options are defined either explicitly or with default_value (build found in directory)")
UI.important("Uploading `ipa` is preferred by default. Set `app_platform` to `osx` to force uploading `pkg`")
end
check_for_changelog_or_whats_new!(options)
UI.success("Ready to upload new build to TestFlight (App: #{fetch_app_id})...")
dir = Dir.mktmpdir
platform = fetch_app_platform
ipa_path = options[:ipa]
if ipa_path && platform != 'osx'
asset_path = ipa_path
app_identifier = config[:app_identifier] || fetch_app_identifier
short_version = config[:app_version] || FastlaneCore::IpaFileAnalyser.fetch_app_version(ipa_path)
bundle_version = config[:build_number] || FastlaneCore::IpaFileAnalyser.fetch_app_build(ipa_path)
package_path = FastlaneCore::IpaUploadPackageBuilder.new.generate(app_id: fetch_app_id,
ipa_path: ipa_path,
package_path: dir,
platform: platform,
app_identifier: app_identifier,
short_version: short_version,
bundle_version: bundle_version)
else
pkg_path = options[:pkg]
asset_path = pkg_path
package_path = FastlaneCore::PkgUploadPackageBuilder.new.generate(app_id: fetch_app_id,
pkg_path: pkg_path,
package_path: dir,
platform: platform)
end
transporter = transporter_for_selected_team(options)
result = transporter.upload(package_path: package_path, asset_path: asset_path, platform: platform)
unless result
transporter_errors = transporter.displayable_errors
file_type = platform == "osx" ? "pkg" : "ipa"
UI.user_error!("Error uploading #{file_type} file: \n #{transporter_errors}")
end
UI.success("Successfully uploaded the new binary to App Store Connect")
# We will fully skip waiting for build processing *only* if no changelog is supplied
# Otherwise we may partially wait until the build appears so the changelog can be set, and then bail.
return_when_build_appears = false
if config[:skip_waiting_for_build_processing]
if config[:changelog].nil?
UI.important("`skip_waiting_for_build_processing` used and no `changelog` supplied - skipping waiting for build processing")
return
else
UI.important("`skip_waiting_for_build_processing` used and `changelog` supplied - will wait until build appears on App Store Connect, update the changelog and then skip the rest of the remaining of the processing steps.")
return_when_build_appears = true
end
end
# Calling login again here is needed if login was not called during 'start'
login unless should_login_in_start
if config[:skip_waiting_for_build_processing].nil?
UI.message("If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option")
UI.message("Note that if `skip_waiting_for_build_processing` is used but a `changelog` is supplied, this process will wait for the build to appear on App Store Connect, update the changelog and then skip the remaining of the processing steps.")
end
latest_build = wait_for_build_processing_to_be_complete(return_when_build_appears)
distribute(options, build: latest_build)
end
def has_changelog_or_whats_new?(options)
# Look for legacy :changelog option
has_changelog = !options[:changelog].nil?
# Look for :whats_new in :localized_build_info
unless has_changelog
infos_by_lang = options[:localized_build_info] || []
infos_by_lang.each do |k, v|
next if has_changelog
v ||= {}
has_changelog = v.key?(:whats_new) || v.key?('whats_new')
end
end
return has_changelog
end
def check_for_changelog_or_whats_new!(options)
if !has_changelog_or_whats_new?(options) && options[:distribute_external] == true
if UI.interactive?
options[:changelog] = UI.input("No changelog provided for new build. You can provide a changelog using the `changelog` option. For now, please provide a changelog here:")
else
UI.user_error!("No changelog provided for new build. Please either disable `distribute_external` or provide a changelog using the `changelog` option")
end
end
end
def wait_for_build_processing_to_be_complete(return_when_build_appears = false)
platform = fetch_app_platform
if config[:ipa] && platform != "osx" && !config[:distribute_only]
app_version = FastlaneCore::IpaFileAnalyser.fetch_app_version(config[:ipa])
app_build = FastlaneCore::IpaFileAnalyser.fetch_app_build(config[:ipa])
elsif config[:pkg] && !config[:distribute_only]
app_version = FastlaneCore::PkgFileAnalyser.fetch_app_version(config[:pkg])
app_build = FastlaneCore::PkgFileAnalyser.fetch_app_build(config[:pkg])
else
app_version = config[:app_version]
app_build = config[:build_number]
end
latest_build = FastlaneCore::BuildWatcher.wait_for_build_processing_to_be_complete(
app_id: app.id,
platform: platform,
app_version: app_version,
build_version: app_build,
poll_interval: config[:wait_processing_interval],
timeout_duration: config[:wait_processing_timeout_duration],
return_when_build_appears: return_when_build_appears,
return_spaceship_testflight_build: false,
select_latest: config[:distribute_only],
wait_for_build_beta_detail_processing: true
)
unless latest_build.app_version == app_version && latest_build.version == app_build
UI.important("Uploaded app #{app_version} - #{app_build}, but received build #{latest_build.app_version} - #{latest_build.version}.")
end
return latest_build
end
def distribute(options, build: nil)
start(options)
if config[:apple_id].to_s.length == 0 && config[:app_identifier].to_s.length == 0
config[:app_identifier] = UI.input("App Identifier: ")
end
# Get latest uploaded build if no build specified
if build.nil?
app_version = config[:app_version]
build_number = config[:build_number]
if build_number.nil?
if app_version.nil?
UI.important("No build specified - fetching latest build")
else
UI.important("No build specified - fetching latest build for version #{app_version}")
end
end
platform = Spaceship::ConnectAPI::Platform.map(fetch_app_platform)
build ||= Spaceship::ConnectAPI::Build.all(app_id: app.id, version: app_version, build_number: build_number, sort: "-uploadedDate", platform: platform, limit: Spaceship::ConnectAPI::Platform::ALL.size).first
end
# Verify the build has all the includes that we need
# and fetch a new build if not
if build && (!build.app || !build.build_beta_detail || !build.pre_release_version)
UI.important("Build did include information for app, build beta detail and pre release version")
UI.important("Fetching a new build with all the information needed")
build = Spaceship::ConnectAPI::Build.get(build_id: build.id)
end
# Error out if no build
if build.nil?
UI.user_error!("No build to distribute!")
end
# Update beta app meta info
# 1. Demo account required
# 2. App info
# 3. Localized app info
# 4. Localized build info
# 5. Auto notify enabled with config[:notify_external_testers]
update_beta_app_meta(options, build)
return if config[:skip_submission]
if options[:reject_build_waiting_for_review]
reject_build_waiting_for_review(build)
end
if options[:expire_previous_builds]
expire_previous_builds(build)
end
if !build.ready_for_internal_testing? && options[:skip_waiting_for_build_processing]
# Meta can be uploaded for a build still in processing
# Returning before distribute if skip_waiting_for_build_processing
# because can't distribute an app that is still processing
return
end
distribute_build(build, options)
type = options[:distribute_external] ? 'External' : 'Internal'
UI.success("Successfully distributed build to #{type} testers 🚀")
end
def list(options)
start(options)
if config[:apple_id].to_s.length == 0 && config[:app_identifier].to_s.length == 0
config[:app_identifier] = UI.input("App Identifier: ")
end
# Get processing builds
build_deliveries = app.get_build_deliveries.map do |build_delivery|
[
build_delivery.cf_build_short_version_string,
build_delivery.cf_build_version
]
end
# Get processed builds
builds = app.get_builds(includes: "betaBuildMetrics,preReleaseVersion", sort: "-uploadedDate").map do |build|
[
build.app_version,
build.version,
(build.beta_build_metrics || []).map(&:install_count).compact.reduce(:+)
]
end
# Only show table if there are any build deliveries
unless build_deliveries.empty?
puts(Terminal::Table.new(
title: "#{app.name} Processing Builds".green,
headings: ["Version #", "Build #"],
rows: FastlaneCore::PrintTable.transform_output(build_deliveries)
))
end
puts(Terminal::Table.new(
title: "#{app.name} Builds".green,
headings: ["Version #", "Build #", "Installs"],
rows: FastlaneCore::PrintTable.transform_output(builds)
))
end
def update_beta_app_meta(options, build)
# If demo_account_required is a parameter, it should added into beta_app_review_info
unless options[:demo_account_required].nil?
options[:beta_app_review_info] = {} if options[:beta_app_review_info].nil?
options[:beta_app_review_info][:demo_account_required] = options[:demo_account_required]
end
if should_update_beta_app_review_info(options)
update_review_detail(build, options[:beta_app_review_info])
end
if should_update_localized_app_information?(options)
update_localized_app_review(build, options[:localized_app_info])
elsif should_update_app_test_information?(options)
default_info = {}
default_info[:feedback_email] = options[:beta_app_feedback_email] if options[:beta_app_feedback_email]
default_info[:description] = options[:beta_app_description] if options[:beta_app_description]
begin
update_localized_app_review(build, {}, default_info: default_info)
UI.success("Successfully set the beta_app_feedback_email and/or beta_app_description")
rescue => ex
UI.user_error!("Could not set beta_app_feedback_email and/or beta_app_description: #{ex}")
end
end
if should_update_localized_build_information?(options)
update_localized_build_review(build, options[:localized_build_info])
elsif should_update_build_information?(options)
begin
update_localized_build_review(build, {}, default_info: { whats_new: options[:changelog] })
UI.success("Successfully set the changelog for build")
rescue => ex
UI.user_error!("Could not set changelog: #{ex}")
end
end
if options[:notify_external_testers].nil?
UI.important("Using App Store Connect's default for notifying external testers (which is true) - set `notify_external_testers` for full control")
else
update_build_beta_details(build, {
auto_notify_enabled: options[:notify_external_testers]
})
end
end
def self.truncate_changelog(changelog)
max_changelog_bytes = 4000
if changelog
changelog_bytes = changelog.unpack('C*').length
if changelog_bytes > max_changelog_bytes
UI.important("Changelog will be truncated since it exceeds Apple's #{max_changelog_bytes}-byte limit. It currently contains #{changelog_bytes} bytes.")
new_changelog = ''
new_changelog_bytes = 0
max_changelog_bytes -= 3 # Will append '...' later.
changelog.chars.each do |char|
new_changelog_bytes += char.unpack('C*').length
break if new_changelog_bytes >= max_changelog_bytes
new_changelog += char
end
changelog = new_changelog + '...'
end
end
changelog
end
def self.emoji_regex
# EmojiRegex::RGIEmoji is now preferred over EmojiRegex::Regex which is deprecated as of 3.2.0
# https://github.com/ticky/ruby-emoji-regex/releases/tag/v3.2.0
return defined?(EmojiRegex::RGIEmoji) ? EmojiRegex::RGIEmoji : EmojiRegex::Regex
end
def self.strip_emoji(changelog)
if changelog && changelog =~ emoji_regex
changelog.gsub!(emoji_regex, "")
UI.important("Emoji symbols have been removed from the changelog, since they're not allowed by Apple.")
end
changelog
end
def self.strip_less_than_sign(changelog)
if changelog && changelog.include?("<")
changelog.delete!("<")
UI.important("Less than signs (<) have been removed from the changelog, since they're not allowed by Apple.")
end
changelog
end
def self.sanitize_changelog(changelog)
changelog = strip_emoji(changelog)
changelog = strip_less_than_sign(changelog)
truncate_changelog(changelog)
end
private
def describe_build(build)
row = [build.train_version,
build.build_version,
build.install_count]
return row
end
def should_update_beta_app_review_info(options)
!options[:beta_app_review_info].nil?
end
def should_update_build_information?(options)
options[:changelog].to_s.length > 0
end
def should_update_app_test_information?(options)
options[:beta_app_description].to_s.length > 0 || options[:beta_app_feedback_email].to_s.length > 0
end
def should_update_localized_app_information?(options)
!options[:localized_app_info].nil?
end
def should_update_localized_build_information?(options)
!options[:localized_build_info].nil?
end
def reject_build_waiting_for_review(build)
waiting_for_review_build = build.app.get_builds(
filter: { "betaAppReviewSubmission.betaReviewState" => "WAITING_FOR_REVIEW,IN_REVIEW",
"expired" => false,
"preReleaseVersion.version" => build.pre_release_version.version },
includes: "betaAppReviewSubmission,preReleaseVersion"
).first
unless waiting_for_review_build.nil?
UI.important("Another build is already in review. Going to remove that build and submit the new one.")
UI.important("Canceling beta app review submission for build: #{waiting_for_review_build.app_version} - #{waiting_for_review_build.version}")
waiting_for_review_build.expire!
UI.success("Canceled beta app review submission for previous build: #{waiting_for_review_build.app_version} - #{waiting_for_review_build.version}")
end
end
def expire_previous_builds(build)
builds_to_expire = build.app.get_builds.reject do |asc_build|
asc_build.id == build.id
end
builds_to_expire.each(&:expire!)
end
# If App Store Connect API token, use token.
# If api_key is specified and it is an Individual API Key, don't use token but use username.
# If itc_provider was explicitly specified, use it.
# 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)
# Use JWT auth
api_token = Spaceship::ConnectAPI.token
api_key = if options[:api_key].nil? && !api_token.nil?
# Load api key info if user set api_key_path, not api_key
{ key_id: api_token.key_id, issuer_id: api_token.issuer_id, key: api_token.key_raw }
elsif !options[:api_key].nil?
api_key = options[:api_key].transform_keys(&:to_sym).dup
# key is still base 64 style if api_key is loaded from option
api_key[:key] = Base64.decode64(api_key[:key]) if api_key[:is_key_content_base64]
api_key
end
# Currently no kind of transporters accept an Individual API Key. Use username and app-specific password instead.
# See https://github.com/fastlane/fastlane/issues/22115
is_individual_key = !api_key.nil? && api_key[:issuer_id].nil?
if is_individual_key
api_key = nil
api_token = nil
end
unless api_token.nil?
api_token.refresh! if api_token.expired?
return FastlaneCore::ItunesTransporter.new(nil, nil, false, nil, api_token.text, altool_compatible_command: true, api_key: api_key)
end
# Otherwise use username and password
tunes_client = Spaceship::ConnectAPI.client ? Spaceship::ConnectAPI.client.tunes_client : nil
generic_transporter = FastlaneCore::ItunesTransporter.new(options[:username], nil, false, options[:itc_provider], altool_compatible_command: true, api_key: api_key)
return generic_transporter if options[:itc_provider] || tunes_client.nil?
return generic_transporter unless tunes_client.teams.count > 1
begin
team = tunes_client.teams.find { |t| t['providerId'].to_s == tunes_client.team_id }
name = team['name']
provider_id = generic_transporter.provider_ids[name]
UI.verbose("Inferred provider id #{provider_id} for team #{name}.")
return FastlaneCore::ItunesTransporter.new(options[:username], nil, false, provider_id, altool_compatible_command: true, api_key: api_key)
rescue => ex
STDERR.puts(ex.to_s)
UI.verbose("Couldn't infer a provider short name for team with id #{tunes_client.team_id} automatically: #{ex}. Proceeding without provider short name.")
return generic_transporter
end
end
def distribute_build(uploaded_build, options)
UI.message("Distributing new build to testers: #{uploaded_build.app_version} - #{uploaded_build.version}")
# This is where we could add a check to see if encryption is required and has been updated
uploaded_build = set_export_compliance_if_needed(uploaded_build, options)
if options[:submit_beta_review] && (options[:groups] || options[:distribute_external])
if uploaded_build.ready_for_beta_submission?
uploaded_build.post_beta_app_review_submission
else
UI.message("Build #{uploaded_build.app_version} - #{uploaded_build.version} already submitted for review")
end
end
if options[:groups]
app = uploaded_build.app
beta_groups = app.get_beta_groups.select do |group|
options[:groups].include?(group.name)
end
unless beta_groups.empty?
uploaded_build.add_beta_groups(beta_groups: beta_groups)
end
end
if options[:distribute_external] && options[:groups].nil?
# Legacy Spaceship::TestFlight API used to have a `default_external_group` that would automatically
# get selected but this no longer exists with Spaceship::ConnectAPI
UI.user_error!("You must specify at least one group using the `:groups` option to distribute externally")
end
true
end
def set_export_compliance_if_needed(uploaded_build, options)
if uploaded_build.uses_non_exempt_encryption.nil?
uses_non_exempt_encryption = options[:uses_non_exempt_encryption]
attributes = { usesNonExemptEncryption: uses_non_exempt_encryption }
Spaceship::ConnectAPI.patch_builds(build_id: uploaded_build.id, attributes: attributes)
UI.important("Export compliance has been set to '#{uses_non_exempt_encryption}'. Need to wait for build to finishing processing again...")
UI.important("Set 'ITSAppUsesNonExemptEncryption' in the 'Info.plist' to skip this step and speed up the submission")
loop do
build = Spaceship::ConnectAPI::Build.get(build_id: uploaded_build.id)
return build unless build.missing_export_compliance?
UI.message("Waiting for build #{uploaded_build.id} to process export compliance")
sleep(5)
end
else
return uploaded_build
end
end
def update_review_detail(build, info)
info = info.transform_keys(&:to_sym)
attributes = {}
attributes[:contactEmail] = info[:contact_email] if info.key?(:contact_email)
attributes[:contactFirstName] = info[:contact_first_name] if info.key?(:contact_first_name)
attributes[:contactLastName] = info[:contact_last_name] if info.key?(:contact_last_name)
attributes[:contactPhone] = info[:contact_phone] if info.key?(:contact_phone)
attributes[:demoAccountName] = info[:demo_account_name] if info.key?(:demo_account_name)
attributes[:demoAccountPassword] = info[:demo_account_password] if info.key?(:demo_account_password)
attributes[:demoAccountRequired] = info[:demo_account_required] if info.key?(:demo_account_required)
attributes[:notes] = info[:notes] if info.key?(:notes)
Spaceship::ConnectAPI.patch_beta_app_review_detail(app_id: build.app.id, attributes: attributes)
end
def update_localized_app_review(build, info_by_lang, default_info: nil)
info_by_lang = info_by_lang.transform_keys(&:to_sym)
if default_info
info_by_lang.delete(:default)
else
default_info = info_by_lang.delete(:default)
end
# Initialize hash of lang codes with info_by_lang keys
localizations_by_lang = {}
info_by_lang.each_key do |key|
localizations_by_lang[key] = nil
end
# Validate locales exist
localizations = app.get_beta_app_localizations
localizations.each do |localization|
localizations_by_lang[localization.locale.to_sym] = localization
end
# Create or update localized app review info
localizations_by_lang.each do |lang_code, localization|
info = info_by_lang[lang_code]
info = default_info unless info
update_localized_app_review_for_lang(app, localization, lang_code, info) if info
end
end
def update_localized_app_review_for_lang(app, localization, locale, info)
attributes = {}
attributes[:feedbackEmail] = info[:feedback_email] if info.key?(:feedback_email)
attributes[:marketingUrl] = info[:marketing_url] if info.key?(:marketing_url)
attributes[:privacyPolicyUrl] = info[:privacy_policy_url] if info.key?(:privacy_policy_url)
attributes[:tvOsPrivacyPolicy] = info[:tv_os_privacy_policy_url] if info.key?(:tv_os_privacy_policy_url)
attributes[:description] = info[:description] if info.key?(:description)
if localization
Spaceship::ConnectAPI.patch_beta_app_localizations(localization_id: localization.id, attributes: attributes)
else
attributes[:locale] = locale if locale
Spaceship::ConnectAPI.post_beta_app_localizations(app_id: app.id, attributes: attributes)
end
end
def update_localized_build_review(build, info_by_lang, default_info: nil)
info_by_lang = info_by_lang.transform_keys(&:to_sym)
if default_info
info_by_lang.delete(:default)
else
default_info = info_by_lang.delete(:default)
end
# Initialize hash of lang codes with info_by_lang keys
localizations_by_lang = {}
info_by_lang.each_key do |key|
localizations_by_lang[key] = nil
end
# Validate locales exist
localizations = build.get_beta_build_localizations
localizations.each do |localization|
localizations_by_lang[localization.locale.to_sym] = localization
end
# Create or update localized app review info
localizations_by_lang.each do |lang_code, localization|
info = info_by_lang[lang_code]
info = default_info unless info
update_localized_build_review_for_lang(build, localization, lang_code, info) if info
end
end
def update_localized_build_review_for_lang(build, localization, locale, info)
attributes = {}
attributes[:whatsNew] = self.class.sanitize_changelog(info[:whats_new]) if info.key?(:whats_new)
if localization
Spaceship::ConnectAPI.patch_beta_build_localizations(localization_id: localization.id, attributes: attributes)
else
attributes[:locale] = locale if locale
Spaceship::ConnectAPI.post_beta_build_localizations(build_id: build.id, attributes: attributes)
end
end
def update_build_beta_details(build, info)
attributes = {}
attributes[:autoNotifyEnabled] = info[:auto_notify_enabled] if info.key?(:auto_notify_enabled)
build_beta_detail = build.build_beta_detail
if build_beta_detail
Spaceship::ConnectAPI.patch_build_beta_details(build_beta_details_id: build_beta_detail.id, attributes: attributes)
else
if attributes[:autoNotifyEnabled]
UI.important("Unable to auto notify testers as the build did not include beta detail information - this is likely a temporary issue on TestFlight.")
end
end
end
end
# rubocop:enable Metrics/ClassLength
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/tester_exporter.rb | pilot/lib/pilot/tester_exporter.rb | require 'spaceship/tunes/application'
require_relative 'module'
require_relative 'manager'
module Pilot
class TesterExporter < Manager
def export_testers(options)
UI.user_error!("Export file path is required") unless options[:testers_file_path]
start(options)
require 'csv'
app = find_app(apple_id: options[:apple_id], app_identifier: options[:app_identifier])
if app
testers = app.get_beta_testers(includes: "apps,betaTesterMetrics,betaGroups")
else
testers = Spaceship::ConnectAPI::BetaTester.all(includes: "apps,betaTesterMetrics,betaGroups")
end
file = config[:testers_file_path]
CSV.open(file, "w") do |csv|
csv << ['First', 'Last', 'Email', 'Groups', 'Installed Version', 'Install Date']
testers.each do |tester|
group_names = tester.beta_groups.map(&:name).join(";") || ""
metric = (tester.beta_tester_metrics || []).first
if metric.installed?
install_version = "#{metric.installed_cf_bundle_short_version_string} (#{metric.installed_cf_bundle_version})"
pretty_date = metric.installed_cf_bundle_version
end
csv << [tester.first_name, tester.last_name, tester.email, group_names, install_version, pretty_date]
end
UI.success("Successfully exported CSV to #{file}")
end
end
def find_app(apple_id: nil, app_identifier: nil)
if app_identifier
app = Spaceship::ConnectAPI::App.find(app_identifier)
UI.user_error!("Could not find an app by #{app_identifier}") unless app
return app
end
if apple_id
app = Spaceship::ConnectAPI::App.get(app_id: apple_id)
UI.user_error!("Could not find an app by #{apple_id}") unless app
return app
end
UI.user_error!("You must include an `app_identifier` to `list_testers`")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/options.rb | pilot/lib/pilot/options.rb | require 'fastlane_core/configuration/config_item'
require 'credentials_manager/appfile_config'
require_relative 'module'
module Pilot
class Options
def self.available_options
user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id)
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
[
FastlaneCore::ConfigItem.new(key: :api_key_path,
env_names: ["PILOT_API_KEY_PATH", "APP_STORE_CONNECT_API_KEY_PATH"],
description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
optional: true,
conflicting_options: [:username],
verify_block: proc do |value|
UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :api_key,
env_names: ["PILOT_API_KEY", "APP_STORE_CONNECT_API_KEY"],
description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-hash-option)",
type: Hash,
optional: true,
sensitive: true,
conflicting_options: [:api_key_path, :username]),
# app upload info
FastlaneCore::ConfigItem.new(key: :username,
short_option: "-u",
env_name: "PILOT_USERNAME",
description: "Your Apple ID Username",
optional: true,
default_value: user,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
short_option: "-a",
env_name: "PILOT_APP_IDENTIFIER",
description: "The bundle identifier of the app to upload or manage testers (optional)",
optional: true,
code_gen_sensitive: true,
# This incorrect env name is here for backwards compatibility
default_value: ENV["TESTFLIGHT_APP_IDENTITIFER"] || CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :app_platform,
short_option: "-m",
env_name: "PILOT_PLATFORM",
description: "The platform to use (optional)",
optional: true,
verify_block: proc do |value|
UI.user_error!("The platform can only be ios, appletvos, osx, or xros") unless ['ios', 'appletvos', 'osx', 'xros'].include?(value)
end),
FastlaneCore::ConfigItem.new(key: :apple_id,
short_option: "-p",
env_name: "PILOT_APPLE_ID",
description: "Apple ID property in the App Information section in App Store Connect",
optional: true,
code_gen_sensitive: true,
default_value: ENV["TESTFLIGHT_APPLE_ID"],
default_value_dynamic: true,
type: String,
verify_block: proc do |value|
error_message = "`apple_id` value is incorrect. The correct value should be taken from Apple ID property in the App Information section in App Store Connect."
# Validate if the value is not an email address
UI.user_error!(error_message) if value =~ /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
# Validate if the value is not a bundle identifier
UI.user_error!(error_message) if value =~ /^[A-Za-x]{2,6}((?!-)\.[A-Za-z0-9-]{1,63}(?<!-))+$/i
end),
FastlaneCore::ConfigItem.new(key: :ipa,
short_option: "-i",
optional: true,
env_name: "PILOT_IPA",
description: "Path to the ipa file to upload",
code_gen_sensitive: true,
default_value: Dir["*.ipa"].sort_by { |x| File.mtime(x) }.last,
default_value_dynamic: true,
verify_block: proc do |value|
value = File.expand_path(value)
UI.user_error!("Could not find ipa file at path '#{value}'") unless File.exist?(value)
UI.user_error!("'#{value}' doesn't seem to be an ipa file") unless value.end_with?(".ipa")
end,
conflicting_options: [:pkg],
conflict_block: proc do |value|
UI.user_error!("You can't use 'ipa' and '#{value.key}' options in one run.")
end),
FastlaneCore::ConfigItem.new(key: :pkg,
short_option: "-P",
optional: true,
env_name: "PILOT_PKG",
description: "Path to your pkg file",
code_gen_sensitive: true,
default_value: Dir["*.pkg"].sort_by { |x| File.mtime(x) }.last,
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Could not find pkg file at path '#{File.expand_path(value)}'") unless File.exist?(value)
UI.user_error!("'#{value}' doesn't seem to be a pkg file") unless value.end_with?(".pkg")
end,
conflicting_options: [:ipa],
conflict_block: proc do |value|
UI.user_error!("You can't use 'pkg' and '#{value.key}' options in one run.")
end),
# app review info
FastlaneCore::ConfigItem.new(key: :demo_account_required,
type: Boolean,
env_name: "DEMO_ACCOUNT_REQUIRED",
description: "Do you need a demo account when Apple does review?",
optional: true),
FastlaneCore::ConfigItem.new(key: :beta_app_review_info,
type: Hash,
env_name: "PILOT_BETA_APP_REVIEW_INFO",
description: "Beta app review information for contact info and demo account",
optional: true,
verify_block: proc do |values|
valid_keys = %w(contact_email contact_first_name contact_last_name contact_phone demo_account_required demo_account_name demo_account_password notes)
values.keys.each { |value| UI.user_error!("Invalid key '#{value}'") unless valid_keys.include?(value.to_s) }
end),
# app detail
FastlaneCore::ConfigItem.new(key: :localized_app_info,
type: Hash,
env_name: "PILOT_LOCALIZED_APP_INFO",
description: "Localized beta app test info for description, feedback email, marketing url, and privacy policy",
optional: true,
verify_block: proc do |lang_values|
valid_keys = %w(feedback_email marketing_url privacy_policy_url tv_os_privacy_policy_url description)
lang_values.values.each do |values|
values.keys.each { |value| UI.user_error!("Invalid key '#{value}'") unless valid_keys.include?(value.to_s) }
end
end),
FastlaneCore::ConfigItem.new(key: :beta_app_description,
short_option: "-d",
optional: true,
env_name: "PILOT_BETA_APP_DESCRIPTION",
description: "Provide the 'Beta App Description' when uploading a new build"),
FastlaneCore::ConfigItem.new(key: :beta_app_feedback_email,
short_option: "-n",
optional: true,
env_name: "PILOT_BETA_APP_FEEDBACK",
description: "Provide the beta app email when uploading a new build"),
# build review info
FastlaneCore::ConfigItem.new(key: :localized_build_info,
type: Hash,
env_name: "PILOT_LOCALIZED_BUILD_INFO",
description: "Localized beta app test info for what's new",
optional: true,
verify_block: proc do |lang_values|
valid_keys = %w(whats_new)
lang_values.values.each do |values|
values.keys.each { |value| UI.user_error!("Invalid key '#{value}'") unless valid_keys.include?(value.to_s) }
end
end),
FastlaneCore::ConfigItem.new(key: :changelog,
short_option: "-w",
optional: true,
env_name: "PILOT_CHANGELOG",
description: "Provide the 'What to Test' text when uploading a new build"),
FastlaneCore::ConfigItem.new(key: :skip_submission,
short_option: "-s",
env_name: "PILOT_SKIP_SUBMISSION",
description: "Skip the distributing action of pilot and only upload the ipa file",
is_string: false,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_waiting_for_build_processing,
short_option: "-z",
env_name: "PILOT_SKIP_WAITING_FOR_BUILD_PROCESSING",
description: "If set to true, the `distribute_external` option won't work and no build will be distributed to testers. " \
"(You might want to use this option if you are using this action on CI and have to pay for 'minutes used' on your CI plan). " \
"If set to `true` and a changelog is provided, it will partially wait for the build to appear on AppStore Connect so the changelog can be set, and skip the remaining processing steps",
is_string: false,
default_value: false),
FastlaneCore::ConfigItem.new(key: :update_build_info_on_upload,
deprecated: true,
short_option: "-x",
env_name: "PILOT_UPDATE_BUILD_INFO_ON_UPLOAD",
description: "Update build info immediately after validation. This is deprecated and will be removed in a future release. App Store Connect no longer supports setting build info until after build processing has completed, which is when build info is updated by default",
is_string: false,
default_value: false),
# distribution
FastlaneCore::ConfigItem.new(key: :distribute_only,
short_option: "-D",
env_name: "PILOT_DISTRIBUTE_ONLY",
description: "Distribute a previously uploaded build (equivalent to the `fastlane pilot distribute` command)",
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :uses_non_exempt_encryption,
short_option: "-X",
env_name: "PILOT_USES_NON_EXEMPT_ENCRYPTION",
description: "Provide the 'Uses Non-Exempt Encryption' for export compliance. This is used if there is 'ITSAppUsesNonExemptEncryption' is not set in the Info.plist",
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :distribute_external,
is_string: false,
env_name: "PILOT_DISTRIBUTE_EXTERNAL",
description: "Should the build be distributed to external testers? If set to true, use of `groups` option is required",
default_value: false),
FastlaneCore::ConfigItem.new(key: :notify_external_testers,
is_string: false,
env_name: "PILOT_NOTIFY_EXTERNAL_TESTERS",
description: "Should notify external testers? (Not setting a value will use App Store Connect's default which is to notify)",
optional: true),
FastlaneCore::ConfigItem.new(key: :app_version,
env_name: "PILOT_APP_VERSION",
description: "The version number of the application build to distribute. If the version number is not specified, then the most recent build uploaded to TestFlight will be distributed. If specified, the most recent build for the version number will be distributed",
optional: true),
FastlaneCore::ConfigItem.new(key: :build_number,
env_name: "PILOT_BUILD_NUMBER",
description: "The build number of the application build to distribute. If the build number is not specified, the most recent build is distributed",
optional: true),
FastlaneCore::ConfigItem.new(key: :expire_previous_builds,
is_string: false,
env_name: "PILOT_EXPIRE_PREVIOUS_BUILDS",
description: "Should expire previous builds?",
default_value: false),
# testers
FastlaneCore::ConfigItem.new(key: :first_name,
short_option: "-f",
env_name: "PILOT_TESTER_FIRST_NAME",
description: "The tester's first name",
optional: true),
FastlaneCore::ConfigItem.new(key: :last_name,
short_option: "-l",
env_name: "PILOT_TESTER_LAST_NAME",
description: "The tester's last name",
optional: true),
FastlaneCore::ConfigItem.new(key: :email,
short_option: "-e",
env_name: "PILOT_TESTER_EMAIL",
description: "The tester's email",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass a valid email address") unless value.include?("@")
end),
FastlaneCore::ConfigItem.new(key: :testers_file_path,
short_option: "-c",
env_name: "PILOT_TESTERS_FILE",
description: "Path to a CSV file of testers",
default_value: "./testers.csv",
optional: true),
FastlaneCore::ConfigItem.new(key: :groups,
short_option: "-g",
env_name: "PILOT_GROUPS",
description: "Associate tester to one group or more by group name / group id. E.g. `-g \"Team 1\",\"Team 2\"` This is required when `distribute_external` option is set to true or when we want to add a tester to one or more external testing groups ",
optional: true,
type: Array,
verify_block: proc do |value|
UI.user_error!("Could not evaluate array from '#{value}'") unless value.kind_of?(Array)
end),
# app store connect teams
FastlaneCore::ConfigItem.new(key: :team_id,
short_option: "-q",
env_name: "PILOT_TEAM_ID",
description: "The ID of your App Store Connect team if you're in multiple teams",
optional: true,
is_string: false, # as we also allow integers, which we convert to strings anyway
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_ITC_TEAM_ID"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :team_name,
short_option: "-r",
env_name: "PILOT_TEAM_NAME",
description: "The name of your App Store Connect team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_ITC_TEAM_NAME"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :dev_portal_team_id,
env_name: "PILOT_DEV_PORTAL_TEAM_ID",
description: "The short ID of your team in the developer portal, if you're in multiple teams. Different from your iTC team ID!",
optional: true,
is_string: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_TEAM_ID"] = value.to_s
end),
# rubocop:disable Layout/LineLength
FastlaneCore::ConfigItem.new(key: :itc_provider,
env_name: "PILOT_ITC_PROVIDER",
description: "The provider short name to be used with the iTMSTransporter to identify your team. This value will override the automatically detected provider short name. To get provider short name run `pathToXcode.app/Contents/Applications/Application\\ Loader.app/Contents/itms/bin/iTMSTransporter -m provider -u 'USERNAME' -p 'PASSWORD' -account_type itunes_connect -v off`. The short names of providers should be listed in the second column",
optional: true),
# rubocop:enable Layout/LineLength
# waiting and uploaded build
FastlaneCore::ConfigItem.new(key: :wait_processing_interval,
short_option: "-k",
env_name: "PILOT_WAIT_PROCESSING_INTERVAL",
description: "Interval in seconds to wait for App Store Connect processing",
default_value: 30,
type: Integer,
verify_block: proc do |value|
UI.user_error!("Please enter a valid positive number of seconds") unless value.to_i > 0
end),
FastlaneCore::ConfigItem.new(key: :wait_processing_timeout_duration,
env_name: "PILOT_WAIT_PROCESSING_TIMEOUT_DURATION",
description: "Timeout duration in seconds to wait for App Store Connect processing. If set, after exceeding timeout duration, this will `force stop` to wait for App Store Connect processing and exit with exception",
optional: true,
type: Integer,
verify_block: proc do |value|
UI.user_error!("Please enter a valid positive number of seconds") unless value.to_i > 0
end),
FastlaneCore::ConfigItem.new(key: :wait_for_uploaded_build,
env_name: "PILOT_WAIT_FOR_UPLOADED_BUILD",
deprecated: "No longer needed with the transition over to the App Store Connect API",
description: "Use version info from uploaded ipa file to determine what build to use for distribution. If set to false, latest processing or any latest build will be used",
is_string: false,
default_value: false),
FastlaneCore::ConfigItem.new(key: :reject_build_waiting_for_review,
short_option: "-b",
env_name: "PILOT_REJECT_PREVIOUS_BUILD",
description: "Expire previous if it's 'waiting for review'",
is_string: false,
default_value: false),
FastlaneCore::ConfigItem.new(key: :submit_beta_review,
env_name: "PILOT_DISTRIBUTE_EXTERNAL",
description: "Send the build for a beta review",
type: Boolean,
default_value: true)
]
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/tester_importer.rb | pilot/lib/pilot/tester_importer.rb | require_relative 'module'
require_relative 'manager'
require_relative 'tester_manager'
module Pilot
class TesterImporter < Manager
def import_testers(options)
UI.user_error!("Import file path is required") unless options[:testers_file_path]
start(options)
require 'csv'
file = config[:testers_file_path]
tester_manager = Pilot::TesterManager.new
imported_tester_count = 0
groups = options[:groups]
CSV.foreach(file, "r") do |row|
first_name, last_name, email, testing_groups = row
unless email
UI.error("No email found in row: #{row}")
next
end
unless email.index("@")
UI.error("No email found in row: #{row}")
next
end
# Add this the existing config hash to pass it to the TesterManager
config[:first_name] = first_name
config[:last_name] = last_name
config[:email] = email
config[:groups] = groups
if testing_groups
config[:groups] = testing_groups.split(";")
end
begin
tester_manager.add_tester(config)
imported_tester_count += 1
rescue => exception
UI.error("Error adding tester #{email}: #{exception}")
end
end
UI.success("Successfully imported #{imported_tester_count} testers from #{file}")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/commands_generator.rb | pilot/lib/pilot/commands_generator.rb | require "commander"
require 'fastlane_core/configuration/configuration'
require 'fastlane_core/ui/help_formatter'
require_relative 'module'
require_relative 'tester_importer'
require_relative 'tester_exporter'
require_relative 'tester_manager'
require_relative 'build_manager'
require_relative 'options'
HighLine.track_eof = false
module Pilot
class CommandsGenerator
include Commander::Methods
def self.start
new.run
end
def convert_options(options)
o = options.__hash__.dup
o.delete(:verbose)
o
end
def handle_multiple(action, args, options)
mgr = Pilot::TesterManager.new
config = create_config(options)
args.push(config[:email]) if config[:email] && args.empty?
args.push(UI.input("Email address of the tester: ")) if args.empty?
failures = []
args.each do |address|
config[:email] = address
begin
mgr.public_send(action, config)
rescue => ex
# no need to show the email address in the message if only one specified
message = (args.count > 1) ? "[#{address}]: #{ex}" : ex
failures << message
UI.error(message)
end
end
UI.user_error!("Some operations failed: #{failures.join(', ')}") unless failures.empty?
end
def run
program :name, 'pilot'
program :version, Fastlane::VERSION
program :description, Pilot::DESCRIPTION
program :help, "Author", "Felix Krause <pilot@krausefx.com>"
program :help, "Website", "https://fastlane.tools"
program :help, "Documentation", "https://docs.fastlane.tools/actions/pilot/"
program :help_formatter, FastlaneCore::HelpFormatter
global_option("--verbose") { FastlaneCore::Globals.verbose = true }
command :upload do |c|
c.syntax = "fastlane pilot upload"
c.description = "Uploads a new binary to Apple TestFlight"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
config = create_config(options)
Pilot::BuildManager.new.upload(config)
end
end
command :distribute do |c|
c.syntax = "fastlane pilot distribute"
c.description = "Distribute a previously uploaded binary to Apple TestFlight"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
config = create_config(options)
Pilot::BuildManager.new.distribute(config)
end
end
command :builds do |c|
c.syntax = "fastlane pilot builds"
c.description = "Lists all builds for given application"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
config = create_config(options)
Pilot::BuildManager.new.list(config)
end
end
command :add do |c|
c.syntax = "fastlane pilot add"
c.description = "Adds new external tester(s) to a specific app (if given). This will also add an existing tester to an app."
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
handle_multiple('add_tester', args, options)
end
end
command :list do |c|
c.syntax = "fastlane pilot list"
c.description = "Lists all registered testers, both internal and external"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
config = create_config(options)
UI.user_error!("You must include an `app_identifier` to list testers") unless config[:app_identifier]
Pilot::TesterManager.new.list_testers(config)
end
end
command :find do |c|
c.syntax = "fastlane pilot find"
c.description = "Find tester(s) (internal or external) by their email address"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
handle_multiple('find_tester', args, options)
end
end
command :remove do |c|
c.syntax = "fastlane pilot remove"
c.description = "Remove external tester(s) by their email address"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
handle_multiple('remove_tester', args, options)
end
end
command :export do |c|
c.syntax = "fastlane pilot export"
c.description = "Exports all external testers to a CSV file"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
config = create_config(options)
Pilot::TesterExporter.new.export_testers(config)
end
end
command :import do |c|
c.syntax = "fastlane pilot import"
c.description = "Import external testers from a CSV file called testers.csv"
FastlaneCore::CommanderGenerator.new.generate(Pilot::Options.available_options, command: c)
c.action do |args, options|
config = create_config(options)
Pilot::TesterImporter.new.import_testers(config)
end
end
default_command(:help)
run!
end
def create_config(options)
config = FastlaneCore::Configuration.create(Pilot::Options.available_options, convert_options(options))
return config
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/tester_manager.rb | pilot/lib/pilot/tester_manager.rb | require 'terminal-table'
require_relative 'manager'
module Pilot
class TesterManager < Manager
def add_tester(options)
start(options)
app = find_app(apple_id: config[:apple_id], app_identifier: config[:app_identifier])
UI.user_error!("You must provide either a Apple ID for the app (with the `:apple_id` option) or app identifier (with the `:app_identifier` option)") unless app
groups_param = config[:groups]
UI.user_error!("You must provide 1 or more groups (with the `:groups` option)") unless groups_param
app.get_beta_groups.select do |group|
next unless groups_param.include?(group.name)
user = {
email: config[:email],
firstName: config[:first_name],
lastName: config[:last_name]
}
group.post_bulk_beta_tester_assignments(beta_testers: [user])
end
group_names = groups_param.join(';')
UI.success("Successfully added tester #{config[:email]} to app #{app.name} in group(s) #{group_names}")
end
def find_tester(options)
start(options)
app = find_app(apple_id: config[:apple_id], app_identifier: config[:app_identifier])
tester = find_app_tester(email: config[:email], app: app)
UI.user_error!("Tester #{config[:email]} not found") unless tester
describe_tester(tester)
return tester
end
def remove_tester(options)
start(options)
app = find_app(apple_id: config[:apple_id], app_identifier: config[:app_identifier])
tester = find_app_tester(email: config[:email], app: app)
UI.user_error!("Tester #{config[:email]} not found") unless tester
begin
# If no groups are passed to options, remove the tester from the app-level,
# otherwise remove the tester from the groups specified.
if config[:groups].nil?
tester.delete_from_apps(apps: [app])
UI.success("Successfully removed tester #{tester.email} from app: #{app.name}")
else
groups = tester.beta_groups.select do |group|
config[:groups].include?(group.name)
end
tester.delete_from_beta_groups(beta_groups: groups)
group_names = groups.map(&:name)
UI.success("Successfully removed tester #{tester.email} from app #{app.name} in group(s) #{group_names}")
end
rescue => ex
UI.error("Could not remove #{tester.email} from app: #{ex}")
raise ex
end
end
def list_testers(options)
start(options)
app = find_app(apple_id: config[:apple_id], app_identifier: config[:app_identifier])
if app
list_testers_by_app(app)
else
UI.user_error!("You must include an `app_identifier` to `list_testers`")
end
end
private
def find_app(apple_id: nil, app_identifier: nil)
if app_identifier
app = Spaceship::ConnectAPI::App.find(app_identifier)
UI.user_error!("Could not find an app by #{app_identifier}") unless app
return app
end
if apple_id
app = Spaceship::ConnectAPI::App.get(app_id: apple_id)
UI.user_error!("Could not find an app by #{apple_id}") unless app
return app
end
UI.user_error!("You must include an `app_identifier` to `list_testers`")
end
def find_app_tester(email: nil, app: nil)
tester = app.get_beta_testers(filter: { email: email }, includes: "apps,betaTesterMetrics,betaGroups").first
if tester
UI.success("Found existing tester #{email}")
end
return tester
end
def list_testers_by_app(app)
testers = app.get_beta_testers(includes: "apps,betaTesterMetrics,betaGroups")
list_by_app(testers, "All Testers")
end
def list_by_app(all_testers, title)
headers = ["First", "Last", "Email", "Groups"]
list(all_testers, "#{title} (#{all_testers.count})", headers) do |tester|
tester_groups = tester.beta_groups.nil? ? nil : tester.beta_groups.map(&:name).join(";")
[
tester.first_name,
tester.last_name,
tester.email,
tester_groups
# Testers returned by the query made in the context of an app do not contain
# the version, or install date information
]
end
end
# Requires a block that accepts a tester and returns an array of tester column values
def list(all_testers, title, headings)
rows = all_testers.map { |tester| yield(tester) }
puts(Terminal::Table.new(
title: title.green,
headings: headings,
rows: FastlaneCore::PrintTable.transform_output(rows)
))
end
# Print out all the details of a specific tester
def describe_tester(tester)
return unless tester
rows = []
rows << ["First name", tester.first_name]
rows << ["Last name", tester.last_name]
rows << ["Email", tester.email]
if tester.beta_groups
rows << ["Groups", tester.beta_groups.map(&:name).join(";")]
end
metric = (tester.beta_tester_metrics || []).first
if metric.installed?
rows << ["Latest Version", "#{metric.installed_cf_bundle_short_version_string} (#{metric.installed_cf_bundle_version})"]
rows << ["Latest Install Date", metric.installed_cf_bundle_version]
rows << ["Installed", metric.installed?]
end
puts(Terminal::Table.new(
title: tester.email.green,
rows: FastlaneCore::PrintTable.transform_output(rows)
))
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/manager.rb | pilot/lib/pilot/manager.rb | require 'credentials_manager/appfile_config'
require 'fastlane_core/print_table'
require 'spaceship'
require 'spaceship/tunes/tunes'
require 'spaceship/tunes/members'
require 'spaceship/test_flight'
require 'fastlane_core/ipa_file_analyser'
require_relative 'module'
module Pilot
class Manager
def start(options, should_login: true)
return if @config # to not login multiple times
@config = options
# 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
if (api_token = Spaceship::ConnectAPI::Token.from(hash: config[:api_key], filepath: config[:api_key_path]))
UI.message("Creating authorization token for App Store Connect API")
Spaceship::ConnectAPI.token = api_token
elsif !Spaceship::ConnectAPI.token.nil?
UI.message("Using existing authorization token for App Store Connect API")
else
config[:username] ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
# Username is now optional since addition of App Store Connect API Key
# Force asking for username to prompt user if not already set
config.fetch(:username, force_ask: true)
UI.message("Login to App Store Connect (#{config[:username]})")
Spaceship::ConnectAPI.login(config[:username], use_portal: false, use_tunes: true, tunes_team_id: config[:team_id], team_name: config[:team_name])
UI.message("Login successful")
end
end
# The app object we're currently using
def app
@app_id ||= fetch_app_id
@app ||= Spaceship::ConnectAPI::App.get(app_id: @app_id)
unless @app
UI.user_error!("Could not find app with #{(config[:apple_id] || config[:app_identifier])}")
end
return @app
end
# Access the current configuration
attr_reader :config
# Config Related
################
def fetch_app_id
@app_id ||= config[:apple_id]
return @app_id if @app_id
config[:app_identifier] = fetch_app_identifier
if config[:app_identifier]
@app ||= Spaceship::ConnectAPI::App.find(config[:app_identifier])
UI.user_error!("Couldn't find app '#{config[:app_identifier]}' on the account of '#{config[:username]}' on App Store Connect") unless @app
@app_id ||= @app.id
end
@app_id ||= UI.input("Could not automatically find the app ID, please enter it here (e.g. 956814360): ")
return @app_id
end
def fetch_app_identifier
result = config[:app_identifier]
result ||= FastlaneCore::IpaFileAnalyser.fetch_app_identifier(config[:ipa]) if config[:ipa]
result ||= FastlaneCore::PkgFileAnalyser.fetch_app_identifier(config[:pkg]) if config[:pkg]
result ||= UI.input("Please enter the app's bundle identifier: ")
UI.verbose("App identifier (#{result})")
return result
end
def fetch_app_platform(required: true)
result = config[:app_platform]
result ||= FastlaneCore::IpaFileAnalyser.fetch_app_platform(config[:ipa]) if config[:ipa]
result ||= FastlaneCore::PkgFileAnalyser.fetch_app_platform(config[:pkg]) if config[:pkg]
if required
result ||= UI.input("Please enter the app's platform (appletvos, ios, osx, xros): ")
UI.user_error!("App Platform must be ios, appletvos, osx, or xros") unless ['ios', 'appletvos', 'osx', 'xros'].include?(result)
UI.verbose("App Platform (#{result})")
end
return result
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/pilot/lib/pilot/module.rb | pilot/lib/pilot/module.rb | require 'fastlane_core/helper'
require 'fastlane/boolean'
module Pilot
Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
UI = FastlaneCore::UI
Boolean = Fastlane::Boolean
ROOT = Pathname.new(File.expand_path('../../..', __FILE__))
DESCRIPTION = "The best way to manage your TestFlight testers and builds from your terminal"
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/two_step_or_factor_client_spec.rb | spaceship/spec/two_step_or_factor_client_spec.rb | require_relative 'mock_servers'
describe Spaceship::Client do
class TwoStepOrFactorClient < Spaceship::Client
def self.hostname
"http://example.com"
end
def ask_for_2fa_code(text)
'123'
end
def choose_phone_number(opts)
opts.first
end
def store_cookie(path: nil)
true
end
# these tests actually "send requests" - and `update_request_headers` would otherwise
# add data to the headers that does not exist / is empty which will crash faraday later
def update_request_headers(req)
req
end
end
let(:subject) { TwoStepOrFactorClient.new }
let(:phone_numbers_json_string) do
'
[
{ "id" : 1, "numberWithDialCode" : "+49 •••• •••••85", "obfuscatedNumber" : "•••• •••••85", "pushMode" : "sms" },
{ "id" : 2, "numberWithDialCode" : "+49 ••••• •••••81", "obfuscatedNumber" : "••••• •••••81", "pushMode" : "sms" },
{ "id" : 3, "numberWithDialCode" : "+1 (•••) •••-••66", "obfuscatedNumber" : "(•••) •••-••66", "pushMode" : "sms" },
{ "id" : 4, "numberWithDialCode" : "+39 ••• ••• ••71", "obfuscatedNumber" : "••• ••• ••71", "pushMode" : "sms" },
{ "id" : 5, "numberWithDialCode" : "+353 •• ••• ••43", "obfuscatedNumber" : "••• ••• •43", "pushMode" : "sms" },
{ "id" : 6, "numberWithDialCode" : "+375 • ••• •••-••-59", "obfuscatedNumber" : "• ••• •••-••-59", "pushMode" : "sms" }
]
'
end
let(:phone_numbers) { JSON.parse(phone_numbers_json_string) }
describe 'phone_id_from_number' do
{
"+49 123 4567885" => 1,
"+4912341234581" => 2,
"+1-123-456-7866" => 3,
"+39 123 456 7871" => 4,
"+353123456743" => 5,
"+375 00 000-00-59" => 6
}.each do |number_to_test, expected_phone_id|
it "selects correct phone id #{expected_phone_id} for provided phone number #{number_to_test}" do
phone_id = subject.phone_id_from_number(phone_numbers, number_to_test)
expect(phone_id).to eq(expected_phone_id)
end
end
it "raises an error with unknown phone number" do
phone_number = 'la le lu'
expect do
phone_id = subject.phone_id_from_number(phone_numbers, phone_number)
end.to raise_error(Spaceship::Tunes::Error)
end
end
describe 'handle_two_factor' do
let(:trusted_devices_response) { JSON.parse(File.read(File.join('spaceship', 'spec', 'fixtures', 'client_appleauth_auth_2fa_response.json'), encoding: 'utf-8')) }
let(:no_trusted_devices_response) { JSON.parse(File.read(File.join('spaceship', 'spec', 'fixtures', 'appleauth_2fa_no_trusted_devices.json'), encoding: 'utf-8')) }
let(:no_trusted_devices_voice_response) { JSON.parse(File.read(File.join('spaceship', 'spec', 'fixtures', 'appleauth_2fa_voice_no_trusted_devices.json'), encoding: 'utf-8')) }
let(:no_trusted_devices_two_numbers_response) { JSON.parse(File.read(File.join('spaceship', 'spec', 'fixtures', 'appleauth_2fa_no_trusted_devices_two_numbers.json'), encoding: 'utf-8')) }
context 'when running non-interactive' do
it 'raises an error' do
ENV["FASTLANE_IS_INTERACTIVE"] = "false"
expect(subject).to receive(:handle_two_factor)
stub_request(:get, "https://idmsa.apple.com/appleauth/auth").to_return(status: 200, body: '{"trustedPhoneNumbers": [{"1": ""}]}', headers: { 'Content-Type' => 'application/json' })
subject.handle_two_step_or_factor("response")
end
end
context 'when running non-interactive and force 2FA to be interactive only' do
it 'raises an error' do
ENV["FASTLANE_IS_INTERACTIVE"] = "false"
ENV["SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA"] = "true"
expect { subject.handle_two_step_or_factor("response") }.to raise_error("2FA can only be performed in interactive mode")
ENV.delete('SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA')
end
end
context 'when running interactive' do
it 'does not raise an error' do
ENV["FASTLANE_IS_INTERACTIVE"] = "true"
ENV["SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA"] = "true"
expect(subject).to receive(:handle_two_factor)
stub_request(:get, "https://idmsa.apple.com/appleauth/auth").to_return(status: 200, body: '{"trustedPhoneNumbers": [{"1": ""}]}', headers: { 'Content-Type' => 'application/json' })
subject.handle_two_step_or_factor("response")
end
end
context 'when interactive mode is not set' do
it 'does not raise an error' do
ENV["FASTLANE_IS_INTERACTIVE"] = nil
ENV["SPACESHIP_ONLY_ALLOW_INTERACTIVE_2FA"] = "false"
expect(subject).to receive(:handle_two_factor)
stub_request(:get, "https://idmsa.apple.com/appleauth/auth").to_return(status: 200, body: '{"trustedPhoneNumbers": [{"1": ""}]}', headers: { 'Content-Type' => 'application/json' })
subject.handle_two_step_or_factor("response")
end
end
context 'when SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER is not set' do
context 'with trusted devices' do
let(:response) do
response = OpenStruct.new
response.body = trusted_devices_response
return response
end
it 'works with input sms' do
expect(subject).to receive(:ask_for_2fa_code).twice.and_return('sms', '123')
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
# sms should be sent despite having trusted devices
expect(WebMock).to have_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone').with(body: { phoneNumber: { id: 1 }, mode: "sms" })
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: 1 }, mode: "sms" })
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode')
end
it 'does not request sms code, and submits code correctly' do
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
expect(WebMock).to have_not_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone')
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode')
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode').with(body: { securityCode: { code: "123" } })
end
end
context 'with no trusted devices' do
# sms fallback, will be sent automatically
context "with exactly one phone number" do
it "does not request sms code, and sends the correct request" do
response = OpenStruct.new
response.body = no_trusted_devices_response
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
expect(WebMock).to have_not_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone')
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode')
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: 1 }, mode: "sms" })
end
it "does not request sms code, and sends the correct request with voice" do
response = OpenStruct.new
response.body = no_trusted_devices_voice_response
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
expect(WebMock).to have_not_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone')
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode')
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: 1 }, mode: "voice" })
end
end
# sms fallback, won't be sent automatically
context 'with at least two phone numbers' do
let(:phone_id) { 2 }
let(:phone_number) { "+49 ••••• •••••81" }
let(:response) do
response = OpenStruct.new
response.body = no_trusted_devices_two_numbers_response
return response
end
before do
allow(subject).to receive(:choose_phone_number).and_return(phone_number)
end
it 'prompts user to choose number' do
expect(subject).to receive(:choose_phone_number)
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
end
it 'requests sms code, and submits code correctly' do
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode')
expect(WebMock).to have_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone').with(body: { phoneNumber: { id: phone_id }, mode: "sms" }).once
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: phone_id }, mode: "sms" })
end
end
end
end
context 'when SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER is set' do
let(:phone_number) { '+49 123 4567885' }
let(:phone_id) { 1 }
let(:response) do
response = OpenStruct.new
response.body = trusted_devices_response
return response
end
before do
ENV['SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER'] = phone_number
end
after do
ENV.delete('SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER')
end
it 'providing a known phone number returns true (and sends the correct requests)' do
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
# expected requests
expect(WebMock).to have_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone').with(body: { phoneNumber: { id: phone_id }, mode: "sms" }).once
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: phone_id }, mode: "sms" })
expect(WebMock).to have_requested(:get, 'https://idmsa.apple.com/appleauth/auth/2sv/trust')
end
it 'providing an unknown phone number throws an exception' do
phone_number = '+49 123 4567800'
ENV['SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER'] = phone_number
expect do
bool = subject.handle_two_factor(response)
end.to raise_error(Spaceship::Tunes::Error)
end
context 'and pushMode is voice' do
let(:phone_number) { '+49 123 4567880' }
let(:phone_id) { 3 }
it 'requests voice code' do
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
# expected requests
expect(WebMock).to have_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone').with(body: { phoneNumber: { id: phone_id }, mode: "voice" }).once
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: phone_id }, mode: "voice" })
expect(WebMock).to have_requested(:get, 'https://idmsa.apple.com/appleauth/auth/2sv/trust')
end
end
context 'with trusted devices' do
# make sure sms overrides device verification when env var is set
it 'requests sms code, and submits code correctly' do
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode')
expect(WebMock).to have_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone').with(body: { phoneNumber: { id: phone_id }, mode: "sms" }).once
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: phone_id }, mode: "sms" })
end
end
context 'with no trusted devices' do
# sms fallback, will be sent automatically
context "with exactly one phone number" do
it "does not request sms code, and sends the correct request" do
response = OpenStruct.new
response.body = no_trusted_devices_response
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
expect(WebMock).to have_not_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone')
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode')
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: 1 }, mode: "sms" })
end
end
context 'with at least two phone numbers' do
# sets env var to the second phone number in this context
let(:phone_number) { '+49 123 4567881' }
let(:phone_id) { 2 }
let(:response) do
response = OpenStruct.new
response.body = no_trusted_devices_two_numbers_response
return response
end
# making sure we use env var for phone number selection
it 'does not prompt user to choose number' do
expect(subject).not_to receive(:choose_phone_number)
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
end
it 'requests sms code, and submits code correctly' do
bool = subject.handle_two_factor(response)
expect(bool).to eq(true)
expect(WebMock).to have_not_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/trusteddevice/securitycode')
expect(WebMock).to have_requested(:put, 'https://idmsa.apple.com/appleauth/auth/verify/phone').with(body: { phoneNumber: { id: phone_id }, mode: "sms" }).once
expect(WebMock).to have_requested(:post, 'https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode').with(body: { securityCode: { code: "123" }, phoneNumber: { id: phone_id }, mode: "sms" })
end
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/client_spec.rb | spaceship/spec/client_spec.rb | describe Spaceship::Client do
class TestClient < Spaceship::Client
def self.hostname
"http://example.com"
end
def req_home
request(:get, TestClient.hostname)
end
def send_login_request(_user, _password)
true
end
end
class TestResponse
attr_accessor :body
attr_accessor :status
def initialize(body = nil, status = 200)
@body = body
@status = status
end
end
let(:subject) { TestClient.new }
let(:unauth_error) { Spaceship::Client::UnauthorizedAccessError.new }
let(:test_uri) { "http://example.com" }
let(:default_body) { '{foo: "bar"}' }
def stub_client_request(error, times, status, body)
stub_request(:get, test_uri).
to_raise(error).times(times).then.
to_return(status: status, body: body)
end
def stub_client_retry_auth(status_error, times, status_ok, body)
stub_request(:get, test_uri).
to_return(status: status_error, body: body).times(times).
then.to_return(status: status_ok, body: body)
end
describe 'detect_most_common_errors_and_raise_exceptions' do
# this test is strange, the `error` has a typo "InsufficentPermissions" and is not really relevant
it "raises Spaceship::InsufficientPermissions for InsufficentPermissions" do
body = JSON.generate({ messages: { error: "InsufficentPermissions" } })
stub_client_request(Spaceship::InsufficientPermissions, 6, 200, body)
expect do
subject.req_home
end.to raise_error(Spaceship::InsufficientPermissions)
end
it "raises Spaceship::InsufficientPermissions for Forbidden" do
body = JSON.generate({ messages: { error: "Forbidden" } })
stub_client_request(Spaceship::InsufficientPermissions, 6, 200, body)
expect do
subject.req_home
end.to raise_error(Spaceship::InsufficientPermissions)
end
it "raises Spaceship::InsufficientPermissions for insufficient privileges" do
body = JSON.generate({ messages: { error: "insufficient privileges" } })
stub_client_request(Spaceship::InsufficientPermissions, 6, 200, body)
expect do
subject.req_home
end.to raise_error(Spaceship::InsufficientPermissions)
end
it "raises Spaceship::InternalServerError" do
stub_client_request(Spaceship::GatewayTimeoutError, 6, 504, "<html>Internal Server - Read</html>")
expect do
subject.req_home
end.to raise_error(Spaceship::GatewayTimeoutError)
end
it "raises Spaceship::GatewayTimeoutError for 504" do
stub_client_request(Spaceship::GatewayTimeoutError, 6, 504, "<html>Gateway Timeout - In Read</html>")
expect do
subject.req_home
end.to raise_error(Spaceship::GatewayTimeoutError)
end
it "raises Spaceship::BadGatewayError for 502" do
stub_client_request(Spaceship::BadGatewayError, 6, 502, "<html>Bad Gateway</html>")
expect do
subject.req_home
end.to raise_error(Spaceship::BadGatewayError)
end
it "raises Spaceship::AppleTimeoutError for 503" do
stub_client_request(Spaceship::AppleTimeoutError, 6, 503, "<html>Service Unavailable</html>")
expect do
subject.req_home
end.to raise_error(Spaceship::AppleTimeoutError)
end
it "raises Spaceship::AppleTimeoutError for 503 HTML content" do
body = "<html><head><title>503 Service Temporarily Unavailable</title></head><body><center><h1>503 Service Temporarily Unavailable</h1></center></body>"
stub_client_request(Spaceship::AppleTimeoutError, 6, 200, body)
expect do
subject.req_home
end.to raise_error(Spaceship::AppleTimeoutError)
end
it "raises Spaceship::ProgramLicenseAgreementUpdated" do
stub_client_request(Spaceship::ProgramLicenseAgreementUpdated, 6, 200, "Program License Agreement")
expect do
subject.req_home
end.to raise_error(Spaceship::ProgramLicenseAgreementUpdated)
end
it "raises Spaceship::AccessForbiddenError" do
stub_client_request(Spaceship::AccessForbiddenError, 6, 403, "<html>Access Denied - In Read</html>")
expect do
subject.req_home
end.to raise_error(Spaceship::AccessForbiddenError)
end
it "raises Spaceship::ProgramLicenseAgreementUpdated" do
stub_client_request(Spaceship::ProgramLicenseAgreementUpdated, 6, 200, "Program License Agreement")
expect do
subject.req_home
end.to raise_error(Spaceship::ProgramLicenseAgreementUpdated)
end
it "raises Spaceship::TooManyRequestsError" do
stub_client_request(Spaceship::TooManyRequestsError.new({}), 6, 429, "Program License Agreement")
expect do
subject.req_home
end.to raise_error(Spaceship::Client::TooManyRequestsError)
end
end
describe 'retry' do
[
Faraday::TimeoutError,
Faraday::ConnectionFailed,
Faraday::ParsingError,
Spaceship::BadGatewayError,
Spaceship::InternalServerError,
Spaceship::GatewayTimeoutError,
Spaceship::AccessForbiddenError
].each do |thrown|
it "re-raises when retry limit reached throwing #{thrown}" do
stub_client_request(thrown, 6, 200, nil)
expect do
subject.req_home
end.to raise_error(thrown)
end
it "retries when #{thrown} error raised" do
stub_client_request(thrown, 2, 200, default_body)
expect(subject.req_home.body).to eq(default_body)
end
end
it "raises AppleTimeoutError when response contains '302 Found'" do
ClientStubbing.stub_connection_timeout_302
expect do
subject.req_home
end.to raise_error(Spaceship::Client::AppleTimeoutError)
end
it "raises BadGatewayError when response contains 'Bad Gateway'" do
body = <<BODY
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-size: 15px;
font-weight: 200;
line-height: 20px;
color: #4c4c4c;
text-align: center;
}
.section {
margin-top: 50px;
}
</style>
</head>
<body>
<div class="section">
<h1></h1>
<h3>Bad Gateway</h3>
<p>Correlation Key: XXXXXXXXXXXXXXXXXXXX</p>
</div>
</body>
</html>
BODY
stub_client_retry_auth(502, 1, 200, body)
expect do
subject.req_home
end.to raise_error(Spaceship::Client::BadGatewayError)
end
end
describe 'retry' do
[
Faraday::TimeoutError,
Faraday::ConnectionFailed,
Faraday::ParsingError,
Spaceship::BadGatewayError,
Spaceship::InternalServerError,
Spaceship::GatewayTimeoutError,
Spaceship::AccessForbiddenError
].each do |thrown|
it "re-raises when retry limit reached throwing #{thrown}" do
stub_client_request(thrown, 6, 200, nil)
expect do
subject.req_home
end.to raise_error(thrown)
end
it "retries when #{thrown} error raised" do
stub_client_request(thrown, 2, 200, default_body)
expect(subject.req_home.body).to eq(default_body)
end
end
it "raises AppleTimeoutError when response contains '302 Found'" do
ClientStubbing.stub_connection_timeout_302
expect do
subject.req_home
end.to raise_error(Spaceship::Client::AppleTimeoutError)
end
it "raises BadGatewayError when response contains 'Bad Gateway'" do
body = <<BODY
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
font-size: 15px;
font-weight: 200;
line-height: 20px;
color: #4c4c4c;
text-align: center;
}
.section {
margin-top: 50px;
}
</style>
</head>
<body>
<div class="section">
<h1></h1>
<h3>Bad Gateway</h3>
<p>Correlation Key: XXXXXXXXXXXXXXXXXXXX</p>
</div>
</body>
</html>
BODY
stub_client_retry_auth(502, 1, 200, body)
expect do
subject.req_home
end.to raise_error(Spaceship::Client::BadGatewayError)
end
it "successfully retries request after logging in again when UnauthorizedAccess Error raised" do
subject.login
stub_client_retry_auth(401, 1, 200, default_body)
expect(subject.req_home.body).to eq(default_body)
end
it "fails to retry request if login fails in retry block when UnauthorizedAccess Error raised" do
subject.login
stub_client_retry_auth(401, 1, 200, default_body)
# the next login will fail
def subject.send_login_request(_user, _password)
raise Spaceship::Client::UnauthorizedAccessError.new, "Faked"
end
expect do
subject.req_home
end.to raise_error(Spaceship::Client::UnauthorizedAccessError)
end
describe "retry when user and password not fetched from CredentialManager" do
let(:the_user) { 'u' }
let(:the_password) { 'p' }
it "is able to retry and login successfully" do
def subject.send_login_request(user, password)
can_login = (user == 'u' && password == 'p')
raise Spaceship::Client::UnauthorizedAccessError.new, "Faked" unless can_login
true
end
subject.login(the_user, the_password)
stub_client_retry_auth(401, 1, 200, default_body)
expect(subject.req_home.body).to eq(default_body)
end
end
end
describe "#do_sirp" do
it "raises Spaceship::UnexpectedResponse when body is not valid JSON, but HTTP 200" do
stub_request(:post, "https://idmsa.apple.com/appleauth/auth/signin/init").
to_return(status: 200, body: "<html>Something went wrong</html>", headers: { 'Content-Type' => 'text/html' })
expect do
subject.do_sirp("user", "password", nil)
end.to raise_error(Spaceship::Client::UnexpectedResponse, /Expected JSON response, but got String/)
end
it "raises Spaceship::UnexpectedResponse when body contains serviceErrors" do
response_body = {
"iteration" => 0,
"serviceErrors" => [
{
"code" => "-900007",
"suppressDismissal" => false
}
]
}
stub_request(:post, "https://idmsa.apple.com/appleauth/auth/signin/init").
to_return(status: 200, body: response_body.to_json, headers: { 'Content-Type' => 'application/json' })
allow(subject).to receive(:itc_service_key).and_return("fake_service_key")
expect do
subject.do_sirp("user", "password", nil)
end.to raise_error(Spaceship::Client::UnexpectedResponse)
end
end
describe "#log_response" do
it 'handles ASCII-8BIT to UTF-8 encoding gracefully' do
response = TestResponse.new([130, 5, 3120, 130, 4, 171, 160, 3, 2].pack('C*'))
expect(subject.send(:log_response, :get, TestClient.hostname, response)).to be_truthy
end
end
describe "#persistent_cookie_path" do
before do
subject.login("username", "password")
end
after do
ENV.delete("SPACESHIP_COOKIE_PATH")
end
it "uses $SPACESHIP_COOKIE_PATH when set" do
tmp_path = Dir.mktmpdir
ENV["SPACESHIP_COOKIE_PATH"] = "#{tmp_path}/custom_path"
expect(subject.persistent_cookie_path).to eq("#{tmp_path}/custom_path/spaceship/username/cookie")
end
it "uses home dir by default" do
allow(subject).to receive(:directory_accessible?).with(File.expand_path("~/.fastlane")).and_return(true)
expect(subject.persistent_cookie_path).to eq(File.expand_path("~/.fastlane/spaceship/username/cookie"))
end
it "supports legacy .spaceship path" do
allow(subject).to receive(:directory_accessible?).with(File.expand_path("~/.fastlane")).and_return(false)
allow(subject).to receive(:directory_accessible?).with(File.expand_path("~")).and_return(true)
expect(subject.persistent_cookie_path).to eq(File.expand_path("~/.spaceship/username/cookie"))
end
it "uses /var/tmp if home not available" do
allow(subject).to receive(:directory_accessible?).with(File.expand_path("~/.fastlane")).and_return(false)
allow(subject).to receive(:directory_accessible?).with(File.expand_path("~")).and_return(false)
allow(subject).to receive(:directory_accessible?).with(File.expand_path("/var/tmp")).and_return(true)
expect(subject.persistent_cookie_path).to eq(File.expand_path("/var/tmp/spaceship/username/cookie"))
end
it "falls back to Dir.tmpdir as last resort" do
allow(subject).to receive(:directory_accessible?).with(File.expand_path("~")).and_return(false)
allow(subject).to receive(:directory_accessible?).with(File.expand_path("~/.fastlane")).and_return(false)
allow(subject).to receive(:directory_accessible?).with(File.expand_path("/var/tmp")).and_return(false)
allow(subject).to receive(:directory_accessible?).with(Dir.tmpdir).and_return(true)
expect(subject.persistent_cookie_path).to eq("#{Dir.tmpdir}/spaceship/username/cookie")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/stats_middleware_spec.rb | spaceship/spec/stats_middleware_spec.rb | describe Spaceship::StatsMiddleware do
context '#log' do
let(:app) { double('app') }
let(:middleware) { Spaceship::StatsMiddleware.new(app) }
before(:each) do
allow(Spaceship::Globals).to receive(:verbose?).and_return(true)
end
it 'with nil env' do
success = middleware.log(nil)
expect(success).to be(false)
end
it 'with empty env' do
mock_env = double('env')
expect(mock_env).to receive(:url).and_return(nil)
success = middleware.log(mock_env)
expect(success).to be(false)
end
it 'with bad env url' do
mock_env = double('env')
expect(mock_env).to receive(:url).and_return("pizza is good").twice
expect do
success = middleware.log(mock_env)
expect(success).to be(false)
end.to output(/Failed to log spaceship stats/).to_stdout
end
it 'with api.appstoreconnect.apple.com' do
mock_stats = Hash.new(0)
allow(Spaceship::StatsMiddleware).to receive(:service_stats) do
mock_stats
end
# Note: This does not test if all these services were actually added.
urls = [
# Supported
"https://api.appstoreconnect.apple.com/stuff",
"https://api.appstoreconnect.apple.com/stuff2",
"https://appstoreconnect.apple.com/iris/v1/stuff",
"https://api.enterprise.developer.apple.com/stuff",
"https://developer.apple.com/services-account/v1/stuff",
"https://idmsa.apple.com/stuff",
"https://appstoreconnect.apple.com/olympus/v1/stuff",
"https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/stuff",
"https://developer.apple.com/services-account/QH65B2/stuff",
# Custom
"https://somethingelse.com/stuff",
"https://somethingelse.com/stuff2"
]
urls.each do |url|
mock_env = double('env')
allow(mock_env).to receive(:url).and_return(url)
success = middleware.log(mock_env)
expect(success).to be(true)
end
expect(Spaceship::StatsMiddleware.service_stats.size).to eq(9)
expect(find_count("api.appstoreconnect.apple.com")).to eq(2)
expect(find_count("appstoreconnect.apple.com/iris/")).to eq(1)
expect(find_count("api.enterprise.developer.apple.com")).to eq(1)
expect(find_count("developer.apple.com/services-account/")).to eq(1)
expect(find_count("idmsa.apple.com")).to eq(1)
expect(find_count("appstoreconnect.apple.com/olympus/v1/")).to eq(1)
expect(find_count("appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/")).to eq(1)
expect(find_count("developer.apple.com/services-account/QH65B2/")).to eq(1)
expect(find_count("somethingelse.com")).to eq(2)
end
def find_count(url)
Spaceship::StatsMiddleware.service_stats.find { |k, v| k.url == url }.last
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/client_stubbing.rb | spaceship/spec/client_stubbing.rb | class ClientStubbing
class << self
def client_read_fixture_file(filename)
File.read(File.join('spaceship', 'spec', 'fixtures', filename))
end
# Necessary, as we're now running this in a different context
def stub_request(*args)
WebMock::API.stub_request(*args)
end
def stub_connection_timeout_302
stub_request(:get, "http://example.com/").
to_return(status: 200, body: client_read_fixture_file('302.html'), headers: {})
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/launcher_spec.rb | spaceship/spec/launcher_spec.rb | describe Spaceship do
describe Spaceship::Launcher do
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
let(:spaceship1) { Spaceship::Launcher.new }
let(:spaceship2) { Spaceship::Launcher.new }
before do
spaceship1.login(username, password)
spaceship2.login(username, password)
end
it 'should have 2 separate spaceships' do
expect(spaceship1).to_not(eq(spaceship2))
end
it '#select_team' do
expect(spaceship1.select_team).to eq("XXXXXXXXXX")
end
it "may have different teams" do
allow_any_instance_of(Spaceship::PortalClient).to receive(:teams).and_return([
{ 'teamId' => 'XXXXXXXXXX', 'currentTeamMember' => { 'teamMemberId' => '' } },
{ 'teamId' => 'ABCDEF', 'currentTeamMember' => { 'teamMemberId' => '' } }
])
team_id = "ABCDEF"
spaceship1.client.select_team(team_id: team_id)
expect(spaceship1.client.team_id).to eq(team_id) # custom
expect(spaceship2.client.team_id).to eq("XXXXXXXXXX") # default
end
it "Device" do
expect(spaceship1.device.all.count).to eq(4)
end
it "DeviceDisabled" do
expect(spaceship1.device.all(include_disabled: true).count).to eq(6)
end
it "Certificate" do
expect(spaceship1.certificate.all.count).to eq(3)
end
it "ProvisioningProfile" do
expect(spaceship1.provisioning_profile.all.count).to eq(7)
end
it "App" do
expect(spaceship1.app.all.count).to eq(5)
end
context "With an uninitialized environment" do
before do
Spaceship::App.set_client(nil)
Spaceship::AppGroup.set_client(nil)
Spaceship::Device.set_client(nil)
Spaceship::Certificate.set_client(nil)
Spaceship::ProvisioningProfile.set_client(nil)
end
it "shouldn't fail if provisioning_profile is invoked before app and device" do
clean_launcher = Spaceship::Launcher.new
clean_launcher.login(username, password)
expect(clean_launcher.provisioning_profile.all.count).to eq(7)
end
it "shouldn't fail if trying to create new apns_certificate before app is invoked" do
clean_launcher = Spaceship::Launcher.new
clean_launcher.login(username, password)
expect(clean_launcher.client).to receive(:create_certificate!).with('JKG5JZ54H7', /BEGIN CERTIFICATE REQUEST/, 'B7JBD8LHAA', false) do
JSON.parse(PortalStubbing.adp_read_fixture_file('certificateCreate.certRequest.json'))
end
csr, pkey = Spaceship::Portal::Certificate.create_certificate_signing_request
expect do
clean_launcher.certificate.development_push.create!(csr: csr, bundle_id: 'net.sunapps.151')
end.to_not(raise_error)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/spaceship_base_spec.rb | spaceship/spec/spaceship_base_spec.rb | describe Spaceship::Base do
let(:client) { double('Client') }
before { Spaceship::Portal.client = double('Default Client') }
describe 'Class Methods' do
it 'will use a default client' do
expect(Spaceship::PortalBase.client).to eq(Spaceship::Portal.client)
end
it 'can set a client' do
Spaceship::PortalBase.client = client
expect(Spaceship::PortalBase.client).to eq(client)
end
it 'can set a client and return itself' do
expect(Spaceship::PortalBase.set_client(client)).to eq(Spaceship::PortalBase)
end
describe 'instantiation from an attribute hash' do
let(:test_class) do
Class.new(Spaceship::PortalBase) do
attr_accessor :some_attr_name
attr_accessor :nested_attr_name
attr_accessor :is_live
attr_mapping({
'someAttributeName' => :some_attr_name,
'nestedAttribute.name.value' => :nested_attr_name,
'isLiveString' => :is_live
})
def is_live
super == 'true'
end
end
end
it 'can create an attribute mapping' do
inst = test_class.new('someAttributeName' => 'some value')
expect(inst.some_attr_name).to eq('some value')
end
it 'can inherit the attribute mapping' do
subclass = Class.new(test_class)
inst = subclass.new('someAttributeName' => 'some value')
expect(inst.some_attr_name).to eq('some value')
end
it 'can map nested attributes' do
inst = test_class.new({ 'nestedAttribute' => { 'name' => { 'value' => 'a value' } } })
expect(inst.nested_attr_name).to eq('a value')
end
it 'can overwrite an attribute and call super' do
inst = test_class.new({ 'isLiveString' => 'true' })
expect(inst.is_live).to eq(true)
end
it 'helps troubleshoot json conversion issues' do
inst = test_class.new({ 'someAttributeName' => "iPhone\xAE" })
expect do
FastlaneSpec::Env.with_verbose(true) do
inst.raw_data.to_json
end
end.to raise_error(JSON::GeneratorError)
end
end
it 'can constantize subclasses by calling a method on the parent class' do
class Developer < Spaceship::PortalBase
class RubyDeveloper < Developer
end
end
expect(Developer.ruby_developer).to eq(Developer::RubyDeveloper)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/provisioning_profile_spec.rb | spaceship/spec/provisioning_profile_spec.rb | describe Spaceship::ProvisioningProfile do
before { Spaceship.login }
let(:client) { Spaceship::ProvisioningProfile.client }
let(:cert_id) { "C8DL7464RQ" }
describe '#all' do
let(:provisioning_profiles) { Spaceship::ProvisioningProfile.all }
it "properly retrieves and filters the provisioning profiles" do
expect(provisioning_profiles.count).to eq(7)
profile = provisioning_profiles[5]
expect(profile.name).to eq('delete.me.please AppStore')
expect(profile.type).to eq('iOS Distribution')
expect(profile.app.app_id).to eq('2UMR2S6P4L')
expect(profile.status).to eq('Active')
expect(profile.expires.class).to eq(Time)
expect(profile.expires.to_s).to eq('2016-02-10 00:00:00 UTC')
expect(profile.uuid).to eq('58ce5b78-15f8-4ceb-83f1-a29f6c4d066f')
expect(profile.managed_by_xcode?).to eq(false)
expect(profile.distribution_method).to eq('store')
expect(profile.class.type).to eq('store')
expect(profile.class.pretty_type).to eq('AppStore')
expect(profile.type).to eq('iOS Distribution')
end
it 'should filter by the correct types' do
expect(Spaceship::ProvisioningProfile::Development.all.count).to eq(1)
expect(Spaceship::ProvisioningProfile::AdHoc.all.count).to eq(1)
expect(Spaceship::ProvisioningProfile::AppStore.all.count).to eq(5)
end
it "AppStore and AdHoc are not the same" do
Spaceship::ProvisioningProfile::AdHoc.all.each do |adhoc|
expect(Spaceship::ProvisioningProfile::AppStore.all.find_all { |a| a.id == adhoc.id }.count).to eq(0)
end
end
it 'should have an app' do
profile = provisioning_profiles.first
expect(profile.app).to be_instance_of(Spaceship::App)
end
describe "include managed by Xcode" do
it 'filters Xcode managed profiles' do
provisioning_profiles = Spaceship::ProvisioningProfile.all(xcode: false)
expect(provisioning_profiles.count).to eq(7) # ignore the Xcode generated profiles
end
it 'includes Xcode managed profiles' do
provisioning_profiles = Spaceship::ProvisioningProfile.all(xcode: true)
expect(provisioning_profiles.count).to eq(7) # include the Xcode generated profiles
end
end
end
describe '#all via xcode api' do
it 'should use the Xcode api to get provisioning profiles and their appIds' do
stub_const('ENV', { "SPACESHIP_AVOID_XCODE_API" => nil })
expect(client).to receive(:provisioning_profiles_via_xcode_api).and_call_original
expect(client).not_to(receive(:provisioning_profiles))
expect(client).not_to(receive(:provisioning_profile_details))
Spaceship::ProvisioningProfile.find_by_bundle_id(bundle_id: 'some-fake-id')
end
it 'should use the developer portal api to get provisioning profiles and their appIds' do
stub_const('ENV', { "SPACESHIP_AVOID_XCODE_API" => 'true' })
expect(client).not_to(receive(:provisioning_profiles_via_xcode_api))
expect(client).to receive(:provisioning_profiles).and_call_original
expect(client).to receive(:provisioning_profile_details).and_call_original.exactly(7).times
Spaceship::ProvisioningProfile.find_by_bundle_id(bundle_id: 'some-fake-id')
end
end
describe '#find_by_bundle_id' do
it "returns [] if there are no profiles" do
profiles = Spaceship::ProvisioningProfile.find_by_bundle_id(bundle_id: "notExistent")
expect(profiles).to eq([])
end
it "returns the profile in an array if matching for ios" do
profiles = Spaceship::ProvisioningProfile.find_by_bundle_id(bundle_id: "net.sunapps.1")
expect(profiles.count).to eq(6)
expect(profiles.first.app.bundle_id).to eq('net.sunapps.1')
expect(profiles.first.distribution_method).to eq('adhoc')
end
it "returns the profile in an array if matching for tvos" do
profiles = Spaceship::ProvisioningProfile.find_by_bundle_id(bundle_id: "net.sunapps.1", sub_platform: 'tvOS')
expect(profiles.count).to eq(1)
expect(profiles.first.app.bundle_id).to eq('net.sunapps.1')
expect(profiles.first.distribution_method).to eq('store')
end
end
describe '#class.type' do
it "Returns only valid profile types" do
valid = %w(limited adhoc store direct)
Spaceship::ProvisioningProfile.all.each do |profile|
expect(valid).to include(profile.class.type)
end
end
end
it "distribution_method says `adhoc` for AdHoc profile" do
adhoc = Spaceship::ProvisioningProfile::AdHoc.all.first
expect(adhoc.distribution_method).to eq('adhoc')
expect(adhoc.devices.count).to eq(2)
device = adhoc.devices.first
expect(device.id).to eq('FVRY7XH22J')
expect(device.name).to eq('Felix Krause\'s iPhone 6s')
expect(device.udid).to eq('aaabbbccccddddaaabbb')
expect(device.platform).to eq('ios')
expect(device.status).to eq('c')
end
describe '#download' do
it "downloads an existing provisioning profile" do
file = Spaceship::ProvisioningProfile.all.first.download
xml = Plist.parse_xml(file)
expect(xml['AppIDName']).to eq("SunApp Setup")
expect(xml['TeamName']).to eq("SunApps GmbH")
end
it "handles failed download request" do
PortalStubbing.adp_stub_download_provisioning_profile_failure
profile = Spaceship::ProvisioningProfile.all.first
error_text = /^Couldn't download provisioning profile, got this instead:/
expect do
profile.download
end.to raise_error(Spaceship::Client::UnexpectedResponse, error_text)
end
end
describe '#valid?' do
it "Valid profile" do
p = Spaceship::ProvisioningProfile.all.first
p.expires = Time.now.utc + 60
expect(p.valid?).to eq(true)
end
it "Invalid profile with expired status" do
profile = Spaceship::ProvisioningProfile.all.first
profile.status = 'Expired'
expect(profile.valid?).to eq(false)
end
it "Invalid profile with active status but expired date" do
profile = Spaceship::ProvisioningProfile.all.first
profile.status = 'Active'
profile.expires = Time.now.utc
expect(profile.valid?).to eq(false)
end
end
describe '#factory' do
let(:fake_app_info) { {} }
describe 'accepted distribution methods' do
let(:accepted_distribution_methods) do
{
'limited' => 'Development',
'store' => 'AppStore',
'adhoc' => 'AdHoc',
'inhouse' => 'InHouse',
'direct' => 'Direct'
}
end
let(:expected_profile) { "expected_profile" }
it 'creates proper profile types' do
accepted_distribution_methods.each do |k, v|
expect(Kernel.const_get("Spaceship::ProvisioningProfile::#{v}")).to receive(:new).and_return(expected_profile)
profile = Spaceship::ProvisioningProfile.factory({ 'appId' => fake_app_info, 'proProPlatform' => 'mac', 'distributionMethod' => k })
expect(profile).to eq(expected_profile)
end
end
end
describe 'unrecognized distribution method' do
subject do
Spaceship::ProvisioningProfile.factory({ 'appId' => fake_app_info, 'proProPlatform' => 'mac', 'distributionMethod' => 'hamsandwich' })
end
it 'raises error' do
expect { subject }.to raise_error("Can't find class 'hamsandwich'")
end
end
end
describe '#create!' do
let(:certificate) { Spaceship::Certificate.all.first }
it 'creates a new development provisioning profile' do
expect(Spaceship::Device).to receive(:all).and_return([])
expect(client).to receive(:create_provisioning_profile!).with('Delete Me', 'limited', '2UMR2S6PAA', "XC5PH8DAAA", [], mac: false, sub_platform: nil, template_name: nil).and_return({})
Spaceship::ProvisioningProfile::Development.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: certificate)
end
it 'creates a new appstore provisioning profile' do
expect(client).to receive(:create_provisioning_profile!).with('Delete Me', 'store', '2UMR2S6PAA', "XC5PH8DAAA", [], mac: false, sub_platform: nil, template_name: nil).and_return({})
Spaceship::ProvisioningProfile::AppStore.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: certificate)
end
it 'creates a provisioning profile with only the required parameters and auto fills all available devices' do
expect(client).to receive(:create_provisioning_profile!).with('net.sunapps.1 AppStore',
'store',
'2UMR2S6PAA',
"XC5PH8DAAA",
[],
mac: false,
sub_platform: nil,
template_name: nil).
and_return({})
Spaceship::ProvisioningProfile::AppStore.create!(bundle_id: 'net.sunapps.1', certificate: certificate)
end
it 'creates a new appstore provisioning profile with template' do
template_name = 'Test Template'
expect(client).to receive(:create_provisioning_profile!).with('Delete Me', 'store', '2UMR2S6PAA', "XC5PH8DAAA", [], mac: false, sub_platform: nil, template_name: template_name).and_return({})
Spaceship::ProvisioningProfile::AppStore.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: certificate, template_name: template_name)
end
it 'raises an error if the user wants to create a profile for a non-existing app' do
expect do
Spaceship::ProvisioningProfile::AppStore.create!(bundle_id: 'notExisting', certificate: certificate)
end.to raise_error("Could not find app with bundle id 'notExisting'")
end
describe 'modify devices to prevent having devices on profile types where it does not make sense' do
it 'Direct (Mac) profile types have no devices' do
fake_devices = Spaceship::Device.all
expected_devices = []
expect(Spaceship::ProvisioningProfile::Direct.client).to receive(:create_provisioning_profile!).with('Delete Me', 'direct', '2UMR2S6PAA', "XC5PH8DAAA", expected_devices, mac: true, sub_platform: nil, template_name: nil).and_return({})
Spaceship::ProvisioningProfile::Direct.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: certificate, mac: true, devices: fake_devices)
end
it 'Development profile types have devices' do
fake_devices = Spaceship::Device.all
expected_devices = fake_devices.collect(&:id)
expect(Spaceship::ProvisioningProfile::Development.client).to receive(:create_provisioning_profile!).with('Delete Me', 'limited', '2UMR2S6PAA', "XC5PH8DAAA", expected_devices, mac: false, sub_platform: nil, template_name: nil).and_return({})
Spaceship::ProvisioningProfile::Development.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: certificate, devices: fake_devices)
end
it 'AdHoc profile types have no devices' do
fake_devices = Spaceship::Device.all
expected_devices = fake_devices.collect(&:id)
expect(Spaceship::ProvisioningProfile::AdHoc.client).to receive(:create_provisioning_profile!).with('Delete Me', 'adhoc', '2UMR2S6PAA', "XC5PH8DAAA", expected_devices, mac: false, sub_platform: nil, template_name: nil).and_return({})
Spaceship::ProvisioningProfile::AdHoc.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: certificate, devices: fake_devices)
end
it 'AppStore profile types have no devices' do
fake_devices = Spaceship::Device.all
expected_devices = []
expect(Spaceship::ProvisioningProfile::AppStore.client).to receive(:create_provisioning_profile!).with('Delete Me', 'store', '2UMR2S6PAA', "XC5PH8DAAA", expected_devices, mac: false, sub_platform: nil, template_name: nil).and_return({})
Spaceship::ProvisioningProfile::AppStore.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: certificate, devices: fake_devices)
end
end
end
describe "#delete" do
let(:profile) { Spaceship::ProvisioningProfile.all.first }
it "deletes an existing profile" do
expect(client).to receive(:delete_provisioning_profile!).with(profile.id, mac: false).and_return({})
profile.delete!
end
end
describe "#repair" do
let(:profile) { Spaceship::ProvisioningProfile.all.detect { |pp| pp.id == 'PP00000006' } }
it "repairs an existing profile with added devices" do
profile.devices = Spaceship::Device.all_for_profile_type(profile.type)
expect(client).to receive(:repair_provisioning_profile!).with('PP00000006', 'delete.me.please AppStore', 'store', '2UMR2S6P4L', [cert_id], ["AAAAAAAAAA", "BBBBBBBBBB", "CCCCCCCCCC", "DDDDDDDDDD"], mac: false, sub_platform: nil, template_name: nil).and_return({})
profile.repair!
end
it "update the certificate if the current one doesn't exist" do
profile.certificates = []
expect(client).to receive(:repair_provisioning_profile!).with('PP00000006', 'delete.me.please AppStore', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: nil, template_name: nil).and_return({})
# expect(client).to receive(:repair_provisioning_profile!).with('PP00000002', '1 Gut Altentann Ad Hoc', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: nil).and_return({})
profile.repair!
end
it "update the certificate if the current one is invalid" do
expect(profile.certificates.first.id).to eq("3BH4JJSWM4")
expect(client).to receive(:repair_provisioning_profile!).with('PP00000006', 'delete.me.please AppStore', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: nil, template_name: nil).and_return({})
profile.repair! # repair will replace the old certificate with the new one
end
it "repairs an existing profile with no devices" do
expect(client).to receive(:repair_provisioning_profile!).with('PP00000006', 'delete.me.please AppStore', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: nil, template_name: nil).and_return({})
profile.repair!
end
describe "Different Environments" do
it "Development" do
profile = Spaceship::ProvisioningProfile::Development.all.first
devices = ["FVRY7XH22J", "4ZE252U553"]
expect(client).to receive(:repair_provisioning_profile!).with('PP00000005', '112 Wombats RC Development', 'limited', '2UMR2S6P4L', [cert_id], devices, mac: false, sub_platform: nil, template_name: nil).and_return({})
profile.repair!
end
end
context "if the profile was created with a template" do
let(:profile) { Spaceship::ProvisioningProfile.all.detect { |pp| pp.id == 'PP00000007' } }
it "repairs an existing profile with template" do
expect(client).to receive(:repair_provisioning_profile!).with('PP00000007', 'Profile with Template App Store', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: nil, template_name: "Subscription Service (dist)").and_return({})
profile.repair!
end
end
end
describe "#update!" do
let(:profile) { Spaceship::ProvisioningProfile.all.detect { |pp| pp.id == 'PP00000006' } }
let(:tvOSProfile) { Spaceship::ProvisioningProfile.all_tvos.first }
it "updates an existing iOS profile" do
expect(client).to receive(:repair_provisioning_profile!).with('PP00000006', 'delete.me.please AppStore', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: nil, template_name: nil).and_return({})
profile.update!
end
it "updates an existing tvOS profile" do
expect(client).to receive(:repair_provisioning_profile!).with('PP00000004', '107 GC Lorenzen AppStore tvOS', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: 'tvOS', template_name: nil).and_return({})
tvOSProfile.update!
end
context "if the profile was created with a template" do
let(:profile) { Spaceship::ProvisioningProfile.all.detect { |pp| pp.id == 'PP00000007' } }
it "updates an existing profile with template" do
expect(client).to receive(:repair_provisioning_profile!).with('PP00000007', 'Profile with Template App Store', 'store', '2UMR2S6P4L', [cert_id], [], mac: false, sub_platform: nil, template_name: "Subscription Service (dist)").and_return({})
profile.update!
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/spaceship_spec.rb | spaceship/spec/spaceship_spec.rb | describe Spaceship do
before { Spaceship.login }
it "#select_team" do
expect(Spaceship.select_team).to eq('XXXXXXXXXX')
end
it 'should initialize with a client' do
expect(Spaceship.client).to be_instance_of(Spaceship::PortalClient)
end
it "Device" do
expect(Spaceship.device.all.count).to eq(4)
end
it "Certificate" do
expect(Spaceship.certificate.all.count).to eq(3)
end
it "ProvisioningProfile" do
expect(Spaceship.provisioning_profile.all.count).to eq(7)
end
it "App" do
expect(Spaceship.app.all.count).to eq(5)
end
it "App Group" do
expect(Spaceship.app_group.all.count).to eq(2)
end
describe Spaceship::Launcher do
it 'has a client' do
expect(subject.client).to be_instance_of(Spaceship::PortalClient)
end
it 'returns a scoped model class' do
expect(subject.app).to eq(Spaceship::App)
expect(subject.app_group).to eq(Spaceship::AppGroup)
expect(subject.certificate).to eq(Spaceship::Certificate)
expect(subject.device).to eq(Spaceship::Device)
expect(subject.provisioning_profile).to eq(Spaceship::ProvisioningProfile)
end
it 'passes the client to the models' do
expect(subject.device.client).to eq(subject.client)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/spaceauth_spec.rb | spaceship/spec/spaceauth_spec.rb | require_relative 'tunes/tunes_stubbing'
require 'fastlane_core/clipboard'
describe Spaceship::SpaceauthRunner do
let(:user_cookie) { TunesStubbing.itc_read_fixture_file('spaceauth_cookie.yml') }
it 'uses all required cookies for fastlane session' do
if FastlaneCore::Helper.mac?
expect(Spaceship::Client::UserInterface).to receive(:interactive?).and_return(false)
end
expect_any_instance_of(Spaceship::Client).to receive(:store_cookie).exactly(2).times.and_return(user_cookie)
expect do
Spaceship::SpaceauthRunner.new.run
end.to output(/export FASTLANE_SESSION=.*name: DES.*name: myacinfo.*name: dqsid.*/).to_stdout
end
describe 'copy_to_clipboard option', if: FastlaneCore::Clipboard.is_supported? do
before :each do
# Save clipboard
@clipboard = FastlaneCore::Clipboard.paste
end
after :each do
# Restore clipboard
FastlaneCore::Clipboard.copy(content: @clipboard)
end
it 'when true, it should copy the session to clipboard' do
Spaceship::SpaceauthRunner.new(copy_to_clipboard: true).run
expect(FastlaneCore::Clipboard.paste).to match(%r{.*domain: idmsa.apple.com.*path: \"\/appleauth\/auth\/signin\/\".*})
end
it 'when false, it should not copy the session to clipboard' do
Spaceship::SpaceauthRunner.new(copy_to_clipboard: false).run
expect(FastlaneCore::Clipboard.paste).to eq(@clipboard)
end
end
describe 'check_session option' do
before :each do
Spaceship::Globals.check_session = true
end
after :each do
Spaceship::Globals.check_session = false
end
it 'when using the default user, it should return a message saying the session is logged in with an exit code of 0' do
expect do
expect do
Spaceship::SpaceauthRunner.new.run
end.to raise_error(SystemExit) do |error|
expect(error.status).to eq(0)
end
end.to output(/Valid session found \(.*\). Exiting./).to_stdout
end
it 'when passed a known user, it should return a message saying the session is logged in with an exit code of 0' do
expect do
expect do
Spaceship::SpaceauthRunner.new(username: 'spaceship@krausefx.com').run
end.to raise_error(SystemExit) do |error|
expect(error.status).to eq(0)
end
end.to output(/Valid session found \(.*\). Exiting./).to_stdout
end
it 'when passed an unknown user, it should return a message saying no valid session found with an exit code of 1' do
expect do
expect do
Spaceship::SpaceauthRunner.new(username: 'unknown-user').run
end.to raise_error(SystemExit) do |error|
expect(error.status).to eq(1)
end
end.to output(/No valid session found \(.*\). Exiting./).to_stdout
end
end
describe '#session_string' do
it 'should return the session when called after run' do
expect(Spaceship::SpaceauthRunner.new.run.session_string).to match(%r{.*domain: idmsa.apple.com.*path: \"\/appleauth\/auth\/signin\/\".*})
end
it 'should throw when called before run' do
expect(FastlaneCore::UI).to receive(:user_error!).with(/method called before calling `run` in `SpaceauthRunner`/).and_raise("boom")
expect do
Spaceship::SpaceauthRunner.new.session_string
end.to raise_error("boom")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/base_spec.rb | spaceship/spec/base_spec.rb | describe Spaceship::Base do
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::App.client }
class TestBase < Spaceship::Base
attr_accessor :child
def initialize # required
end
end
describe "#inspect" do
it "contains the relevant data" do
app = Spaceship::App.all.first
output = app.inspect
expect(output).to include("B7JBD8LHAA")
expect(output).to include("The App Name")
end
it "prints out references" do
Spaceship::Tunes.login
app = Spaceship::Application.all.find { |a| a.apple_id == "898536088" }
v = app.live_version
output = v.inspect
expect(output).to include("Tunes::AppVersion")
expect(output).to include("Tunes::Application")
end
it 'handles circular references' do
test_base = TestBase.new
test_base.child = test_base # self-references
expect do
test_base.inspect
end.to_not(raise_error)
end
it 'displays a placeholder value in inspect/to_s' do
test_base = TestBase.new
test_base.child = test_base # self-references
expect(test_base.to_s).to eq("<TestBase \n\tchild=<TestBase \n\t#<Object ...>>>")
end
it "doesn't leak state when throwing exceptions while inspecting objects" do
# an object with a broken inspect
test_base2 = TestBase.new
error = "faked inspect error"
allow(test_base2).to receive(:inspect).and_raise(error)
# will break the parent
test_base = TestBase.new
test_base.child = test_base2
expect do
test_base.inspect
end.to raise_error(error)
expect(Thread.current[:inspected_objects]).to be_nil
end
end
it "doesn't blow up if it was initialized with a nil data hash" do
hash = Spaceship::Base::DataHash.new(nil)
expect { hash["key"] }.not_to(raise_exception)
end
it "allows modification of values and properly retrieving them" do
app = Spaceship::App.all.first
app.name = "12"
expect(app.name).to eq("12")
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/hashcash_spec.rb | spaceship/spec/hashcash_spec.rb | describe Spaceship::Hashcash do
it "makes hashcash with 11 bits" do
allow_any_instance_of(Time).to receive(:strftime).and_return("20230223170600")
sha = Spaceship::Hashcash.make(bits: "11", challenge: "4d74fb15eb23f465f1f6fcbf534e5877")
expect(sha).to eq("1:11:20230223170600:4d74fb15eb23f465f1f6fcbf534e5877::6373")
end
it "finds hashcash with 12 bits" do
allow_any_instance_of(Time).to receive(:strftime).and_return("20230223213732")
sha = Spaceship::Hashcash.make(bits: "12", challenge: "f8b58554b2f22960fc0dc99aea342276")
expect(sha).to eq("1:12:20230223213732:f8b58554b2f22960fc0dc99aea342276::2381")
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/spec_helper.rb | spaceship/spec/spec_helper.rb | require 'plist'
require_relative 'client_stubbing'
require_relative 'connect_api/provisioning/provisioning_stubbing'
require_relative 'connect_api/testflight/testflight_stubbing'
require_relative 'connect_api/tunes/tunes_stubbing'
require_relative 'connect_api/users/users_stubbing'
require_relative 'portal/portal_stubbing'
require_relative 'tunes/tunes_stubbing'
require_relative 'du/du_stubbing'
# Ensure that no ENV vars which interfere with testing are set
#
set_auth_vars = [
'FASTLANE_SESSION',
'FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD',
'FASTLANE_PASSWORD'
].select { |var| ENV.key?(var) }
if set_auth_vars.any?
abort("[!] Please `unset` the following ENV vars which interfere with spaceship testing: #{set_auth_vars.join(', ')}".red)
end
@cache_paths = [
File.expand_path("/tmp/spaceship_itc_service_key.txt")
]
def try_delete(path)
FileUtils.rm_f(path) if File.exist?(path)
end
def before_each_spaceship
@cache_paths.each { |path| try_delete(path) }
ENV["DELIVER_USER"] = "spaceship@krausefx.com"
ENV["DELIVER_PASSWORD"] = "so_secret"
ENV['SPACESHIP_AVOID_XCODE_API'] = 'true'
ENV.delete("FASTLANE_USER")
TunesStubbing.itc_stub_login
PortalStubbing.adp_stub_login
PortalStubbing.adp_stub_app_groups
PortalStubbing.adp_stub_apps
PortalStubbing.adp_stub_provisioning
PortalStubbing.adp_stub_certificates
PortalStubbing.adp_stub_devices
PortalStubbing.adp_stub_persons
PortalStubbing.adp_stub_website_pushes
PortalStubbing.adp_stub_passbooks
TunesStubbing.itc_stub_applications
TunesStubbing.itc_stub_app_versions
TunesStubbing.itc_stub_build_trains
TunesStubbing.itc_stub_testers
TunesStubbing.itc_stub_testflight
TunesStubbing.itc_stub_app_version_ref
TunesStubbing.itc_stub_user_detail
TunesStubbing.itc_stub_sandbox_testers
TunesStubbing.itc_stub_create_sandbox_tester
TunesStubbing.itc_stub_delete_sandbox_tester
TunesStubbing.itc_stub_candidate_builds
TunesStubbing.itc_stub_pricing_tiers
TunesStubbing.itc_stub_release_to_store
TunesStubbing.itc_stub_release_to_all_users
TunesStubbing.itc_stub_promocodes
TunesStubbing.itc_stub_generate_promocodes
TunesStubbing.itc_stub_promocodes_history
TunesStubbing.itc_stub_supported_countries
ConnectAPIStubbing::Provisioning.stub_available_bundle_id_capabilities
ConnectAPIStubbing::Provisioning.stub_bundle_ids
ConnectAPIStubbing::Provisioning.stub_bundle_id
ConnectAPIStubbing::Provisioning.stub_patch_bundle_id_capability
ConnectAPIStubbing::Provisioning.stub_certificates
ConnectAPIStubbing::Provisioning.stub_devices
ConnectAPIStubbing::Provisioning.stub_profiles
ConnectAPIStubbing::TestFlight.stub_apps
ConnectAPIStubbing::TestFlight.stub_beta_app_localizations
ConnectAPIStubbing::TestFlight.stub_beta_app_review_details
ConnectAPIStubbing::TestFlight.stub_beta_app_review_submissions
ConnectAPIStubbing::TestFlight.stub_beta_build_localizations
ConnectAPIStubbing::TestFlight.stub_beta_build_metrics
ConnectAPIStubbing::TestFlight.stub_beta_feedbacks
ConnectAPIStubbing::TestFlight.stub_beta_feedbacks_delete
ConnectAPIStubbing::TestFlight.stub_beta_groups
ConnectAPIStubbing::TestFlight.stub_beta_testers
ConnectAPIStubbing::TestFlight.stub_beta_tester_metrics
ConnectAPIStubbing::TestFlight.stub_build_beta_details
ConnectAPIStubbing::TestFlight.stub_build_bundles
ConnectAPIStubbing::TestFlight.stub_build_deliveries
ConnectAPIStubbing::TestFlight.stub_builds
ConnectAPIStubbing::TestFlight.stub_pre_release_versions
ConnectAPIStubbing::Tunes.stub_app_store_version_release_request
ConnectAPIStubbing::Users.stub_users
end
def after_each_spaceship
@cache_paths.each { |path| try_delete(path) }
end
RSpec.configure do |config|
def mock_client_response(method_name, with: anything)
mock_method = allow(mock_client).to receive(method_name)
mock_method = mock_method.with(with)
if block_given?
mock_method.and_return(JSON.parse(yield.to_json))
else
mock_method
end
end
end
RSpec.shared_examples("common spaceship login") do |skip_tunes_login|
require 'fastlane-sirp'
let(:authentication_data) {
'8f30ce83b660f03abb0f8570c235e0e1e1d3860a222304acf18e989bdc065dc922a141e6da4563f0' \
'5586605b0e10535d875ca7e0fae7fe100cfe533374f29aaa803cdfb2c6194f458485e87f76988f6' \
'cddaa1829309438e1aa9ab652b17cfc081fff40356cb3af35c621e9f37ba6e2a03e6abac5a6bfe' \
'18ddb489412b7c56355292e6c355f8859270d04063b843d23c1ef7503c3c5dd2c56740101a3ef5' \
'bfec6bff1e6dc55e3f70840a83a95d7b3d20ab350d0472809ce87a4e3c29ed9685eb7721dc87ba' \
'bfadbd9e65e75d5df55547bcff98711ddeae7b8e1e6dbf529e96f7caa4b830b43575cddc52cebc' \
'39f9522f85cbf33ac35ee59f66f48109c12fbb78d'
}
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before {
allow_any_instance_of(SIRP::Client).to receive(:start_authentication).and_return(authentication_data)
allow_any_instance_of(SIRP::Client).to receive(:process_challenge).and_return("1234")
Spaceship::Tunes.login unless skip_tunes_login
}
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/mock_servers.rb | spaceship/spec/mock_servers.rb | require_relative 'mock_servers/test_flight_server'
require_relative 'mock_servers/developer_portal_server'
RSpec.configure do |config|
config.include(WebMock::API)
config.before do
stub_request(:any, %r(appstoreconnect\.apple.com/testflight/v2)).to_rack(MockAPI::TestFlightServer)
stub_request(:any, %r(developer\.apple\.com/services-account/QH65B2/account/auth/key)).to_rack(MockAPI::DeveloperPortalServer)
stub_request(:any, %r(developer\.apple\.com/services-account/QH65B2/account/ios/identifiers/.*OMC(s){0,1}\.action)).to_rack(MockAPI::DeveloperPortalServer)
end
config.after do
MockAPI::TestFlightServer.instance_variable_set(:@routes, {})
MockAPI::DeveloperPortalServer.instance_variable_set(:@routes, {})
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/token_spec.rb | spaceship/spec/connect_api/token_spec.rb | require 'tempfile'
describe Spaceship::ConnectAPI::Token do
let(:key_id) { 'BA5176BF04' }
let(:issuer_id) { '693fbb20-54a0-4d94-88ce-8a6caf875439' }
let(:fake_api_key_json_path) { "./spaceship/spec/connect_api/fixtures/asc_key.json" }
let(:fake_api_key_extra_fields_json_path) { "./spaceship/spec/connect_api/fixtures/asc_key_extra_fields.json" }
let(:fake_api_key_base64_json_path) { "./spaceship/spec/connect_api/fixtures/asc_key_base64.json" }
let(:fake_api_key_in_house_json_path) { "./spaceship/spec/connect_api/fixtures/asc_key_in_house.json" }
let(:private_key) do
json = JSON.parse(File.read(fake_api_key_json_path), { symbolize_names: true })
json[:key]
end
context '#from_json_file' do
it 'successfully creates token' do
token = Spaceship::ConnectAPI::Token.from_json_file(fake_api_key_json_path)
expect(token.key_id).to eq("D485S484")
expect(token.issuer_id).to eq("061966a2-5f3c-4185-af13-70e66d2263f5")
expect(token.in_house).to be_nil
end
it 'successfully creates token with extra fields' do
token = Spaceship::ConnectAPI::Token.from_json_file(fake_api_key_extra_fields_json_path)
expect(token.key_id).to eq("D485S484")
expect(token.issuer_id).to eq("061966a2-5f3c-4185-af13-70e66d2263f5")
expect(token.in_house).to be_nil
end
it 'successfully creates token with base64 encoded key' do
json = JSON.parse(File.read(fake_api_key_json_path), { symbolize_names: true })
expect(Base64).to receive(:decode64).and_call_original
expect(OpenSSL::PKey::EC).to receive(:new).with(json[:key]).and_call_original
token64 = Spaceship::ConnectAPI::Token.from_json_file(fake_api_key_base64_json_path)
expect(token64.key_id).to eq("D485S484")
expect(token64.issuer_id).to eq("061966a2-5f3c-4185-af13-70e66d2263f5")
expect(token64.in_house).to be_nil
end
it 'successfully creates token with in_house' do
token = Spaceship::ConnectAPI::Token.from_json_file(fake_api_key_in_house_json_path)
expect(token.key_id).to eq("D485S484")
expect(token.issuer_id).to eq("061966a2-5f3c-4185-af13-70e66d2263f5")
expect(token.in_house).to eq(true)
end
it 'raises error with invalid JSON' do
file = Tempfile.new('key.json')
file.write('abc123')
file.close
expect do
Spaceship::ConnectAPI::Token.from_json_file(file.path)
end.to raise_error(JSON::ParserError, /unexpected token/)
end
it 'raises error with missing all keys' do
file = Tempfile.new('key.json')
file.write('{"thing":"thing"}')
file.close
expect do
Spaceship::ConnectAPI::Token.from_json_file(file.path)
end.to raise_error("App Store Connect API key JSON is missing field(s): key_id, key")
end
it 'raises error with missing key' do
file = Tempfile.new('key.json')
file.write('{"key_id":"thing", "issuer_id": "thing"}')
file.close
expect do
Spaceship::ConnectAPI::Token.from_json_file(file.path)
end.to raise_error("App Store Connect API key JSON is missing field(s): key")
end
end
context '#from' do
describe 'hash' do
it 'with string keys' do
token = Spaceship::ConnectAPI::Token.from(hash: {
"key_id" => "key_id",
"issuer_id" => "issuer_id",
"key" => private_key,
"duration" => 200,
"in_house" => true
})
expect(token.key_id).to eq('key_id')
expect(token.issuer_id).to eq('issuer_id')
expect(token.text).not_to(be_nil)
expect(token.duration).to eq(200)
expect(token.in_house).to eq(true)
end
it 'with symbols keys' do
token = Spaceship::ConnectAPI::Token.from(hash: {
key_id: "key_id",
issuer_id: "issuer_id",
key: private_key,
duration: 200,
in_house: true
})
expect(token.key_id).to eq('key_id')
expect(token.issuer_id).to eq('issuer_id')
expect(token.text).not_to(be_nil)
expect(token.duration).to eq(200)
expect(token.in_house).to eq(true)
end
end
end
context '#create' do
describe 'with arguments' do
it "with key" do
token = Spaceship::ConnectAPI::Token.create(
key_id: "key_id",
issuer_id: "issuer_id",
key: private_key,
duration: 200,
in_house: true
)
expect(token.key_id).to eq('key_id')
expect(token.issuer_id).to eq('issuer_id')
expect(token.text).not_to(be_nil)
expect(token.duration).to eq(200)
expect(token.in_house).to eq(true)
end
it "with filepath" do
expect(File).to receive(:binread).with('/path/to/file').and_return(private_key)
token = Spaceship::ConnectAPI::Token.create(
key_id: "key_id",
issuer_id: "issuer_id",
filepath: "/path/to/file",
duration: 200,
in_house: true
)
expect(token.key_id).to eq('key_id')
expect(token.issuer_id).to eq('issuer_id')
expect(token.text).not_to(be_nil)
expect(token.duration).to eq(200)
expect(token.in_house).to eq(true)
end
it "without issuer_id" do
expect(File).to receive(:binread).with('/path/to/file').and_return(private_key)
token = Spaceship::ConnectAPI::Token.create(
key_id: "key_id",
filepath: "/path/to/file",
duration: 200,
in_house: true
)
expect(token.key_id).to eq('key_id')
expect(token.issuer_id).to be_nil
expect(token.text).not_to(be_nil)
expect(token.duration).to eq(200)
expect(token.in_house).to eq(true)
end
end
describe 'with environment variables' do
it "with key" do
stub_const('ENV', {
'SPACESHIP_CONNECT_API_KEY_ID' => 'key_id',
'SPACESHIP_CONNECT_API_ISSUER_ID' => 'issuer_id',
'SPACESHIP_CONNECT_API_KEY_FILEPATH' => nil,
'SPACESHIP_CONNECT_API_TOKEN_DURATION' => '200',
'SPACESHIP_CONNECT_API_IN_HOUSE' => 'no',
'SPACESHIP_CONNECT_API_KEY' => private_key
})
token = Spaceship::ConnectAPI::Token.create
expect(token.key_id).to eq('key_id')
expect(token.issuer_id).to eq('issuer_id')
expect(token.text).not_to(be_nil)
expect(token.duration).to eq(200)
expect(token.in_house).to eq(false)
end
it "with filepath" do
expect(File).to receive(:binread).with('/path/to/file').and_return(private_key)
stub_const('ENV', {
'SPACESHIP_CONNECT_API_KEY_ID' => 'key_id',
'SPACESHIP_CONNECT_API_ISSUER_ID' => 'issuer_id',
'SPACESHIP_CONNECT_API_KEY_FILEPATH' => '/path/to/file',
'SPACESHIP_CONNECT_API_TOKEN_DURATION' => '200',
'SPACESHIP_CONNECT_API_IN_HOUSE' => 'true',
'SPACESHIP_CONNECT_API_KEY' => nil
})
token = Spaceship::ConnectAPI::Token.create
expect(token.key_id).to eq('key_id')
expect(token.issuer_id).to eq('issuer_id')
expect(token.text).not_to(be_nil)
expect(token.duration).to eq(200)
expect(token.in_house).to eq(true)
end
end
end
context 'init' do
it 'generates proper team token' do
key = OpenSSL::PKey::EC.generate('prime256v1')
token = Spaceship::ConnectAPI::Token.new(key_id: key_id, issuer_id: issuer_id, key: key)
expect(token.key_id).to eq(key_id)
expect(token.issuer_id).to eq(issuer_id)
payload, header = JWT.decode(token.text, key, true, { algorithm: 'ES256' })
expect(payload['iss']).to eq(issuer_id)
expect(payload['sub']).to be_nil
expect(payload['iat']).to be < Time.now.to_i
expect(payload['aud']).to eq('appstoreconnect-v1')
expect(payload['exp']).to be > Time.now.to_i
expect(header['kid']).to eq(key_id)
expect(header['typ']).to eq('JWT')
end
it 'generates proper individual token' do
key = OpenSSL::PKey::EC.generate('prime256v1')
token = Spaceship::ConnectAPI::Token.new(key_id: key_id, key: key)
expect(token.key_id).to eq(key_id)
expect(token.issuer_id).to be_nil
payload, header = JWT.decode(token.text, key, true, { algorithm: 'ES256' })
expect(payload['sub']).to eq('user')
expect(payload['iss']).to be_nil
expect(payload['iat']).to be < Time.now.to_i
expect(payload['aud']).to eq('appstoreconnect-v1')
expect(payload['exp']).to be > Time.now.to_i
expect(header['kid']).to eq(key_id)
expect(header['typ']).to eq('JWT')
end
describe 'audience field for JWT payload' do
key = OpenSSL::PKey::EC.generate('prime256v1')
it 'uses appstoreconnect when in_house is false' do
token = Spaceship::ConnectAPI::Token.new(key_id: key_id, key: key, in_house: false)
payload, = JWT.decode(token.text, key, true, { algorithm: 'ES256' })
expect(payload['aud']).to eq('appstoreconnect-v1')
end
it 'uses enterprise when in_house is true' do
token = Spaceship::ConnectAPI::Token.new(key_id: key_id, key: key, in_house: true)
payload, = JWT.decode(token.text, key, true, { algorithm: 'ES256' })
expect(payload['aud']).to eq('apple-developer-enterprise-v1')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/client_spec.rb | spaceship/spec/connect_api/client_spec.rb | describe Spaceship::ConnectAPI::Client do
context 'create instance' do
it '#initialize' do
cookie = double('cookie')
current_team_id = double('current_team_id')
token = double('token')
other_tunes_client = double('tunes_client')
other_portal_client = double('portal_client')
portal_args = { cookie: cookie, current_team_id: current_team_id, token: token, another_client: other_portal_client }
tunes_args = { cookie: cookie, current_team_id: current_team_id, token: token, another_client: other_tunes_client }
provisioning_client = double('provisioning_client')
test_flight_client = double('test_flight_client')
tunes_client = double('tunes_client')
users_client = double('users_client')
# Creates the API clients for the modules
expect(Spaceship::ConnectAPI::Provisioning::Client).to receive(:new).with(portal_args)
.and_return(provisioning_client)
expect(Spaceship::ConnectAPI::TestFlight::Client).to receive(:new).with(tunes_args)
.and_return(test_flight_client)
expect(Spaceship::ConnectAPI::Tunes::Client).to receive(:new).with(tunes_args)
.and_return(tunes_client)
expect(Spaceship::ConnectAPI::Users::Client).to receive(:new).with(tunes_args)
.and_return(users_client)
# Create client
client = Spaceship::ConnectAPI::Client.new(
cookie: cookie,
current_team_id: current_team_id,
token: token,
tunes_client: other_tunes_client,
portal_client: other_portal_client
)
expect(client.tunes_client).to eq(other_tunes_client)
expect(client.portal_client).to eq(other_portal_client)
expect(client.provisioning_request_client).to eq(provisioning_client)
expect(client.test_flight_request_client).to eq(test_flight_client)
expect(client.tunes_request_client).to eq(tunes_client)
expect(client.users_request_client).to eq(users_client)
end
context '#auth' do
it 'with filepath' do
key_id = "key_id"
issuer_id = "issuer_id"
filepath = "filepath"
token = double('token')
expect(Spaceship::ConnectAPI::Token).to receive(:create).with(key_id: key_id, issuer_id: issuer_id, filepath: filepath, key: nil, duration: nil, in_house: nil).and_return(token)
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(token: token)
Spaceship::ConnectAPI::Client.auth(key_id: key_id, issuer_id: issuer_id, filepath: filepath)
end
it 'with key' do
key_id = "key_id"
issuer_id = "issuer_id"
key = "key"
token = double('token')
expect(Spaceship::ConnectAPI::Token).to receive(:create).with(key_id: key_id, issuer_id: issuer_id, filepath: nil, key: key, duration: 100, in_house: true).and_return(token)
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(token: token)
Spaceship::ConnectAPI::Client.auth(key_id: key_id, issuer_id: issuer_id, key: key, duration: 100, in_house: true)
end
end
context '#login' do
let(:username) { 'username' }
let(:password) { 'password' }
let(:team_id) { 'team_id' }
let(:team_name) { 'team_name' }
let(:tunes_client) { double('tunes_client') }
let(:portal_client) { double('portal_client') }
it 'no team_id or team_name' do
stub_const('ENV', {})
expect(Spaceship::PortalClient).to receive(:login).with(username, password).and_return(portal_client)
expect(Spaceship::TunesClient).to receive(:login).with(username, password).and_return(tunes_client)
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: tunes_client, portal_client: portal_client)
expect(portal_client).to receive(:select_team).with(team_id: nil, team_name: nil)
expect(tunes_client).to receive(:select_team).with(team_id: nil, team_name: nil)
Spaceship::ConnectAPI::Client.login(username, password)
end
it 'with portal_team_id' do
stub_const('ENV', {})
expect(Spaceship::PortalClient).to receive(:login).with(username, password).and_return(portal_client)
expect(Spaceship::TunesClient).not_to(receive(:login).with(username, password))
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: nil, portal_client: portal_client)
expect(portal_client).to receive(:select_team).with(team_id: team_id, team_name: nil)
expect(tunes_client).not_to(receive(:select_team).with(team_id: team_id, team_name: nil))
Spaceship::ConnectAPI::Client.login(username, password, use_portal: true, use_tunes: false, portal_team_id: team_id)
end
it 'with tunes_team_id' do
stub_const('ENV', {})
expect(Spaceship::PortalClient).not_to(receive(:login).with(username, password))
expect(Spaceship::TunesClient).to receive(:login).with(username, password).and_return(tunes_client)
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: tunes_client, portal_client: nil)
expect(portal_client).not_to(receive(:select_team).with(team_id: team_id, team_name: nil))
expect(tunes_client).to receive(:select_team).with(team_id: team_id, team_name: nil)
Spaceship::ConnectAPI::Client.login(username, password, use_portal: false, use_tunes: true, tunes_team_id: team_id)
end
it 'with team_name' do
stub_const('ENV', {})
expect(Spaceship::PortalClient).to receive(:login).with(username, password).and_return(portal_client)
expect(Spaceship::TunesClient).to receive(:login).with(username, password).and_return(tunes_client)
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: tunes_client, portal_client: portal_client)
expect(tunes_client).to receive(:select_team).with(team_id: nil, team_name: team_name)
expect(portal_client).to receive(:select_team).with(team_id: nil, team_name: team_name)
Spaceship::ConnectAPI::Client.login(username, password, team_name: team_name)
end
context 'with environment variables' do
it 'with FASTLANE_TEAM_ID' do
stub_const('ENV', { 'FASTLANE_TEAM_ID' => team_id })
expect(Spaceship::PortalClient).to receive(:login).with(username, password).and_return(portal_client)
expect(Spaceship::TunesClient).not_to(receive(:login).with(username, password))
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: nil, portal_client: portal_client)
expect(portal_client).to receive(:select_team)
expect(tunes_client).not_to(receive(:select_team))
Spaceship::ConnectAPI::Client.login(username, password, use_portal: true, use_tunes: false)
end
it 'with FASTLANE_ITC_TEAM_ID' do
stub_const('ENV', { 'FASTLANE_ITC_TEAM_ID' => team_id })
expect(Spaceship::PortalClient).not_to(receive(:login).with(username, password))
expect(Spaceship::TunesClient).to receive(:login).with(username, password).and_return(tunes_client)
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: tunes_client, portal_client: nil)
expect(portal_client).not_to(receive(:select_team))
expect(tunes_client).to receive(:select_team)
Spaceship::ConnectAPI::Client.login(username, password, use_portal: false, use_tunes: true)
end
it 'with FASTLANE_TEAM_NAME' do
stub_const('ENV', { 'FASTLANE_TEAM_NAME' => team_name })
expect(Spaceship::PortalClient).to receive(:login).with(username, password).and_return(portal_client)
expect(Spaceship::TunesClient).not_to(receive(:login).with(username, password))
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: nil, portal_client: portal_client)
expect(portal_client).to receive(:select_team)
expect(tunes_client).not_to(receive(:select_team))
Spaceship::ConnectAPI::Client.login(username, password, use_portal: true, use_tunes: false)
end
it 'with FASTLANE_ITC_TEAM_NAME' do
stub_const('ENV', { 'FASTLANE_ITC_TEAM_NAME' => team_name })
expect(Spaceship::PortalClient).not_to(receive(:login).with(username, password))
expect(Spaceship::TunesClient).to receive(:login).with(username, password).and_return(tunes_client)
expect(Spaceship::ConnectAPI::Client).to receive(:new).with(tunes_client: tunes_client, portal_client: nil)
expect(portal_client).not_to(receive(:select_team))
expect(tunes_client).to receive(:select_team)
Spaceship::ConnectAPI::Client.login(username, password, use_portal: false, use_tunes: true)
end
end
end
context "#in_house?" do
context "with token" do
let(:mock_token) { double('token') }
let(:client) do
Spaceship::ConnectAPI::Client.new(token: mock_token)
end
it "raise error without in_house set" do
allow(mock_token).to receive(:in_house).and_return(nil)
expect do
client.in_house?
end.to raise_error(/Cannot determine if team is App Store or Enterprise via the App Store Connect API/)
end
it "with in_house set" do
allow(mock_token).to receive(:in_house).and_return(true)
in_house = client.in_house?
expect(in_house).to be(true)
end
end
it "with portal client" do
mock_portal_client = double('portal client')
allow(mock_portal_client).to receive(:team_id)
allow(mock_portal_client).to receive(:csrf_tokens)
client = Spaceship::ConnectAPI::Client.new(portal_client: mock_portal_client)
expect(mock_portal_client).to receive(:in_house?).and_return(true)
in_house = client.in_house?
expect(in_house).to be(true)
end
it "raise error with no session" do
client = Spaceship::ConnectAPI::Client.new
expect do
client.in_house?
end.to raise_error("No App Store Connect API token or Portal Client set")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/api_client_spec.rb | spaceship/spec/connect_api/api_client_spec.rb | describe Spaceship::ConnectAPI::APIClient do
describe "#build_params" do
let(:mock_token) { double('token') }
let(:client) { Spaceship::ConnectAPI::APIClient.new(token: mock_token) }
before(:each) do
allow(mock_token).to receive(:text).and_return("ewfawef")
allow(mock_token).to receive(:in_house).and_return(nil)
end
context 'build_params' do
let(:path) { "betaAppReviewDetails" }
let(:nil_filter) { { build: nil } }
let(:one_filter) { { build: "123" } }
let(:two_filters) { { build: "123", app: "321" } }
let(:includes) { "model.attribute" }
let(:fields) { { a: 'aField', b: 'bField1,bField2' } }
let(:limit) { "30" }
let(:sort) { "asc" }
it 'builds params with nothing' do
params = client.build_params
expect(params).to eq({})
end
it 'builds params with nil filter' do
params = client.build_params(filter: nil_filter)
expect(params).to eq({})
end
it 'builds params with one filter' do
params = client.build_params(filter: one_filter)
expect(params).to eq({
filter: one_filter
})
end
it 'builds params with two filters' do
params = client.build_params(filter: two_filters)
expect(params).to eq({
filter: two_filters
})
end
it 'builds params with includes' do
params = client.build_params(includes: includes)
expect(params).to eq({
include: includes
})
end
it 'builds params with fields' do
params = client.build_params(fields: fields)
expect(params).to eq({
fields: fields
})
end
it 'builds params with limit' do
params = client.build_params(limit: limit)
expect(params).to eq({
limit: limit
})
end
it 'builds params with sort' do
params = client.build_params(sort: sort)
expect(params).to eq({
sort: sort
})
end
it 'builds params with one filter, includes, fields, limit, and sort' do
params = client.build_params(filter: one_filter, includes: includes, fields: fields, limit: limit, sort: sort)
expect(params).to eq({
filter: one_filter,
include: includes,
fields: fields,
limit: limit,
sort: sort
})
end
end
end
describe "#request" do
let(:mock_token) { double('token') }
let(:client) { Spaceship::ConnectAPI::APIClient.new(token: mock_token) }
let(:unauth_error) { Spaceship::Client::UnauthorizedAccessError.new }
let(:default_body) { '{foo: "bar"}' }
def stub_client_request(uri, status, body)
stub_request(:get, uri).
to_return(status: status, body: body, headers: { "Content-Type": "application/json" })
end
before(:each) do
allow(mock_token).to receive(:text).and_return("ewfawef")
allow(mock_token).to receive(:expired?).and_return(false)
allow(mock_token).to receive(:in_house).and_return(nil)
end
it 'not raise on 200' do
body = JSON.generate({ "data": { "hello": "world" } })
stub_client_request(client.hostname, 200, body)
client.get('')
end
it 'raise on 401' do
body = JSON.generate({ "errors": [] })
stub_client_request(client.hostname, 401, body)
expect(mock_token).to receive(:refresh!).exactly(4).times
expect do
client.get('')
end.to raise_error(Spaceship::UnauthorizedAccessError)
end
it 'raise on 403 with program license agreement updated' do
body = JSON.generate({ "errors": [{ "code": "FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED" }] })
stub_client_request(client.hostname, 403, body)
expect do
client.get('')
end.to raise_error(Spaceship::ProgramLicenseAgreementUpdated)
end
it 'raise on 403' do
body = JSON.generate({ "errors": [] })
stub_client_request(client.hostname, 403, body)
expect do
client.get('')
end.to raise_error(Spaceship::AccessForbiddenError)
end
describe 'with_retry' do
it 'sleeps on 429' do
stub_request(:get, client.hostname).
to_return(status: 429).then.
to_return(status: 200, body: "")
expect(Kernel).to receive(:sleep).once.with(1)
expect(client).to receive(:handle_response).once
expect(client).to receive(:request).twice.and_call_original
expect do
client.get('')
end.to_not(raise_error)
end
it 'sleeps until limit is reached on 429' do
body = JSON.generate({ "errors": [{ "title": "The request rate limit has been reached.", "details": "We've received too many requests for this API. Please wait and try again or slow down your request rate." }] })
stub_client_request(client.hostname, 429, body)
expect(Kernel).to receive(:sleep).exactly(12).times
expect do
client.get('')
end.to raise_error(Spaceship::ConnectAPI::APIClient::TooManyRequestsError, "Too many requests, giving up after backing off for > 3600 seconds.")
end
end
end
describe "#handle_error" do
let(:mock_token) { double('token') }
let(:client) { Spaceship::ConnectAPI::APIClient.new(token: mock_token) }
let(:mock_response) { double('response') }
before(:each) do
allow(mock_token).to receive(:in_house).and_return(nil)
end
describe "status of 200" do
before(:each) do
allow(mock_response).to receive(:status).and_return(200)
end
it 'does not raise' do
allow(mock_response).to receive(:body).and_return({})
expect do
client.send(:handle_error, mock_response)
end.to_not(raise_error)
end
end
describe "status of 401" do
before(:each) do
allow(mock_response).to receive(:status).and_return(401)
end
it 'raises UnauthorizedAccessError with no errors in body' do
allow(mock_response).to receive(:body).and_return({})
expect do
client.send(:handle_error, mock_response)
end.to raise_error(Spaceship::UnauthorizedAccessError, /Unknown error/)
end
it 'raises UnauthorizedAccessError when body is string' do
allow(mock_response).to receive(:body).and_return('{"errors":[{"title": "Some title", "detail": "some detail"}]}')
expect do
client.send(:handle_error, mock_response)
end.to raise_error(Spaceship::UnauthorizedAccessError, /Some title - some detail/)
end
end
describe "status of 403" do
before(:each) do
allow(mock_response).to receive(:status).and_return(403)
end
it 'raises ProgramLicenseAgreementUpdated with no errors in body FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED' do
allow(mock_response).to receive(:body).and_return({
"errors" => [
{
"code" => "FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED"
}
]
})
expect do
client.send(:handle_error, mock_response)
end.to raise_error(Spaceship::ProgramLicenseAgreementUpdated)
end
it 'raises AccessForbiddenError with no errors in body' do
allow(mock_response).to receive(:body).and_return({})
expect do
client.send(:handle_error, mock_response)
end.to raise_error(Spaceship::AccessForbiddenError, /Unknown error/)
end
it 'raises AccessForbiddenError when body is string' do
allow(mock_response).to receive(:body).and_return('{"errors":[{"title": "Some title", "detail": "some detail"}]}')
expect do
client.send(:handle_error, mock_response)
end.to raise_error(Spaceship::AccessForbiddenError, /Some title - some detail/)
end
it 'raises AccessForbiddenError with errors in body' do
allow(mock_response).to receive(:body).and_return({
"errors" => [
{
"title" => "Some title",
"detail" => "some detail"
}
]
})
expect do
client.send(:handle_error, mock_response)
end.to raise_error(Spaceship::AccessForbiddenError, /Some title - some detail/)
end
end
end
describe "#hostname" do
let(:mock_token) { double('token') }
let(:client) { Spaceship::ConnectAPI::APIClient.new(token: mock_token) }
it 'points to App Store Connect API when in_house is not set' do
allow(mock_token).to receive(:in_house).and_return(nil)
expect(client.hostname).to eq('https://api.appstoreconnect.apple.com/')
end
it 'points to App Store Connect API when in_house is false' do
allow(mock_token).to receive(:in_house).and_return(false)
expect(client.hostname).to eq('https://api.appstoreconnect.apple.com/')
end
it 'points to Enterprise Program API when in_house is true' do
allow(mock_token).to receive(:in_house).and_return(true)
expect(client.hostname).to eq('https://api.enterprise.developer.apple.com/')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/model_spec.rb | spaceship/spec/connect_api/model_spec.rb | require 'json'
describe Spaceship::ConnectAPI::Model do
it "#to_json" do
class TestModel
include Spaceship::ConnectAPI::Model
attr_accessor :foo
attr_accessor :foo_bar
attr_mapping({
"fooBar" => "foo_bar"
})
end
test = TestModel.new("id", { foo: "foo", foo_bar: "foo_bar" })
expect(JSON.parse(test.to_json)).to eq({
"id" => "id",
"foo" => "foo",
"foo_bar" => "foo_bar"
})
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/spaceship_spec.rb | spaceship/spec/connect_api/spaceship_spec.rb | describe Spaceship::ConnectAPI do
before(:all) do
Spaceship::ConnectAPI.client = nil
Spaceship::Tunes.client = nil
Spaceship::Portal.client = nil
end
context '#client' do
let(:mock_client) { double('mock_client') }
let(:mock_tunes_client) { double('tunes_client') }
let(:mock_portal_client) { double('portal_client') }
before(:each) do
allow(mock_tunes_client).to receive(:team_id).and_return("team_id")
allow(mock_portal_client).to receive(:team_id).and_return("team_id")
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(mock_portal_client).to receive(:csrf_tokens)
end
context 'with implicit client' do
it 'returns client with using existing Tunes session' do
allow(Spaceship::Tunes).to receive(:client).and_return(mock_tunes_client)
client = Spaceship::ConnectAPI.client
expect(client).not_to(be_nil)
expect(client.tunes_client).to eq(mock_tunes_client)
expect(client.portal_client).to eq(nil)
end
it 'returns client with using existing Portal session' do
allow(Spaceship::Portal).to receive(:client).and_return(mock_portal_client)
client = Spaceship::ConnectAPI.client
expect(client).not_to(be_nil)
expect(client.tunes_client).to eq(nil)
expect(client.portal_client).to eq(mock_portal_client)
end
it 'returns client with using existing Tunes and Portal session' do
allow(Spaceship::Tunes).to receive(:client).and_return(mock_tunes_client)
allow(Spaceship::Portal).to receive(:client).and_return(mock_portal_client)
client = Spaceship::ConnectAPI.client
expect(client).not_to(be_nil)
expect(client.tunes_client).to eq(mock_tunes_client)
expect(client.portal_client).to eq(mock_portal_client)
end
it 'returns nil when no existing sessions' do
client = Spaceship::ConnectAPI.client
expect(client).to(be_nil)
end
end
context 'with explicit client' do
it '#auth' do
key_id = 'key_id'
issuer_id = 'issuer_id'
filepath = 'filepath'
expect(Spaceship::ConnectAPI::Client).to receive(:auth).with(key_id: key_id, issuer_id: issuer_id, filepath: filepath, key: nil, duration: nil, in_house: nil).and_return(mock_client)
client = Spaceship::ConnectAPI.auth(key_id: key_id, issuer_id: issuer_id, filepath: filepath)
expect(client).to eq(Spaceship::ConnectAPI.client)
end
context '#login' do
it 'with portal_team_id' do
user = 'user'
password = 'password'
team_id = 'team_id'
team_name = 'team_name'
expect(Spaceship::ConnectAPI::Client).to receive(:login).with(user, password, use_portal: true, use_tunes: false, portal_team_id: team_id, tunes_team_id: nil, team_name: team_name, skip_select_team: false).and_return(mock_client)
client = Spaceship::ConnectAPI.login(user, password, use_portal: true, use_tunes: false, portal_team_id: team_id, team_name: team_name)
expect(client).to eq(Spaceship::ConnectAPI.client)
end
it 'with tunes_team_id' do
user = 'user'
password = 'password'
team_id = 'team_id'
team_name = 'team_name'
expect(Spaceship::ConnectAPI::Client).to receive(:login).with(user, password, use_portal: false, use_tunes: true, portal_team_id: nil, tunes_team_id: team_id, team_name: team_name, skip_select_team: false).and_return(mock_client)
client = Spaceship::ConnectAPI.login(user, password, use_portal: false, use_tunes: true, tunes_team_id: team_id, team_name: team_name)
expect(client).to eq(Spaceship::ConnectAPI.client)
end
it 'with both portal_team_id and tunes_team_id' do
user = 'user'
password = 'password'
team_id = 'team_id'
team_name = 'team_name'
expect(Spaceship::ConnectAPI::Client).to receive(:login).with(user, password, use_portal: true, use_tunes: true, portal_team_id: team_id, tunes_team_id: team_id, team_name: team_name, skip_select_team: false).and_return(mock_client)
client = Spaceship::ConnectAPI.login(user, password, use_portal: true, use_tunes: true, portal_team_id: team_id, tunes_team_id: team_id, team_name: team_name)
expect(client).to eq(Spaceship::ConnectAPI.client)
end
end
end
end
context '#select_team' do
let(:mock_client) { double('mock_client') }
let(:team_id) { "team_id" }
let(:team_name) { "team name" }
context 'with client' do
it 'with portal_team_id' do
allow(Spaceship::ConnectAPI).to receive(:client).and_return(mock_client)
expect(mock_client).to receive(:select_team).with(portal_team_id: team_id, tunes_team_id: nil, team_name: team_name)
Spaceship::ConnectAPI.select_team(portal_team_id: team_id, team_name: team_name)
end
it 'with tunes_team_id' do
allow(Spaceship::ConnectAPI).to receive(:client).and_return(mock_client)
expect(mock_client).to receive(:select_team).with(portal_team_id: nil, tunes_team_id: team_id, team_name: team_name)
Spaceship::ConnectAPI.select_team(tunes_team_id: team_id, team_name: team_name)
end
it 'with both portal_team_id and tunes_team_id' do
allow(Spaceship::ConnectAPI).to receive(:client).and_return(mock_client)
expect(mock_client).to receive(:select_team).with(portal_team_id: team_id, tunes_team_id: team_id, team_name: team_name)
Spaceship::ConnectAPI.select_team(portal_team_id: team_id, tunes_team_id: team_id, team_name: team_name)
end
end
it 'without client' do
allow(Spaceship::ConnectAPI).to receive(:client).and_return(nil)
expect(mock_client).not_to(receive(:select_team).with(portal_team_id: team_id, tunes_team_id: team_id, team_name: team_name))
Spaceship::ConnectAPI.select_team(portal_team_id: team_id, tunes_team_id: team_id, team_name: team_name)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/provisioning/provisioning_stubbing.rb | spaceship/spec/connect_api/provisioning/provisioning_stubbing.rb | class ConnectAPIStubbing
class Provisioning
class << self
def read_fixture_file(filename)
File.read(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'provisioning', filename))
end
def read_binary_fixture_file(filename)
File.binread(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'provisioning', filename))
end
# Necessary, as we're now running this in a different context
def stub_request(*args)
WebMock::API.stub_request(*args)
end
def stub_bundle_ids
stub_request(:post, "https://developer.apple.com/services-account/v1/bundleIds").
to_return(status: 200, body: read_fixture_file('bundle_ids.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
end
def stub_patch_bundle_id_capability
# APP_ATTEST
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => false, "settings" => [] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "APP_ATTEST" } } } }] } } } }).
to_return(status: 200)
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => true, "settings" => [] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "APP_ATTEST" } } } }] } } } }).
to_return(status: 200)
# ACCESS_WIFI
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => false, "settings" => [] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "ACCESS_WIFI_INFORMATION" } } } }] } } } }).
to_return(status: 200)
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => true, "settings" => [] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "ACCESS_WIFI_INFORMATION" } } } }] } } } }).
to_return(status: 200)
# DATA_PROTECTION
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => true, "settings" => [{ "key" => "DATA_PROTECTION_PERMISSION_LEVEL", "options" => [{ "key" => "COMPLETE_PROTECTION" }] }] }, "relationships" => { "capability" =>
{ "data" => { "type" => "capabilities", "id" => "DATA_PROTECTION" } } } }] } } } }).to_return(status: 200)
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => true, "settings" => [{ "key" => "DATA_PROTECTION_PERMISSION_LEVEL", "options" => [{ "key" => "PROTECTED_UNLESS_OPEN" }] }] }, "relationships" => { "capability" =>
{ "data" => { "type" => "capabilities", "id" => "DATA_PROTECTION" } } } }] } } } }).to_return(status: 200)
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => true, "settings" => [{ "key" => "DATA_PROTECTION_PERMISSION_LEVEL", "options" => [{ "key" => "PROTECTED_UNTIL_FIRST_USER_AUTH" }] }] }, "relationships" => { "capability" =>
{ "data" => { "type" => "capabilities", "id" => "DATA_PROTECTION" } } } }] } } } }).to_return(status: 200)
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => false, "settings" => [] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "DATA_PROTECTION" } } } }] } } } }).
to_return(status: 200)
# ICLOUD
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => true, "settings" => [{ "key" => "ICLOUD_VERSION", "options" => [{ "key" => "XCODE_5" }] }] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "ICLOUD" } } } }] } } } }).
to_return(status: 200)
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => true, "settings" => [{ "key" => "ICLOUD_VERSION", "options" => [{ "key" => "XCODE_6" }] }] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "ICLOUD" } } } }] } } } }).
to_return(status: 200)
stub_request(:patch, "https://developer.apple.com/services-account/v1/bundleIds/ABCD1234").
with(body: { "data" => { "type" => "bundleIds", "id" => "ABCD1234", "attributes" => { "permissions" => { "edit" => true, "delete" => true }, "seedId" => "SEEDID", "teamId" => "XXXXXXXXXX" },
"relationships" => { "bundleIdCapabilities" => { "data" => [{ "type" => "bundleIdCapabilities", "attributes" => { "enabled" => false, "settings" => [] }, "relationships" => { "capability" => { "data" => { "type" => "capabilities", "id" => "ICLOUD" } } } }] } } } }).
to_return(status: 200)
end
def stub_bundle_id
stub_request(:post, "https://developer.apple.com/services-account/v1/bundleIds/123456789").
to_return(status: 200, body: read_fixture_file('bundle_id.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
end
def stub_available_bundle_id_capabilities
stub_request(:post, "https://developer.apple.com/services-account/v1/capabilities").
to_return(status: 200, body: read_fixture_file('capabilities.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
end
def stub_certificates
stub_request(:post, "https://developer.apple.com/services-account/v1/certificates").
to_return(status: 200, body: read_fixture_file('certificates.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
end
def stub_devices
stub_request(:post, "https://developer.apple.com/services-account/v1/devices").
to_return(status: 200, body: read_fixture_file('devices.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
stub_request(:patch, "https://developer.apple.com/services-account/v1/devices/13371337").
to_return(status: 200, body: read_fixture_file('device_enable.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
stub_request(:patch, "https://developer.apple.com/services-account/v1/devices/123456789").
to_return(status: 200, body: read_fixture_file('device_disable.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
stub_request(:patch, "https://developer.apple.com/services-account/v1/devices/987654321").
to_return(status: 200, body: read_fixture_file('device_rename.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
end
def stub_profiles
stub_request(:post, "https://developer.apple.com/services-account/v1/profiles").
to_return(status: 200, body: read_fixture_file('profiles.json'), headers: { 'Content-Type' => 'application/vnd.api+json' })
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/provisioning/provisioning_client_spec.rb | spaceship/spec/connect_api/provisioning/provisioning_client_spec.rb | describe Spaceship::ConnectAPI::Provisioning::Client do
let(:client) { Spaceship::ConnectAPI::Provisioning::Client.new }
let(:hostname) { Spaceship::ConnectAPI::Provisioning::Client.hostname }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
Spaceship::ConnectAPI.login(username, password, use_portal: true, use_tunes: false)
end
context 'sends api request' do
before(:each) do
allow(client).to receive(:handle_response)
allow(client).to receive(:team_id).and_return("XXXXXXXXXX")
end
def test_request_params(url, params)
req_mock = double
options_mock = double
allow(req_mock).to receive(:headers).and_return({})
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:params=).with(params)
expect(req_mock).to receive(:options).and_return(options_mock)
expect(options_mock).to receive(:params_encoder=).with(Faraday::NestedParamsEncoder)
return req_mock
end
def test_request_body(url, body)
req_mock = double
header_mock = double
encoded_params = Faraday::NestedParamsEncoder.encode(body)
encoded_body = { "urlEncodedQueryParams" => encoded_params, "teamId" => Spaceship::Portal.client.team_id }
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:body=).with(JSON.generate(encoded_body))
expect(req_mock).to receive(:headers).and_return(header_mock).exactly(3).times
expect(header_mock).to receive(:[]=).with("X-Requested-With", "XMLHttpRequest")
expect(header_mock).to receive(:[]=).with("X-HTTP-Method-Override", "GET")
expect(header_mock).to receive(:[]=).with("Content-Type", "application/vnd.api+json")
return req_mock
end
describe "bundleIds" do
context 'get_bundle_ids' do
let(:path) { "v1/bundleIds" }
it 'succeeds' do
params = {}
req_mock = test_request_body(path, params)
expect(client).to receive(:request).with(:post).and_yield(req_mock)
client.get_bundle_ids
end
end
end
describe "bundleId Capability" do
context 'patch_bundle_id_capability' do
it 'should make a request to turn APP_ATTEST on' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: true, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::APP_ATTEST)
end
it 'should make a request to turn APP_ATTEST off' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: false, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::APP_ATTEST)
end
it 'should make a request to turn ACCESS_WIFI on' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: true, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::ACCESS_WIFI_INFORMATION)
end
it 'should make a request to turn ACCESS_WIFI off' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: false, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::ACCESS_WIFI_INFORMATION)
end
it 'should make a request to turn DATA_PROTECTION complete' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: true, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::DATA_PROTECTION,
settings: settings = [{ key: Spaceship::ConnectAPI::BundleIdCapability::Settings::DATA_PROTECTION_PERMISSION_LEVEL, options: [ { key: Spaceship::ConnectAPI::BundleIdCapability::Options::COMPLETE_PROTECTION } ] }])
end
it 'should make a request to turn DATA_PROTECTION unless_open' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: true, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::DATA_PROTECTION,
settings: settings = [{ key: Spaceship::ConnectAPI::BundleIdCapability::Settings::DATA_PROTECTION_PERMISSION_LEVEL, options: [ { key: Spaceship::ConnectAPI::BundleIdCapability::Options::PROTECTED_UNLESS_OPEN } ] }])
end
it 'should make a request to turn DATA_PROTECTION until_first_auth' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: true, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::DATA_PROTECTION,
settings: settings = [{ key: Spaceship::ConnectAPI::BundleIdCapability::Settings::DATA_PROTECTION_PERMISSION_LEVEL, options: [ { key: Spaceship::ConnectAPI::BundleIdCapability::Options::PROTECTED_UNTIL_FIRST_USER_AUTH } ] }])
end
it 'should make a request to turn DATA_PROTECTION off' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: false, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::DATA_PROTECTION)
end
it 'should make a request to turn ICLOUD xcode6_compatible' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: true, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::ICLOUD,
settings: settings = [{ key: Spaceship::ConnectAPI::BundleIdCapability::Settings::ICLOUD_VERSION, options: [ { key: Spaceship::ConnectAPI::BundleIdCapability::Options::XCODE_5 } ] }])
end
it 'should make a request to turn ICLOUD xcode5_compatible' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: true, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::ICLOUD,
settings: settings = [{ key: Spaceship::ConnectAPI::BundleIdCapability::Settings::ICLOUD_VERSION, options: [ { key: Spaceship::ConnectAPI::BundleIdCapability::Options::XCODE_6 } ] }])
end
it 'should make a request to turn ICLOUD off' do
client.patch_bundle_id_capability(bundle_id_id: "ABCD1234", seed_id: "SEEDID", enabled: false, capability_type: Spaceship::ConnectAPI::BundleIdCapability::Type::ICLOUD)
end
end
end
describe "certificates" do
context 'get_certificates' do
let(:path) { "v1/certificates" }
it 'succeeds' do
params = {}
req_mock = test_request_body(path, params)
expect(client).to receive(:request).with(:post).and_yield(req_mock)
client.get_certificates
end
end
context 'get_certificates_for_profile' do
let(:path) { "v1/profiles/123456789/certificates" }
it 'succeeds' do
params = {}
req_mock = test_request_body(path, params)
expect(client).to receive(:request).with(:post).and_yield(req_mock)
client.get_certificates(profile_id: '123456789')
end
end
end
describe "devices" do
context 'get_devices' do
let(:path) { "v1/devices" }
it 'succeeds' do
params = {}
req_mock = test_request_body(path, params)
expect(client).to receive(:request).with(:post).and_yield(req_mock)
client.get_devices
end
end
end
describe "profiles" do
context 'get_profiles' do
let(:path) { "v1/profiles" }
it 'succeeds' do
params = {}
req_mock = test_request_body(path, params)
expect(client).to receive(:request).with(:post).and_yield(req_mock)
client.get_profiles
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/tunes/tunes_stubbing.rb | spaceship/spec/connect_api/tunes/tunes_stubbing.rb | class ConnectAPIStubbing
class Tunes
class << self
def read_fixture_file(filename)
File.read(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'tunes', filename))
end
def read_binary_fixture_file(filename)
File.binread(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'tunes', filename))
end
# Necessary, as we're now running this in a different context
def stub_request(*args)
WebMock::API.stub_request(*args)
end
def stub_get_app_availabilities_ready_for_distribution
stub_request(:get, "https://appstoreconnect.apple.com/iris/v2/appAvailabilities/123456789?include=territoryAvailabilities&limit%5BterritoryAvailabilities%5D=200").
to_return(status: 200, body: read_fixture_file('app_availabilities_ready_for_distribution.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_get_app_availabilities_removed_from_sale
stub_request(:get, "https://appstoreconnect.apple.com/iris/v2/appAvailabilities/123456789?include=territoryAvailabilities&limit%5BterritoryAvailabilities%5D=200").
to_return(status: 200, body: read_fixture_file('app_availabilities_removed_app.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_get_app_infos
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps/123456789/appInfos").
to_return(status: 200, body: read_fixture_file('app_infos.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_app_store_version_release_request
stub_request(:post, "https://appstoreconnect.apple.com/iris/v1/appStoreVersionReleaseRequests").
to_return(status: 200, body: read_fixture_file('app_store_version_release_request.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_create_review_submission
stub_request(:post, "https://appstoreconnect.apple.com/iris/v1/reviewSubmissions").
to_return(status: 200, body: read_fixture_file('review_submission_created.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_cancel_review_submission
stub_request(:patch, "https://appstoreconnect.apple.com/iris/v1/reviewSubmissions/123456789").
with(body: { data: WebMock::API.hash_including({ attributes: { canceled: true } }) }).
to_return(status: 200, body: read_fixture_file('review_submission_cancelled.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_get_review_submission
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/reviewSubmissions/123456789").
to_return(status: 200, body: read_fixture_file('review_submission.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_get_review_submissions
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps/123456789-app/reviewSubmissions").
to_return(status: 200, body: read_fixture_file('review_submissions.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_submit_review_submission
stub_request(:patch, "https://appstoreconnect.apple.com/iris/v1/reviewSubmissions/123456789").
with(body: { data: WebMock::API.hash_including({ attributes: { submitted: true } }) }).
to_return(status: 200, body: read_fixture_file('review_submission_submitted.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_create_review_submission_item
stub_request(:post, "https://appstoreconnect.apple.com/iris/v1/reviewSubmissionItems").
to_return(status: 200, body: read_fixture_file('review_submission_item_created.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_get_review_submission_items
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/reviewSubmissions/123456789/items").
to_return(status: 200, body: read_fixture_file('review_submission_items.json'), headers: { 'Content-Type' => 'application/json' })
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/tunes/tunes_client_spec.rb | spaceship/spec/connect_api/tunes/tunes_client_spec.rb | describe Spaceship::ConnectAPI::Tunes::Client do
let(:mock_tunes_client) { double('tunes_client') }
let(:client) { Spaceship::ConnectAPI::Tunes::Client.new(another_client: mock_tunes_client) }
let(:hostname) { Spaceship::ConnectAPI::Tunes::Client.hostname }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
context 'sends api request' do
before(:each) do
allow(client).to receive(:handle_response)
end
def test_request_params(url, params)
req_mock = double
options_mock = double
allow(req_mock).to receive(:headers).and_return({})
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:params=).with(params)
expect(req_mock).to receive(:options).and_return(options_mock)
expect(options_mock).to receive(:params_encoder=).with(Faraday::NestedParamsEncoder)
allow(req_mock).to receive(:status)
return req_mock
end
def test_request_body(url, body)
req_mock = double
header_mock = double
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:body=).with(JSON.generate(body))
expect(req_mock).to receive(:headers).and_return(header_mock)
expect(header_mock).to receive(:[]=).with("Content-Type", "application/json")
allow(req_mock).to receive(:status)
return req_mock
end
describe "appAvailabilities" do
context 'get_app_availabilities' do
let(:path) { "v2/appAvailabilities" }
let(:app_id) { "123" }
it 'succeeds' do
url = "#{path}/#{app_id}"
params = {
include: "territoryAvailabilities",
limit: { "territoryAvailabilities": 200 }
}
req_mock = test_request_params(url, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_app_availabilities(app_id: app_id, includes: "territoryAvailabilities", limit: { "territoryAvailabilities": 200 })
end
end
end
describe "appStoreVersionReleaseRequests" do
context 'post_app_store_version_release_request' do
let(:path) { "v1/appStoreVersionReleaseRequests" }
let(:app_store_version_id) { "123" }
let(:body) do
{
data: {
type: "appStoreVersionReleaseRequests",
relationships: {
appStoreVersion: {
data: {
type: "appStoreVersions",
id: app_store_version_id
}
}
}
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_app_store_version_release_request(app_store_version_id: app_store_version_id)
end
end
end
describe "reviewSubmissions" do
context 'get_review_submissions' do
let(:app_id) { "123456789-app" }
let(:path) { "v1/apps/#{app_id}/reviewSubmissions" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_review_submissions(app_id: app_id)
end
end
context 'get_review_submission' do
let(:review_submission_id) { "123456789" }
let(:path) { "v1/reviewSubmissions/#{review_submission_id}" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_review_submission(review_submission_id: review_submission_id)
end
end
context 'post_review_submission' do
let(:app_id) { "123456789-app" }
let(:platform) { Spaceship::ConnectAPI::Platform::IOS }
let(:path) { "v1/reviewSubmissions" }
let(:body) do
{
data: {
type: "reviewSubmissions",
attributes: {
platform: platform
},
relationships: {
app: {
data: {
type: "apps",
id: app_id
}
}
}
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_review_submission(app_id: app_id, platform: platform)
end
end
context 'patch_review_submission' do
let(:review_submission_id) { "123456789" }
let(:attributes) { { submitted: true } }
let(:path) { "v1/reviewSubmissions/#{review_submission_id}" }
let(:body) do
{
data: {
type: "reviewSubmissions",
id: review_submission_id,
attributes: attributes
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_review_submission(review_submission_id: review_submission_id, attributes: attributes)
end
end
end
describe "reviewSubmissionItems" do
context 'get_review_submission_items' do
let(:review_submission_id) { "123456789" }
let(:path) { "v1/reviewSubmissions/#{review_submission_id}/items" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_review_submission_items(review_submission_id: review_submission_id)
end
end
context 'post_review_submission_item' do
let(:review_submission_id) { "123456789" }
let(:app_store_version_id) { "123456789-app-store-version" }
let(:path) { "v1/reviewSubmissionItems" }
let(:body) do
{
data: {
type: "reviewSubmissionItems",
relationships: {
reviewSubmission: {
data: {
type: "reviewSubmissions",
id: review_submission_id
}
},
appStoreVersion: {
data: {
type: "appStoreVersions",
id: app_store_version_id
}
}
}
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_review_submission_item(review_submission_id: review_submission_id, app_store_version_id: app_store_version_id)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_app_review_detail_spec.rb | spaceship/spec/connect_api/models/beta_app_review_detail_spec.rb | describe Spaceship::ConnectAPI::BetaAppReviewDetail do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_app_review_detail' do
response = Spaceship::ConnectAPI.get_beta_app_review_detail
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaAppReviewDetail)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.contact_first_name).to eq("Connect")
expect(model.contact_last_name).to eq("API")
expect(model.contact_phone).to eq("5558674309")
expect(model.contact_email).to eq("email@email.com")
expect(model.demo_account_name).to eq("username")
expect(model.demo_account_password).to eq("password")
expect(model.demo_account_required).to eq(true)
expect(model.notes).to eq("this is review notes")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/build_bundle_file_sizes_spec.rb | spaceship/spec/connect_api/models/build_bundle_file_sizes_spec.rb | describe Spaceship::ConnectAPI::BuildBundleFileSizes do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_build_bundles_build_bundle_file_sizes' do
response = Spaceship::ConnectAPI.get_build_bundles_build_bundle_file_sizes(build_bundle_id: '48a9bb1f-5f0f-4133-8c72-3fb93e92603a')
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(50)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BuildBundleFileSizes)
end
model = response.first
expect(model.id).to eq("82ee11de-a206-371c-8e4f-a79b9185c962")
expect(model.device_model).to eq("Universal")
expect(model.os_version).to eq("Universal")
expect(model.download_bytes).to eq(54_844_802)
expect(model.install_bytes).to eq(74_799_104)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/build_spec.rb | spaceship/spec/connect_api/models/build_spec.rb | describe Spaceship::ConnectAPI::Build do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_builds' do
response = Spaceship::ConnectAPI.get_builds
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::Build)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.version).to eq("225")
expect(model.uploaded_date).to eq("2019-04-30T17:16:21-07:00")
expect(model.expiration_date).to eq("2019-07-29T17:16:21-07:00")
expect(model.expired).to eq(false)
expect(model.min_os_version).to eq("10.3")
expect(model.icon_asset_token).to eq({
"templateUrl" => "https://is3-ssl.mzstatic.com/image/thumb/Purple/v4/97/f3/8a/97f38a96-38df-b4a0-8e93-cbb7c1f5ecd8/Icon-83.5@2x.png.png/{w}x{h}bb.{f}",
"width" => 167,
"height" => 167
})
expect(model.processing_state).to eq("VALID")
expect(model.uses_non_exempt_encryption).to eq(false)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/device_spec.rb | spaceship/spec/connect_api/models/device_spec.rb | describe Spaceship::ConnectAPI::Device do
include_examples "common spaceship login"
describe '#client' do
it '#get_devices' do
response = Spaceship::ConnectAPI.get_devices
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(3)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::Device)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.device_class).to eq("IPHONE")
expect(model.model).to eq("iPhone 8")
expect(model.name).to eq("Josh's iPhone")
expect(model.platform).to eq("IOS")
expect(model.status).to eq("ENABLED")
expect(model.udid).to eq("184098239048390489012849018")
expect(model.added_date).to eq("2018-10-10T01:43:27.000+0000")
expect(model.enabled?).to eq(true)
model.status = "DISABLED"
expect(model.enabled?).to eq(false)
end
it '#find_by_udid with an existing enabled udid' do
udid = "184098239048390489012849018"
existing_device = Spaceship::ConnectAPI::Device.find_by_udid(udid)
expect(existing_device.udid).to eq(udid)
end
it '#find_by_udid with missing udid because it is a disabled udid' do
disabled_udid = "5233342324433534345354534"
non_existing_device = Spaceship::ConnectAPI::Device.find_by_udid(disabled_udid, include_disabled: false)
expect(non_existing_device).to eq(nil)
end
it '#find_by_udid with non-existing udid' do
udid = "424242"
non_existing_device = Spaceship::ConnectAPI::Device.find_by_udid(udid)
expect(non_existing_device).to eq(nil)
end
it '#find_by_udid with an existing disabled udid with include_disabled parameter set to true' do
udid = "5233342324433534345354534"
existing_device = Spaceship::ConnectAPI::Device.find_by_udid(udid, include_disabled: true)
expect(existing_device.enabled?).to eq(false)
expect(existing_device.udid).to eq(udid)
end
it '#enable an existing disabled udid' do
udid = "5233342324433534345354534"
existing_device = Spaceship::ConnectAPI::Device.enable(udid)
expect(existing_device.enabled?).to eq(true)
expect(existing_device.udid).to eq(udid)
end
it '#disable an existing disabled udid' do
udid = "184098239048390489012849018"
existing_device = Spaceship::ConnectAPI::Device.disable(udid)
expect(existing_device.enabled?).to eq(false)
expect(existing_device.udid).to eq(udid)
end
it '#rename an existing disabled udid' do
udid = "5843758273957239847298374982"
new_name = "renamed device"
existing_device = Spaceship::ConnectAPI::Device.rename(udid, new_name)
expect(existing_device.name).to eq(new_name)
expect(existing_device.udid).to eq(udid)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/age_rating_declaration_spec.rb | spaceship/spec/connect_api/models/age_rating_declaration_spec.rb | describe Spaceship::ConnectAPI::AgeRatingDeclaration do
let(:from_itc) do
{
"MZGenre.CARTOON_FANTASY_VIOLENCE" => 0,
"REALISTIC_VIOLENCE" => 1,
"HORROR" => 2,
"UNRESTRICTED_WEB_ACCESS" => 1,
"profanityOrCrudeHumor" => "NONE"
}
end
let(:asc_1_2_false_gambling) do
{
"gamblingAndContests" => false
}
end
let(:asc_1_2_true_gambling) do
{
"gamblingAndContests" => true
}
end
describe "Helpers" do
describe "#map_deprecation_if_possible" do
it "successful migration of gamblingAndContests" do
hash, messages, errors = Spaceship::ConnectAPI::AgeRatingDeclaration.map_deprecation_if_possible(asc_1_2_false_gambling)
expect(hash).to eq({
"gambling" => false,
"contests" => "NONE"
})
expect(messages).to eq([
"Age Rating 'gamblingAndContests' has been deprecated and split into 'gambling' and 'contests'"
])
expect(errors).to eq([])
end
it "unsuccessful migration of gamblingAndContests" do
hash, messages, errors = Spaceship::ConnectAPI::AgeRatingDeclaration.map_deprecation_if_possible(asc_1_2_true_gambling)
expect(hash).to eq({
"gambling" => true,
"contests" => true
})
expect(messages).to eq([
"Age Rating 'gamblingAndContests' has been deprecated and split into 'gambling' and 'contests'"
])
expect(errors).to eq([
"'gamblingAndContests' could not be mapped to 'contests' - 'contests' requires a value of 'NONE', 'INFREQUENT_OR_MILD', or 'FREQUENT_OR_INTENSE'"
])
end
end
it "#map_key_from_itc" do
keys = from_itc.keys.map do |key|
Spaceship::ConnectAPI::AgeRatingDeclaration.map_key_from_itc(key)
end
expect(keys).to eq([
"violenceCartoonOrFantasy",
"violenceRealistic",
"horrorOrFearThemes",
"unrestrictedWebAccess",
"profanityOrCrudeHumor"
])
end
it "#map_value_from_itc" do
values = from_itc.map do |key, value|
key = Spaceship::ConnectAPI::AgeRatingDeclaration.map_key_from_itc(key)
Spaceship::ConnectAPI::AgeRatingDeclaration.map_value_from_itc(key, value)
end
expect(values).to eq([
"NONE",
"INFREQUENT_OR_MILD",
"FREQUENT_OR_INTENSE",
true,
"NONE"
])
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/review_submission_item_spec.rb | spaceship/spec/connect_api/models/review_submission_item_spec.rb | describe Spaceship::ConnectAPI::ReviewSubmissionItem do
let(:mock_tunes_client) { double('tunes_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
describe '#Spaceship::ConnectAPI' do
it '#get_review_submission_items' do
ConnectAPIStubbing::Tunes.stub_get_review_submission_items
response = Spaceship::ConnectAPI.get_review_submission_items(review_submission_id: "123456789")
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
model = response.first
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::ReviewSubmissionItem)
expect(model.id).to eq("123456789-item")
expect(model.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::READY_FOR_REVIEW)
expect(model.app_store_version.id).to eq("123456789-app-store-version")
expect(model.app_store_version_experiment).to be_nil
expect(model.app_store_product_page_version).to be_nil
expect(model.app_event).to be_nil
end
end
describe "ReviewSubmissionItem object" do
it 'gets all items for a review submission' do
ConnectAPIStubbing::Tunes.stub_get_review_submission_items
review_submission_items = Spaceship::ConnectAPI::ReviewSubmissionItem.all(review_submission_id: "123456789")
expect(review_submission_items.count).to eq(1)
expect(review_submission_items.first.id).to eq("123456789-item")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_app_review_submission_spec.rb | spaceship/spec/connect_api/models/beta_app_review_submission_spec.rb | describe Spaceship::ConnectAPI::BetaAppReviewSubmission do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_app_review_submissions' do
response = Spaceship::ConnectAPI.get_beta_app_review_submissions
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaAppReviewSubmission)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.beta_review_state).to eq("APPROVED")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/capabilities_spec.rb | spaceship/spec/connect_api/models/capabilities_spec.rb | describe Spaceship::ConnectAPI::Capabilities do
let(:mock_portal_client) { double('portal_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_portal_client).to receive(:team_id).and_return("123")
allow(mock_portal_client).to receive(:select_team)
allow(mock_portal_client).to receive(:csrf_tokens)
allow(Spaceship::PortalClient).to receive(:login).and_return(mock_portal_client)
Spaceship::ConnectAPI.login(username, password, use_portal: true, use_tunes: false)
end
describe '#client' do
it '#get_available_bundle_id_capabilities' do
response = Spaceship::ConnectAPI.get_available_bundle_id_capabilities(bundle_id_id: '123456789')
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::Capabilities)
end
model = response.first
expect(model.id).to eq("ACCESS_WIFI_INFORMATION")
expect(model.name).to eq("Access WiFi Information")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/bundle_id_spec.rb | spaceship/spec/connect_api/models/bundle_id_spec.rb | describe Spaceship::ConnectAPI::BundleId do
let(:mock_portal_client) { double('portal_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_portal_client).to receive(:team_id).and_return("123")
allow(mock_portal_client).to receive(:select_team)
allow(mock_portal_client).to receive(:csrf_tokens)
allow(Spaceship::PortalClient).to receive(:login).and_return(mock_portal_client)
Spaceship::ConnectAPI.login(username, password, use_portal: true, use_tunes: false)
end
describe '#client' do
it '#get_bundle_ids' do
response = Spaceship::ConnectAPI.get_bundle_ids
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BundleId)
end
model = response.first
expect(model.identifier).to eq("com.joshholtz.FastlaneApp")
expect(model.name).to eq("Fastlane App")
expect(model.seedId).to eq("972KS36P2U")
expect(model.platform).to eq("IOS")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_tester_metric_spec.rb | spaceship/spec/connect_api/models/beta_tester_metric_spec.rb | describe Spaceship::ConnectAPI::BetaTesterMetric do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_tester_metrics' do
response = Spaceship::ConnectAPI.get_beta_tester_metrics
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(3)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaTesterMetric)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.install_count).to eq(13)
expect(model.crash_count).to eq(0)
expect(model.session_count).to eq(319)
expect(model.beta_tester_state).to eq("INSTALLED")
expect(model.last_modified_date).to eq("2018-11-20T10:06:55-08:00")
expect(model.installed_cf_bundle_short_version_string).to eq("2.6.1")
expect(model.installed_cf_bundle_version).to eq("1542691006")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/build_beta_detail_spec.rb | spaceship/spec/connect_api/models/build_beta_detail_spec.rb | describe Spaceship::ConnectAPI::BuildBetaDetail do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_build_beta_details' do
response = Spaceship::ConnectAPI.get_build_beta_details
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BuildBetaDetail)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.auto_notify_enabled).to eq(false)
expect(model.did_notify).to eq(false)
expect(model.internal_build_state).to eq("IN_BETA_TESTING")
expect(model.external_build_state).to eq("READY_FOR_BETA_SUBMISSION")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/app_store_version_release_request_spec.rb | spaceship/spec/connect_api/models/app_store_version_release_request_spec.rb | describe Spaceship::ConnectAPI::AppStoreVersionReleaseRequest do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#post_app_store_version_release_request' do
response = Spaceship::ConnectAPI.post_app_store_version_release_request
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::AppStoreVersionReleaseRequest)
end
model = response.first
expect(model.id).to eq("123456789")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_group_spec.rb | spaceship/spec/connect_api/models/beta_group_spec.rb | describe Spaceship::ConnectAPI::BetaGroup do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_groups' do
response = Spaceship::ConnectAPI.get_beta_groups
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(3)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaGroup)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.name).to eq("App Store Connect Users")
expect(model.created_date).to eq("2018-04-15T18:13:40Z")
expect(model.is_internal_group).to eq(false)
expect(model.public_link_enabled).to eq(true)
expect(model.public_link_id).to eq("abcd1234")
expect(model.public_link_limit_enabled).to eq(true)
expect(model.public_link_limit).to eq(10)
expect(model.public_link).to eq("https://testflight.apple.com/join/abcd1234")
end
it '#delete!' do
response = Spaceship::ConnectAPI.get_beta_groups
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(3)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaGroup)
end
model = response.first
expect(model.id).to eq("123456789")
model.delete!
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/profile_spec.rb | spaceship/spec/connect_api/models/profile_spec.rb | describe Spaceship::ConnectAPI::Profile do
let(:mock_portal_client) { double('portal_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_portal_client).to receive(:team_id).and_return("123")
allow(mock_portal_client).to receive(:select_team)
allow(mock_portal_client).to receive(:csrf_tokens)
allow(Spaceship::PortalClient).to receive(:login).and_return(mock_portal_client)
Spaceship::ConnectAPI.login(username, password, use_portal: true, use_tunes: false)
end
describe '#client' do
it '#get_profiles' do
response = Spaceship::ConnectAPI.get_profiles
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::Profile)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.name).to eq("match AppStore com.joshholtz.FastlaneApp 1560136558")
expect(model.platform).to eq("IOS")
expect(model.profile_content).to eq("content")
expect(model.uuid).to eq("7ecd2cf1-3eb1-48b5-94e3-eb60eeaf5ad6")
expect(model.created_date).to eq("2019-06-10T03:15:58.000+0000")
expect(model.profile_state).to eq("ACTIVE")
expect(model.profile_type).to eq("IOS_APP_STORE")
expect(model.expiration_date).to eq("2020-05-01T15:18:38.000+0000")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/review_submission_spec.rb | spaceship/spec/connect_api/models/review_submission_spec.rb | describe Spaceship::ConnectAPI::ReviewSubmission do
let(:mock_tunes_client) { double('tunes_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
describe '#Spaceship::ConnectAPI' do
it '#get_review_submission' do
ConnectAPIStubbing::Tunes.stub_get_review_submission
response = Spaceship::ConnectAPI.get_review_submission(review_submission_id: "123456789")
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
model = response.first
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::ReviewSubmission)
expect(model.id).to eq("123456789")
expect(model.platform).to eq(Spaceship::ConnectAPI::Platform::IOS)
expect(model.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::READY_FOR_REVIEW)
expect(model.submitted_date).to be_nil
expect(model.app_store_version_for_review.id).to eq("123456789-app-store-version")
expect(model.items.count).to eq(1)
expect(model.items.first.id).to eq("123456789-item")
expect(model.last_updated_by_actor).to be_nil
expect(model.submitted_by_actor).to be_nil
end
it '#patch_review_submission' do
ConnectAPIStubbing::Tunes.stub_submit_review_submission
response = Spaceship::ConnectAPI.patch_review_submission(review_submission_id: "123456789", attributes: { submitted: true })
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
model = response.first
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::ReviewSubmission)
expect(model.id).to eq("123456789")
expect(model.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::WAITING_FOR_REVIEW)
end
it '#post_review_submission_item' do
ConnectAPIStubbing::Tunes.stub_create_review_submission_item
response = Spaceship::ConnectAPI.post_review_submission_item(review_submission_id: "123456789", app_store_version_id: "123456789-app-store-version")
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
model = response.first
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::ReviewSubmissionItem)
expect(model.id).to eq("123456789-item")
expect(model.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::READY_FOR_REVIEW)
end
end
describe "ReviewSubmission object" do
it 'gets review submission' do
ConnectAPIStubbing::Tunes.stub_get_review_submission
review_submission = Spaceship::ConnectAPI::ReviewSubmission.get(review_submission_id: "123456789")
expect(review_submission.id).to eq("123456789")
end
it 'submits the submission for review' do
ConnectAPIStubbing::Tunes.stub_submit_review_submission
review_submission = Spaceship::ConnectAPI::ReviewSubmission.new("123456789", [])
updated_review_submission = review_submission.submit_for_review
expect(updated_review_submission.id).to eq("123456789")
expect(updated_review_submission.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::WAITING_FOR_REVIEW)
end
it 'cancels the submission for review' do
ConnectAPIStubbing::Tunes.stub_cancel_review_submission
review_submission = Spaceship::ConnectAPI::ReviewSubmission.new("123456789", [])
updated_review_submission = review_submission.cancel_submission
expect(updated_review_submission.id).to eq("123456789")
expect(updated_review_submission.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::CANCELING)
end
it 'adds an app store version to the submission items' do
ConnectAPIStubbing::Tunes.stub_create_review_submission_item
review_submission = Spaceship::ConnectAPI::ReviewSubmission.new("123456789", [])
review_submission_item = review_submission.add_app_store_version_to_review_items(app_store_version_id: "123456789-app-store-version")
expect(review_submission_item.id).to eq("123456789-item")
expect(review_submission_item.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::READY_FOR_REVIEW)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_tester_spec.rb | spaceship/spec/connect_api/models/beta_tester_spec.rb | describe Spaceship::ConnectAPI::BetaTester do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_testers' do
response = Spaceship::ConnectAPI.get_beta_testers
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaTester)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.first_name).to eq("Cats")
expect(model.last_name).to eq("AreCute")
expect(model.email).to eq("email@email.com")
expect(model.invite_type).to eq("EMAIL")
expect(model.beta_tester_state).to eq("INSTALLED")
expect(model.is_deleted).to eq(false)
expect(model.last_modified_date).to eq("2024-01-21T20:52:18.921-08:00")
expect(model.installed_cf_bundle_short_version_string).to eq("1.3.300")
expect(model.installed_cf_bundle_version).to eq("1113")
expect(model.remove_after_date).to eq("2024-04-20T00:00:00-07:00")
expect(model.installed_device).to eq("iPhone14_7")
expect(model.installed_os_version).to eq("17.2.1")
expect(model.number_of_installed_devices).to eq(1.0)
expect(model.latest_expiring_cf_bundle_short_version_string).to eq("1.3.300")
expect(model.latest_expiring_cf_bundle_version_string).to eq("1113")
expect(model.installed_device_platform).to eq("IOS")
expect(model.latest_installed_device).to eq("iPhone14_7")
expect(model.latest_installed_os_version).to eq("17.2.1")
expect(model.latest_installed_device_platform).to eq("IOS")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/app_store_version_spec.rb | spaceship/spec/connect_api/models/app_store_version_spec.rb | describe Spaceship::ConnectAPI::AppStoreVersion do
include_examples "common spaceship login"
describe "AppStoreVersion object" do
describe "reverse maps attributes" do
let(:app_store_version) { Spaceship::ConnectAPI::AppStoreVersion.new('id', {}) }
let(:attribute_attributes) do
{
contact_first_name: "",
contact_last_name: "",
contact_phone: "",
contact_email: "",
demo_account_name: "",
demo_account_password: "",
demo_account_required: "",
notes: ""
}
end
it "maps attributes names to API names" do
resp = double
allow(resp).to receive(:to_models).and_return([])
expect(Spaceship::ConnectAPI).to receive(:post_app_store_review_detail).with(app_store_version_id: 'id', attributes: {
"contactFirstName" => "",
"contactLastName" => "",
"contactPhone" => "",
"contactEmail" => "",
"demoAccountName" => "",
"demoAccountPassword" => "",
"demoAccountRequired" => "",
"notes" => ""
}).and_return(resp)
app_store_version.create_app_store_review_detail(attributes: attribute_attributes)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/certificate_spec.rb | spaceship/spec/connect_api/models/certificate_spec.rb | describe Spaceship::ConnectAPI::Certificate do
include_examples "common spaceship login"
describe '#client' do
it '#get_certificates' do
response = Spaceship::ConnectAPI.get_certificates
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(5)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::Certificate)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.certificate_content).to eq("content")
expect(model.display_name).to eq("Josh Holtz")
expect(model.name).to eq("iOS Development: Josh Holtz")
expect(model.platform).to eq("IOS")
expect(model.serial_number).to eq("F5A44933E05F97D")
expect(model.certificate_type).to eq("IOS_DEVELOPMENT")
expect(model.requester_email).to eq("email@email.com")
expect(model.requester_first_name).to eq("Josh")
expect(model.requester_last_name).to eq("Holtz")
end
let!(:default_parameters) do
{
fields: nil,
filter: nil,
includes: nil,
limit: Spaceship::ConnectAPI::MAX_OBJECTS_PER_PAGE_LIMIT,
sort: nil
}
end
it '#get_certificates with unsupported certificate types' do
certificate_type = Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPER_ID_APPLICATION_G2
# Will fetch all certificates w/o filtering by certificate type
parameters = default_parameters.merge(filter: {})
allow(Spaceship::ConnectAPI).to receive(:get_certificates).with(parameters).and_call_original
response = Spaceship::ConnectAPI::Certificate.all(filter: { certificateType: [certificate_type] })
# But will filter by certificate in the response
expect(response.count).to eq(1)
model = response.first
expect(model.id).to eq("777888999")
expect(model.certificate_content).to eq("content")
expect(model.display_name).to eq("Josh Holtz")
expect(model.name).to eq("Developer ID Application (G2): Josh Holtz")
expect(model.platform).to eq("MAC_OS_X")
expect(model.serial_number).to eq("6FF0AA8635503A3D")
expect(model.certificate_type).to eq("DEVELOPER_ID_APPLICATION_G2")
expect(model.requester_email).to eq("email@email.com")
expect(model.requester_first_name).to eq("Josh")
end
it '#get_certificates with a supported certificate type' do
certificate_type = Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
# Will pass filter to Spaceship::ConnectAPI
parameters = default_parameters.merge(filter: { certificateType: [certificate_type] })
allow(Spaceship::ConnectAPI).to receive(:get_certificates).with(parameters).and_call_original
response = Spaceship::ConnectAPI::Certificate.all(filter: { certificateType: [certificate_type] })
# Spaceship::ConnectAPI is stubbed, thus filter is ignored and all certificates are returned
expect(response.count).to eq(5)
end
end
describe '#valid?' do
let!(:certificate) do
certificates_response = JSON.parse(File.read(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'provisioning', 'certificates.json')))
model = Spaceship::ConnectAPI::Models.parse(certificates_response).first
end
context 'with past expiration_date' do
before { certificate.expiration_date = "1999-02-01T20:50:34.000+0000" }
it 'should be invalid' do
expect(certificate.valid?).to eq(false)
end
end
context 'with a future expiration_date' do
before { certificate.expiration_date = "9999-02-01T20:50:34.000+0000" }
it 'should be valid' do
expect(certificate.valid?).to eq(true)
end
end
context 'when expiration_date is nil' do
before { certificate.expiration_date = nil }
it 'should be invalid' do
expect(certificate.valid?).to eq(false)
end
end
context 'when expiration_date is an empty string' do
before { certificate.expiration_date = "" }
it 'should be invalid' do
expect(certificate.valid?).to eq(false)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/app_spec.rb | spaceship/spec/connect_api/models/app_spec.rb | describe Spaceship::ConnectAPI::App do
let(:mock_tunes_client) { double('tunes_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
describe '#Spaceship::ConnectAPI' do
it '#get_apps' do
response = Spaceship::ConnectAPI.get_apps
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(5)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::App)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.name).to eq("FastlaneTest")
expect(model.bundle_id).to eq("com.joshholtz.FastlaneTest")
expect(model.sku).to eq("SKU_SKU_SKU_SKU")
expect(model.primary_locale).to eq("en-US")
expect(model.removed).to eq(false)
expect(model.is_aag).to eq(false)
end
it 'gets by app id' do
response = Spaceship::ConnectAPI.get_app(app_id: "123456789")
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::App)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.bundle_id).to eq("com.joshholtz.FastlaneTest")
end
it '#get_review_submissions' do
ConnectAPIStubbing::Tunes.stub_get_review_submissions
response = Spaceship::ConnectAPI.get_review_submissions(app_id: "123456789-app")
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::ReviewSubmission)
end
model = response.first
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::ReviewSubmission)
expect(model.id).to eq("123456789")
expect(model.platform).to eq(Spaceship::ConnectAPI::Platform::IOS)
expect(model.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::READY_FOR_REVIEW)
expect(model.submitted_date).to be_nil
end
it '#post_review_submission' do
ConnectAPIStubbing::Tunes.stub_create_review_submission
response = Spaceship::ConnectAPI.post_review_submission(app_id: "123456789-app", platform: Spaceship::ConnectAPI::Platform::IOS)
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
model = response.first
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::ReviewSubmission)
expect(model.id).to eq("123456789")
expect(model.platform).to eq(Spaceship::ConnectAPI::Platform::IOS)
expect(model.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::READY_FOR_REVIEW)
end
end
describe "App object" do
it 'finds app by bundle id' do
model = Spaceship::ConnectAPI::App.find("com.joshholtz.FastlaneTest")
expect(model.bundle_id).to eq("com.joshholtz.FastlaneTest")
end
it('fetches live app info') do
ConnectAPIStubbing::Tunes.stub_get_app_infos
app = Spaceship::ConnectAPI::App.new("123456789", [])
info = app.fetch_live_app_info(includes: nil)
expect(info.id).to eq("1111-11111")
expect(info.app_store_age_rating).to eq("FOUR_PLUS")
expect(info.app_store_state).to eq("READY_FOR_SALE")
expect(info.state).to eq("READY_FOR_DISTRIBUTION")
end
it('fetches edit app info') do
ConnectAPIStubbing::Tunes.stub_get_app_infos
app = Spaceship::ConnectAPI::App.new("123456789", [])
info = app.fetch_edit_app_info(includes: nil)
expect(info.id).to eq("1111-2222")
expect(info.app_store_age_rating).to eq("FOUR_PLUS")
expect(info.app_store_state).to eq("PREPARE_FOR_SUBMISSION")
expect(info.state).to eq("PREPARE_FOR_SUBMISSION")
end
it 'creates beta group' do
app = Spaceship::ConnectAPI::App.find("com.joshholtz.FastlaneTest")
model = app.create_beta_group(group_name: "Brand New Group", public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false)
expect(model.id).to eq("123456789")
expect(model.is_internal_group).to eq(false)
expect(model.has_access_to_all_builds).to be_nil
# `has_access_to_all_builds` is ignored for external groups
model = app.create_beta_group(group_name: "Brand New Group", public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false, has_access_to_all_builds: true)
expect(model.id).to eq("123456789")
expect(model.is_internal_group).to eq(false)
expect(model.has_access_to_all_builds).to be_nil
# `has_access_to_all_builds` is set to `true` by default for internal groups
model = app.create_beta_group(group_name: "Brand New Group", is_internal_group: true, public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false)
expect(model.id).to eq("123456789")
expect(model.is_internal_group).to eq(true)
expect(model.has_access_to_all_builds).to eq(true)
# `has_access_to_all_builds` can be set to `false` for internal groups
model = app.create_beta_group(group_name: "Brand New Group", is_internal_group: true, public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false, has_access_to_all_builds: false)
expect(model.id).to eq("123456789")
expect(model.is_internal_group).to eq(true)
expect(model.has_access_to_all_builds).to eq(false)
end
it '#get_review_submissions' do
ConnectAPIStubbing::Tunes.stub_get_review_submissions
app = Spaceship::ConnectAPI::App.new("123456789-app", [])
review_submissions = app.get_review_submissions
expect(review_submissions.count).to eq(2)
expect(review_submissions.first.id).to eq("123456789")
end
it '#create_review_submission' do
ConnectAPIStubbing::Tunes.stub_create_review_submission
app = Spaceship::ConnectAPI::App.new("123456789-app", [])
review_submission = app.create_review_submission(platform: Spaceship::ConnectAPI::Platform::IOS)
expect(review_submission.id).to eq("123456789")
expect(review_submission.platform).to eq(Spaceship::ConnectAPI::Platform::IOS)
expect(review_submission.state).to eq(Spaceship::ConnectAPI::ReviewSubmission::ReviewSubmissionState::READY_FOR_REVIEW)
end
end
describe("#get_app_availabilities") do
it('gets app availabilities when app is ready for distribution') do
ConnectAPIStubbing::Tunes.stub_get_app_availabilities_ready_for_distribution
app = Spaceship::ConnectAPI::App.new("123456789", [])
availabilities = app.get_app_availabilities
expect(availabilities.availableInNewTerritories).to be(false)
expect(availabilities.territory_availabilities.count).to eq(2)
expect(availabilities.territory_availabilities[0].available).to be(true)
expect(availabilities.territory_availabilities[1].available).to be(true)
expect(availabilities.territory_availabilities[0].contentStatuses).to eq(["AVAILABLE"])
expect(availabilities.territory_availabilities[1].contentStatuses).to eq(["AVAILABLE"])
end
it('gets app availabilities when app is removed from sale') do
ConnectAPIStubbing::Tunes.stub_get_app_availabilities_removed_from_sale
app = Spaceship::ConnectAPI::App.new("123456789", [])
availabilities = app.get_app_availabilities
expect(availabilities.availableInNewTerritories).to be(false)
expect(availabilities.territory_availabilities.count).to eq(2)
expect(availabilities.territory_availabilities[0].available).to be(false)
expect(availabilities.territory_availabilities[1].available).to be(false)
expect(availabilities.territory_availabilities[0].contentStatuses).to eq(["CANNOT_SELL"])
expect(availabilities.territory_availabilities[1].contentStatuses).to eq(["CANNOT_SELL"])
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/bundle_id_capability_spec.rb | spaceship/spec/connect_api/models/bundle_id_capability_spec.rb | describe Spaceship::ConnectAPI::BundleIdCapability do
let(:mock_portal_client) { double('portal_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_portal_client).to receive(:team_id).and_return("123")
allow(mock_portal_client).to receive(:select_team)
allow(mock_portal_client).to receive(:csrf_tokens)
allow(Spaceship::PortalClient).to receive(:login).and_return(mock_portal_client)
Spaceship::ConnectAPI.login(username, password, use_portal: true, use_tunes: false)
end
describe '#client' do
it 'through #get_bundle_id' do
response = Spaceship::ConnectAPI.get_bundle_id(bundle_id_id: '123456789')
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.first).to be_an_instance_of(Spaceship::ConnectAPI::BundleId)
bundle_id_capabilities = response.first.bundle_id_capabilities
expect(bundle_id_capabilities.count).to eq(2)
bundle_id_capabilities.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BundleIdCapability)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_build_localization_spec.rb | spaceship/spec/connect_api/models/beta_build_localization_spec.rb | describe Spaceship::ConnectAPI::BetaBuildLocalization do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_build_localizations' do
response = Spaceship::ConnectAPI.get_beta_build_localizations
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaBuildLocalization)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.whats_new).to eq("so many en-us things2")
expect(model.locale).to eq("en-US")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_build_metric_spec.rb | spaceship/spec/connect_api/models/beta_build_metric_spec.rb | describe Spaceship::ConnectAPI::BetaBuildMetric do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_build_metrics' do
response = Spaceship::ConnectAPI.get_beta_build_metrics
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaBuildMetric)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.install_count).to eq(1)
expect(model.crash_count).to eq(2)
expect(model.invite_count).to eq(3)
expect(model.seven_day_tester_count).to eq(4)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_app_localizations_spec.rb | spaceship/spec/connect_api/models/beta_app_localizations_spec.rb | describe Spaceship::ConnectAPI::BetaAppLocalization do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it 'succeeds with object' do
response = Spaceship::ConnectAPI.get_beta_app_localizations
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaAppLocalization)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.feedback_email).to eq("email@email.com")
expect(model.marketing_url).to eq("https://fastlane.tools/marketing")
expect(model.privacy_policy_url).to eq("https://fastlane.tools/policy")
expect(model.tv_os_privacy_policy).to eq(nil)
expect(model.description).to eq("This is a description of my app")
expect(model.locale).to eq("en-US")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/build_delivery_spec.rb | spaceship/spec/connect_api/models/build_delivery_spec.rb | describe Spaceship::ConnectAPI::BuildDelivery do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_build_deliveries' do
response = Spaceship::ConnectAPI.get_build_deliveries(app_id: "1234")
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BuildDelivery)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.cf_build_version).to eq("225")
expect(model.cf_build_short_version_string).to eq("1.1")
expect(model.platform).to eq("IOS")
expect(model.uploaded_date).to eq("2019-05-06T20:14:37-07:00")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/user_spec.rb | spaceship/spec/connect_api/models/user_spec.rb | describe Spaceship::ConnectAPI::User do
let(:mock_tunes_client) { double('tunes_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
describe '#Spaceship::ConnectAPI' do
it '#get_users' do
response = Spaceship::ConnectAPI.get_users
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::User)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.username).to eq("pizza@email.com")
expect(model.first_name).to eq("Cheese")
expect(model.last_name).to eq("Pizza")
expect(model.email).to eq("pizza@email.com")
expect(model.preferred_currency_territory).to eq("USD_USA")
expect(model.agreed_to_terms).to eq(true)
expect(model.roles).to eq(["ADMIN"])
expect(model.all_apps_visible).to eq(true)
expect(model.provisioning_allowed).to eq(true)
expect(model.email_vetting_required).to eq(false)
expect(model.notifications).to eq({})
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/beta_feedback_spec.rb | spaceship/spec/connect_api/models/beta_feedback_spec.rb | describe Spaceship::ConnectAPI::BetaFeedback do
include_examples "common spaceship login"
describe '#Spaceship::ConnectAPI' do
it '#get_beta_feedback' do
response = Spaceship::ConnectAPI.get_beta_feedback
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(1)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::BetaFeedback)
end
model = response.first
expect(model.id).to eq("987654321")
expect(model.timestamp).to eq("2019-12-11T02:03:27.661Z")
expect(model.comment).to eq("Oohhhhh feedback!!!!")
expect(model.email_address).to eq("email@email.com")
expect(model.device_model).to eq("iPhone11_2")
expect(model.os_version).to eq("13.2.3")
expect(model.bookmarked).to eq(false)
expect(model.locale).to eq("en-US")
expect(model.carrier).to eq("T-Mobile")
expect(model.timezone).to eq("America/Chicago")
expect(model.architecture).to eq("arm64e")
expect(model.connection_status).to eq("WIFI")
expect(model.paired_apple_watch).to eq(nil)
expect(model.app_up_time_millis).to eq(nil)
expect(model.available_disk_bytes).to eq("13388951552")
expect(model.total_disk_bytes).to eq("63937040384")
expect(model.network_type).to eq("LTE")
expect(model.battery_percentage).to eq(83)
expect(model.screen_width).to eq(375)
expect(model.screen_height).to eq(812)
expect(model.build).to_not(eq(nil))
expect(model.build.version).to eq("1571678363")
expect(model.tester).to_not(eq(nil))
expect(model.tester.first_name).to eq("Josh")
expect(model.screenshots.size).to eq(1)
expect(model.screenshots.first.image_assets.size).to eq(4)
expect(model.screenshots.first.image_assets.first["url"]).to eq("https://tf-feedback.itunes.apple.com/eimg/D_g/HQ8/C4k/CPY/Ezw/ultR3bzSGG0/original.jpg?i_for=974055077&AWSAccessKeyId=MKIA9C0TVRX1ZL0VZ1YK&Expires=1576454400&Signature=NtYpXsRVKPeQNpg7eLh2xKFnmF4%3D&p_sig=8DAxqgHRlxMlhbl_LKW5EDAIAwo")
expect(model.screenshots.first.image_assets.first["width"]).to eq(3024)
expect(model.screenshots.first.image_assets.first["height"]).to eq(4032)
end
end
it "deletes a feedback" do
response = Spaceship::ConnectAPI.get_beta_feedback
feedback = response.first
expect(Spaceship::ConnectAPI).to receive(:delete_beta_feedback).with(feedback_id: feedback.id)
feedback.delete!
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/models/pre_release_version_spec.rb | spaceship/spec/connect_api/models/pre_release_version_spec.rb | describe Spaceship::ConnectAPI::PreReleaseVersion do
let(:mock_tunes_client) { double('tunes_client') }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
describe '#Spaceship::ConnectAPI' do
it '#get_pre_release_versions' do
response = Spaceship::ConnectAPI.get_pre_release_versions
expect(response).to be_an_instance_of(Spaceship::ConnectAPI::Response)
expect(response.count).to eq(2)
response.each do |model|
expect(model).to be_an_instance_of(Spaceship::ConnectAPI::PreReleaseVersion)
end
model = response.first
expect(model.id).to eq("123456789")
expect(model.version).to eq("3.3.3")
expect(model.platform).to eq("IOS")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/testflight/testflight_stubbing.rb | spaceship/spec/connect_api/testflight/testflight_stubbing.rb | class ConnectAPIStubbing
class TestFlight
class << self
def read_fixture_file(filename)
File.read(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'testflight', filename))
end
def read_binary_fixture_file(filename)
File.binread(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'testflight', filename))
end
# Necessary, as we're now running this in a different context
def stub_request(*args)
WebMock::API.stub_request(*args)
end
def stub_apps
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps").
to_return(status: 200, body: read_fixture_file('apps.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps?include=appStoreVersions").
to_return(status: 200, body: read_fixture_file('apps.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps?filter%5BbundleId%5D=com.joshholtz.FastlaneTest&include=appStoreVersions").
to_return(status: 200, body: read_fixture_file('apps.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps/123456789").
to_return(status: 200, body: read_fixture_file('app.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_app_localizations
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaAppLocalizations").
to_return(status: 200, body: read_fixture_file('beta_app_localizations.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_app_review_details
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaAppReviewDetails").
to_return(status: 200, body: read_fixture_file('beta_app_review_details.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_app_review_submissions
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaAppReviewSubmissions").
to_return(status: 200, body: read_fixture_file('beta_app_review_submissions.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_build_localizations
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaBuildLocalizations").
to_return(status: 200, body: read_fixture_file('beta_build_localizations.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_build_metrics
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaBuildMetrics").
to_return(status: 200, body: read_fixture_file('beta_build_metrics.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_feedbacks
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaFeedbacks").
to_return(status: 200, body: read_fixture_file('beta_feedbacks.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_feedbacks_delete
stub_request(:delete, "https://appstoreconnect.apple.com/iris/v1/betaFeedbacks/987654321").
to_return(status: 200, body: "", headers: {})
end
def stub_beta_groups
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaGroups").
to_return(status: 200, body: read_fixture_file('beta_groups.json'), headers: { 'Content-Type' => 'application/json' })
created_beta_group = JSON.parse(read_fixture_file('beta_create_group.json'))
stub_request(:post, "https://appstoreconnect.apple.com/iris/v1/betaGroups").
to_return { |request|
request_body = JSON.parse(request.body)
response_body = created_beta_group.dup
%w{isInternalGroup hasAccessToAllBuilds}.each do |attribute|
response_body["data"]["attributes"][attribute] = request_body["data"]["attributes"][attribute]
end
{ status: 200, body: JSON.dump(response_body), headers: { 'Content-Type' => 'application/json' } }
}
stub_request(:delete, "https://appstoreconnect.apple.com/iris/v1/betaGroups/123456789").
to_return(status: 200, body: "", headers: {})
end
def stub_beta_testers
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaTesters").
to_return(status: 200, body: read_fixture_file('beta_testers.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_beta_tester_metrics
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/betaTesterMetrics").
to_return(status: 200, body: read_fixture_file('beta_tester_metrics.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_build_beta_details
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/buildBetaDetails").
to_return(status: 200, body: read_fixture_file('build_beta_details.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_build_bundles
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/buildBundles/48a9bb1f-5f0f-4133-8c72-3fb93e92603a/buildBundleFileSizes").
to_return(status: 200, body: read_fixture_file('build_bundles_build_bundle_file_sizes.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_build_deliveries
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/apps/1234/buildDeliveries").
to_return(status: 200, body: read_fixture_file('build_deliveries.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_builds
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/builds?include=buildBetaDetail,betaBuildMetrics&limit=10&sort=uploadedDate").
to_return(status: 200, body: read_fixture_file('builds.json'), headers: { 'Content-Type' => 'application/json' })
end
def stub_pre_release_versions
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/preReleaseVersions").
to_return(status: 200, body: read_fixture_file('pre_release_versions.json'), headers: { 'Content-Type' => 'application/json' })
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/testflight/testflight_client_spec.rb | spaceship/spec/connect_api/testflight/testflight_client_spec.rb | describe Spaceship::ConnectAPI::TestFlight::Client do
let(:mock_tunes_client) { double('tunes_client') }
let(:client) { Spaceship::ConnectAPI::TestFlight::Client.new(another_client: mock_tunes_client) }
let(:hostname) { Spaceship::ConnectAPI::TestFlight::Client.hostname }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
context 'sends api request' do
before(:each) do
allow(client).to receive(:handle_response)
end
def test_request_params(url, params)
req_mock = double
options_mock = double
allow(req_mock).to receive(:headers).and_return({})
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:params=).with(params)
expect(req_mock).to receive(:options).and_return(options_mock)
expect(options_mock).to receive(:params_encoder=).with(Faraday::NestedParamsEncoder)
allow(req_mock).to receive(:status)
return req_mock
end
def test_request_body(url, body)
req_mock = double
header_mock = double
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:body=).with(JSON.generate(body))
expect(req_mock).to receive(:headers).and_return(header_mock)
expect(header_mock).to receive(:[]=).with("Content-Type", "application/json")
allow(req_mock).to receive(:status)
return req_mock
end
describe "apps" do
context 'get_apps' do
let(:path) { "v1/apps" }
let(:bundle_id) { "com.bundle.id" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_apps
end
it 'succeeds with filter' do
params = { filter: { bundleId: bundle_id } }
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_apps(filter: { bundleId: bundle_id })
end
end
context 'get_app' do
let(:app_id) { "123456789" }
let(:path) { "v1/apps/#{app_id}" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_app(app_id: app_id)
end
end
end
describe "betaAppLocalizations" do
context 'get_beta_app_localizations' do
let(:path) { "v1/betaAppLocalizations" }
let(:app_id) { "123" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_app_localizations
end
it 'succeeds with filter' do
params = { filter: { app: app_id } }
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_app_localizations(**params)
end
end
context 'post_beta_app_localizations' do
let(:path) { "v1/betaAppLocalizations" }
let(:app_id) { "123" }
let(:attributes) { { key: "value" } }
let(:body) do
{
data: {
attributes: attributes,
type: "betaAppLocalizations",
relationships: {
app: {
data: {
type: "apps",
id: app_id
}
}
}
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_beta_app_localizations(app_id: app_id, attributes: attributes)
end
end
context 'patch_beta_app_localizations' do
let(:path) { "v1/betaAppLocalizations" }
let(:localization_id) { "123" }
let(:attributes) { { key: "value" } }
let(:body) do
{
data: {
attributes: attributes,
id: localization_id,
type: "betaAppLocalizations"
}
}
end
it 'succeeds' do
url = "#{path}/#{localization_id}"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_beta_app_localizations(localization_id: localization_id, attributes: attributes)
end
end
end
describe "betaAppReviewDetails" do
context 'get_beta_app_review_detail' do
let(:path) { "v1/betaAppReviewDetails" }
let(:app_id) { "123" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_app_review_detail
end
it 'succeeds with filter' do
params = { filter: { app: app_id } }
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_app_review_detail(filter: { app: app_id })
end
end
context 'patch_beta_app_review_detail' do
let(:path) { "v1/betaAppReviewDetails" }
let(:app_id) { "123" }
let(:attributes) { { key: "value" } }
let(:body) do
{
data: {
attributes: attributes,
id: app_id,
type: "betaAppReviewDetails"
}
}
end
it 'succeeds' do
url = "#{path}/#{app_id}"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_beta_app_review_detail(app_id: app_id, attributes: attributes)
end
end
end
describe "betaAppReviewSubmissions" do
context 'get_beta_app_review_submissions' do
let(:path) { "v1/betaAppReviewSubmissions" }
let(:app_id) { "123" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_app_review_submissions
end
it 'succeeds with filter' do
params = { filter: { app: app_id } }
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_app_review_submissions(filter: { app: app_id })
end
end
context 'post_beta_app_review_submissions' do
let(:path) { "v1/betaAppReviewSubmissions" }
let(:build_id) { "123" }
let(:body) do
{
data: {
type: "betaAppReviewSubmissions",
relationships: {
build: {
data: {
type: "builds",
id: build_id
}
}
}
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_beta_app_review_submissions(build_id: build_id)
end
end
context 'delete_beta_app_review_submission' do
let(:beta_app_review_submission_id) { "123" }
let(:path) { "v1/betaAppReviewSubmissions/#{beta_app_review_submission_id}" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_beta_app_review_submission(beta_app_review_submission_id: beta_app_review_submission_id)
end
end
end
describe "betaBuildLocalizations" do
context 'get_beta_build_localizations' do
let(:path) { "v1/betaBuildLocalizations" }
let(:build_id) { "123" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_build_localizations
end
it 'succeeds with filter' do
params = { filter: { build: build_id } }
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_build_localizations(**params)
end
end
context 'post_beta_build_localizations' do
let(:path) { "v1/betaBuildLocalizations" }
let(:build_id) { "123" }
let(:attributes) { { key: "value" } }
let(:body) do
{
data: {
attributes: attributes,
type: "betaBuildLocalizations",
relationships: {
build: {
data: {
type: "builds",
id: build_id
}
}
}
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_beta_build_localizations(build_id: build_id, attributes: attributes)
end
end
context 'patch_beta_build_localizations' do
let(:path) { "v1/betaBuildLocalizations" }
let(:localization_id) { "123" }
let(:attributes) { { key: "value" } }
let(:body) do
{
data: {
attributes: attributes,
id: localization_id,
type: "betaBuildLocalizations"
}
}
end
it 'succeeds' do
url = "#{path}/#{localization_id}"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_beta_build_localizations(localization_id: localization_id, attributes: attributes)
end
end
end
describe "betaFeedbacks" do
context 'get_beta_feedbacks' do
let(:path) { "v1/betaFeedbacks" }
let(:app_id) { "123456789" }
let(:default_params) { {} }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_feedback
end
it 'succeeds with filter' do
params = { filter: { "build.app" => app_id } }
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_feedback(**params)
end
end
end
describe "betaGroups" do
context 'get_beta_groups' do
let(:path) { "v1/betaGroups" }
let(:name) { "sir group a lot" }
let(:default_params) { {} }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_groups
end
it 'succeeds with filter' do
params = { filter: { name: name } }
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_groups(**params)
end
end
context 'add_beta_groups_to_build' do
let(:path) { "v1/builds" }
let(:build_id) { "123" }
let(:beta_group_ids) { ["123", "456"] }
let(:body) do
{
data: beta_group_ids.map do |id|
{
type: "betaGroups",
id: id
}
end
}
end
it 'succeeds' do
url = "#{path}/#{build_id}/relationships/betaGroups"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.add_beta_groups_to_build(build_id: build_id, beta_group_ids: beta_group_ids)
end
end
context 'delete_beta_groups_from_build' do
let(:path) { "v1/builds" }
let(:build_id) { "123" }
let(:beta_group_ids) { ["123", "456"] }
let(:body) do
{
data: beta_group_ids.map do |id|
{
type: "betaGroups",
id: id
}
end
}
end
it 'succeeds' do
url = "#{path}/#{build_id}/relationships/betaGroups"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_beta_groups_from_build(build_id: build_id, beta_group_ids: beta_group_ids)
end
end
context 'patch_beta_groups' do
let(:path) { "v1/betaGroups" }
let(:beta_group_id) { "123" }
let(:attributes) { { public_link_enabled: false } }
let(:body) do
{
data: {
attributes: attributes,
id: beta_group_id,
type: "betaGroups"
}
}
end
it 'succeeds' do
url = "#{path}/#{beta_group_id}"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_group(group_id: beta_group_id, attributes: attributes)
end
end
end
describe "betaTesters" do
context 'get_beta_testers' do
let(:path) { "v1/betaTesters" }
let(:app_id) { "123" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_testers
end
it 'succeeds with filter' do
params = { filter: { app: app_id } }
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_beta_testers(**params)
end
end
context 'post_bulk_beta_tester_assignments' do
let(:path) { "v1/bulkBetaTesterAssignments" }
let(:beta_group_id) { "123" }
let(:beta_testers) do
[
{ email: "email1", firstName: "first1", lastName: "last1", errors: [] },
{ email: "email2", firstName: "first2", lastName: "last2", errors: [] }
]
end
let(:body) do
{
data: {
attributes: {
betaTesters: beta_testers
},
relationships: {
betaGroup: {
data: {
type: "betaGroups",
id: beta_group_id
}
}
},
type: "bulkBetaTesterAssignments"
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_bulk_beta_tester_assignments(beta_group_id: beta_group_id, beta_testers: beta_testers)
end
end
context 'post_beta_tester_assignment' do
let(:path) { "v1/betaTesters" }
let(:beta_group_ids) { ["123", "456"] }
let(:attributes) { { email: "email1", firstName: "first1", lastName: "last1" } }
let(:body) do
{
data: {
attributes: attributes,
relationships: {
betaGroups: {
data: beta_group_ids.map do |id|
{
type: "betaGroups",
id: id
}
end
}
},
type: "betaTesters"
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_beta_tester_assignment(beta_group_ids: beta_group_ids, attributes: attributes)
end
end
context "add_beta_tester_to_group" do
let(:beta_group_id) { "123" }
let(:beta_tester_ids) { ["1234", "5678"] }
let(:path) { "v1/betaGroups/#{beta_group_id}/relationships/betaTesters" }
let(:body) do
{
data: beta_tester_ids.map do |id|
{
type: "betaTesters",
id: id
}
end
}
end
it "succeeds" do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.add_beta_tester_to_group(beta_group_id: beta_group_id, beta_tester_ids: beta_tester_ids)
end
end
context 'delete_beta_tester_from_apps' do
let(:beta_tester_id) { "123" }
let(:app_ids) { ["1234", "5678"] }
let(:path) { "v1/betaTesters/#{beta_tester_id}/relationships/apps" }
let(:body) do
{
data: app_ids.map do |id|
{
type: "apps",
id: id
}
end
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_beta_tester_from_apps(beta_tester_id: beta_tester_id, app_ids: app_ids)
end
end
context 'delete_beta_tester_from_beta_groups' do
let(:beta_tester_id) { "123" }
let(:beta_group_ids) { ["1234", "5678"] }
let(:path) { "v1/betaTesters/#{beta_tester_id}/relationships/betaGroups" }
let(:body) do
{
data: beta_group_ids.map do |id|
{
type: "betaGroups",
id: id
}
end
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_beta_tester_from_beta_groups(beta_tester_id: beta_tester_id, beta_group_ids: beta_group_ids)
end
end
context "delete_beta_testers_from_app" do
let(:app_id) { "123" }
let(:beta_tester_ids) { ["1234", "5678"] }
let(:path) { "v1/apps/#{app_id}/relationships/betaTesters" }
let(:body) do
{
data: beta_tester_ids.map do |id|
{
type: "betaTesters",
id: id
}
end
}
end
it "succeeds" do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_beta_testers_from_app(beta_tester_ids: beta_tester_ids, app_id: app_id)
end
end
context 'add_beta_tester_to_builds' do
let(:beta_tester_id) { "123" }
let(:build_ids) { ["1234", "5678"] }
let(:path) { "v1/betaTesters/#{beta_tester_id}/relationships/builds" }
let(:body) do
{
data: build_ids.map do |id|
{
type: "builds",
id: id
}
end
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.add_beta_tester_to_builds(beta_tester_id: beta_tester_id, build_ids: build_ids)
end
end
context 'add_beta_testers_to_build' do
let(:path) { "v1/builds" }
let(:build_id) { "123" }
let(:beta_tester_ids) { ["123", "456"] }
let(:body) do
{
data: beta_tester_ids.map do |id|
{
type: "betaTesters",
id: id
}
end
}
end
it 'succeeds' do
url = "#{path}/#{build_id}/relationships/individualTesters"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.add_beta_testers_to_build(build_id: build_id, beta_tester_ids: beta_tester_ids)
end
end
context 'delete_beta_testers_from_build' do
let(:path) { "v1/builds" }
let(:build_id) { "123" }
let(:beta_tester_ids) { ["123", "456"] }
let(:body) do
{
data: beta_tester_ids.map do |id|
{
type: "betaTesters",
id: id
}
end
}
end
it 'succeeds' do
url = "#{path}/#{build_id}/relationships/individualTesters"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_beta_testers_from_build(build_id: build_id, beta_tester_ids: beta_tester_ids)
end
end
end
describe "builds" do
context 'get_builds' do
let(:path) { "v1/builds" }
let(:build_id) { "123" }
let(:default_params) { { include: "buildBetaDetail,betaBuildMetrics", limit: 10, sort: "uploadedDate" } }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_builds
end
it 'succeeds with filter' do
params = { filter: { expired: false, processingState: "PROCESSING,VALID", version: "123" } }
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_builds(**params)
end
end
context 'get_build' do
let(:build_id) { "123" }
let(:path) { "v1/builds/#{build_id}" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_build(build_id: build_id)
end
end
context 'patch_builds' do
let(:path) { "v1/builds" }
let(:build_id) { "123" }
let(:attributes) { { name: "some_name" } }
let(:body) do
{
data: {
attributes: attributes,
id: build_id,
type: "builds"
}
}
end
it 'succeeds' do
url = "#{path}/#{build_id}"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_builds(build_id: build_id, attributes: attributes)
end
end
end
describe "buildBetaDetails" do
context 'get_build_beta_details' do
let(:path) { "v1/buildBetaDetails" }
let(:build_id) { "123" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_build_beta_details
end
it 'succeeds with filter' do
params = { filter: { build: build_id } }
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_build_beta_details(**params)
end
end
context 'patch_build_beta_details' do
let(:path) { "v1/buildBetaDetails" }
let(:build_beta_details_id) { "123" }
let(:attributes) { { key: "value" } }
let(:body) do
{
data: {
attributes: attributes,
id: build_beta_details_id,
type: "buildBetaDetails"
}
}
end
it 'succeeds' do
url = "#{path}/#{build_beta_details_id}"
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_build_beta_details(build_beta_details_id: build_beta_details_id, attributes: attributes)
end
end
end
describe "buildDeliveries" do
context 'get_build_deliveries' do
let(:app_id) { "123" }
let(:path) { "v1/apps/#{app_id}/buildDeliveries" }
let(:version) { "189" }
let(:default_params) { {} }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_build_deliveries(app_id: app_id)
end
it 'succeeds with filter' do
params = { filter: { version: version } }
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_build_deliveries(app_id: app_id, **params)
end
end
end
describe "preReleaseVersions" do
context 'get_pre_release_versions' do
let(:path) { "v1/preReleaseVersions" }
let(:version) { "186" }
let(:default_params) { {} }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_pre_release_versions
end
it 'succeeds with filter' do
params = { filter: { version: version } }
req_mock = test_request_params(path, params.merge(default_params))
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_pre_release_versions(**params)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/users/user_client_spec.rb | spaceship/spec/connect_api/users/user_client_spec.rb | describe Spaceship::ConnectAPI::Users::Client do
let(:mock_tunes_client) { double('tunes_client') }
let(:client) { Spaceship::ConnectAPI::Users::Client.new(another_client: mock_tunes_client) }
let(:hostname) { Spaceship::ConnectAPI::Users::Client.hostname }
let(:username) { 'spaceship@krausefx.com' }
let(:password) { 'so_secret' }
before do
allow(mock_tunes_client).to receive(:team_id).and_return("123")
allow(mock_tunes_client).to receive(:select_team)
allow(mock_tunes_client).to receive(:csrf_tokens)
allow(Spaceship::TunesClient).to receive(:login).and_return(mock_tunes_client)
Spaceship::ConnectAPI.login(username, password, use_portal: false, use_tunes: true)
end
context 'sends api request' do
before(:each) do
allow(client).to receive(:handle_response)
end
def test_request_params(url, params)
req_mock = double
options_mock = double
allow(req_mock).to receive(:headers).and_return({})
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:params=).with(params)
expect(req_mock).to receive(:options).and_return(options_mock)
expect(options_mock).to receive(:params_encoder=).with(Faraday::NestedParamsEncoder)
allow(req_mock).to receive(:status)
return req_mock
end
def test_request_body(url, body)
req_mock = double
header_mock = double
expect(req_mock).to receive(:url).with(url)
expect(req_mock).to receive(:body=).with(JSON.generate(body))
expect(req_mock).to receive(:headers).and_return(header_mock)
expect(header_mock).to receive(:[]=).with("Content-Type", "application/json")
allow(req_mock).to receive(:status)
return req_mock
end
def test_request(url)
req_mock = double
expect(req_mock).to receive(:url).with(url)
allow(req_mock).to receive(:status)
return req_mock
end
describe "users" do
context 'get_users' do
let(:path) { "v1/users" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_users
end
end
context 'patch_user' do
let(:user_id) { "123" }
let(:all_apps_visible) { false }
let(:provisioning_allowed) { true }
let(:roles) { ["ADMIN"] }
let(:path) { "v1/users/#{user_id}" }
let(:app_ids) { ["456", "789"] }
let(:body) do
{
data: {
type: 'users',
id: user_id,
attributes: {
allAppsVisible: all_apps_visible,
provisioningAllowed: provisioning_allowed,
roles: roles
},
relationships: {
visibleApps: {
data: app_ids.map do |app_id|
{
type: "apps",
id: app_id
}
end
}
}
}
}
end
it 'succeeds with list of apps' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_user(user_id: user_id, all_apps_visible: all_apps_visible, provisioning_allowed: provisioning_allowed, roles: roles, visible_app_ids: app_ids)
end
it 'succeeds with all apps' do
body_all_apps = body.clone
body_all_apps[:data][:attributes][:allAppsVisible] = true
body_all_apps[:data].delete(:relationships)
url = path
req_mock = test_request_body(url, body_all_apps)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_user(user_id: user_id, all_apps_visible: true, provisioning_allowed: provisioning_allowed, roles: roles, visible_app_ids: app_ids)
end
end
context 'delete_user' do
let(:user_id) { "123" }
let(:path) { "v1/users/#{user_id}" }
it 'succeeds' do
req_mock = test_request(path)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_user(user_id: user_id)
end
end
context 'post_user_visible_apps' do
let(:user_id) { "123" }
let(:path) { "v1/users/#{user_id}/relationships/visibleApps" }
let(:app_ids) { ["456", "789"] }
let(:body) do
{
data: app_ids.map do |app_id|
{
type: "apps",
id: app_id
}
end
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_user_visible_apps(user_id: user_id, app_ids: app_ids)
end
end
context 'patch_user_visible_apps' do
let(:user_id) { "123" }
let(:path) { "v1/users/#{user_id}/relationships/visibleApps" }
let(:app_ids) { ["456", "789"] }
let(:body) do
{
data: app_ids.map do |app_id|
{
type: "apps",
id: app_id
}
end
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:patch).and_yield(req_mock).and_return(req_mock)
client.patch_user_visible_apps(user_id: user_id, app_ids: app_ids)
end
end
context 'delete_user_visible_apps' do
let(:user_id) { "123" }
let(:path) { "v1/users/#{user_id}/relationships/visibleApps" }
let(:app_ids) { ["456", "789"] }
let(:body) do
{
data: app_ids.map do |app_id|
{
type: "apps",
id: app_id
}
end
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_user_visible_apps(user_id: user_id, app_ids: app_ids)
end
end
context 'get_user_visible_apps' do
let(:user_id) { "42" }
let(:path) { "v1/users/#{user_id}/visibleApps" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_user_visible_apps(user_id: user_id)
end
end
end
describe "user_invitations" do
context 'get_user_invitations' do
let(:path) { "v1/userInvitations" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_user_invitations
end
end
context 'post_user_invitation' do
let(:path) { "v1/userInvitations" }
let(:attributes) {
{
email: "test@example.com",
firstName: "Firstname",
lastName: "Lastname",
roles: [],
provisioningAllowed: true,
allAppsVisible: false
}
}
let(:visible_app_ids) { ["123", "456"] }
let(:body) do
{
data: {
type: "userInvitations",
attributes: attributes,
relationships: {
visibleApps: {
data: visible_app_ids.map do |id|
{
id: id,
type: "apps"
}
end
}
}
}
}
end
it 'succeeds' do
url = path
req_mock = test_request_body(url, body)
expect(client).to receive(:request).with(:post).and_yield(req_mock).and_return(req_mock)
client.post_user_invitation(
email: "test@example.com",
first_name: "Firstname",
last_name: "Lastname",
roles: [],
provisioning_allowed: true,
all_apps_visible: false,
visible_app_ids: ["123", "456"]
)
end
end
context 'delete_user_invitation' do
let(:invitation_id) { "123" }
let(:path) { "v1/userInvitations/#{invitation_id}" }
it 'succeeds' do
req_mock = test_request(path)
expect(client).to receive(:request).with(:delete).and_yield(req_mock).and_return(req_mock)
client.delete_user_invitation(user_invitation_id: invitation_id)
end
end
context 'get_user_invitation_visible_apps' do
let(:invitation_id) { "42" }
let(:path) { "v1/userInvitations/#{invitation_id}/visibleApps" }
it 'succeeds' do
params = {}
req_mock = test_request_params(path, params)
expect(client).to receive(:request).with(:get).and_yield(req_mock).and_return(req_mock)
client.get_user_invitation_visible_apps(user_invitation_id: invitation_id)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/connect_api/users/users_stubbing.rb | spaceship/spec/connect_api/users/users_stubbing.rb | class ConnectAPIStubbing
class Users
class << self
def read_fixture_file(filename)
File.read(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'users', filename))
end
def read_binary_fixture_file(filename)
File.binread(File.join('spaceship', 'spec', 'connect_api', 'fixtures', 'users', filename))
end
# Necessary, as we're now running this in a different context
def stub_request(*args)
WebMock::API.stub_request(*args)
end
def stub_users
stub_request(:get, "https://appstoreconnect.apple.com/iris/v1/users").
to_return(status: 200, body: read_fixture_file('users.json'), headers: { 'Content-Type' => 'application/json' })
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/mock_servers/developer_portal_server.rb | spaceship/spec/mock_servers/developer_portal_server.rb | require 'sinatra/base'
module MockAPI
class DeveloperPortalServer < Sinatra::Base
set :dump_errors, true
set :show_exceptions, false
before do
if request.post?
content_type(:json)
end
end
after do
if response.body.kind_of?(Hash)
response.body = JSON.dump(response.body)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/mock_servers/test_flight_server.rb | spaceship/spec/mock_servers/test_flight_server.rb | require 'sinatra/base'
module MockAPI
class TestFlightServer < Sinatra::Base
# put errors in stdout instead of returning HTML
set :dump_errors, true
set :show_exceptions, false
before do
content_type(:json)
end
after do
if response.body.kind_of?(Hash)
response.body = JSON.dump(response.body)
end
end
not_found do
content_type(:html)
status(404)
<<-HTML
<html>
<body>
#{request.request_method} : #{request.url}
HTTP ERROR: 404
</body>
</html>
HTML
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/UI/select_team_spec.rb | spaceship/spec/UI/select_team_spec.rb | describe Spaceship::Client do
describe "UI" do
describe "#select_team" do
include_examples "common spaceship login"
subject { Spaceship.client }
before do
Spaceship.login
client = Spaceship.client
end
it "uses the first team if there is only one" do
expect(subject.select_team).to eq("XXXXXXXXXX")
end
describe "Multiple Teams" do
before do
PortalStubbing.adp_stub_multiple_teams
end
it "Lets the user select the team if in multiple teams" do
allow($stdin).to receive(:gets).and_return("2")
expect(Spaceship::Client::UserInterface).to receive(:interactive?).and_return(true)
expect(subject.select_team).to eq("XXXXXXXXXX") # a different team
end
it "Falls back to user selection if team wasn't found" do
ENV["FASTLANE_TEAM_ID"] = "Not Here"
expect(Spaceship::Client::UserInterface).to receive(:interactive?).and_return(true)
allow($stdin).to receive(:gets).and_return("2")
expect(subject.select_team).to eq("XXXXXXXXXX") # a different team
end
it "Uses the specific team (1/2) using environment variables" do
ENV["FASTLANE_TEAM_ID"] = "SecondTeam"
expect(subject.select_team).to eq("SecondTeam") # a different team
end
it "Uses the specific team (2/2) using environment variables" do
ENV["FASTLANE_TEAM_ID"] = "XXXXXXXXXX"
expect(subject.select_team).to eq("XXXXXXXXXX") # a different team
end
it "Let's the user specify the team name using environment variables" do
ENV["FASTLANE_TEAM_NAME"] = "SecondTeamProfiName"
expect(subject.select_team).to eq("SecondTeam")
end
it "Uses the specific team (1/2) using method parameters" do
expect(subject.select_team(team_id: "SecondTeam")).to eq("SecondTeam") # a different team
end
it "Uses the specific team (2/2) using method parameters" do
expect(subject.select_team(team_id: "XXXXXXXXXX")).to eq("XXXXXXXXXX") # a different team
end
it "Let's the user specify the team name using method parameters" do
expect(subject.select_team(team_name: "SecondTeamProfiName")).to eq("SecondTeam")
end
it "Strips out spaces before and after the team name" do
ENV["FASTLANE_TEAM_NAME"] = " SecondTeamProfiName "
expect(subject.select_team).to eq("SecondTeam")
end
it "Asks for the team if the name couldn't be found (pick first)" do
ENV["FASTLANE_TEAM_NAME"] = "NotExistent"
expect(Spaceship::Client::UserInterface).to receive(:interactive?).and_return(true)
allow($stdin).to receive(:gets).and_return("1")
expect(subject.select_team).to eq("SecondTeam")
end
it "Asks for the team if the name couldn't be found (pick last)" do
ENV["FASTLANE_TEAM_NAME"] = "NotExistent"
expect(Spaceship::Client::UserInterface).to receive(:interactive?).and_return(true)
allow($stdin).to receive(:gets).and_return("2")
expect(subject.select_team).to eq("XXXXXXXXXX")
end
it "Raises an Error if shell is non interactive" do
expect(Spaceship::Client::UserInterface).to receive(:interactive?).and_return(false)
expect do
subject.select_team
end.to raise_error("Multiple Teams found; unable to choose, terminal not interactive!")
end
after do
ENV.delete("FASTLANE_TEAM_ID")
ENV.delete("FASTLANE_TEAM_NAME")
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/key_spec.rb | spaceship/spec/portal/key_spec.rb | require 'spec_helper'
describe Spaceship::Portal::Key do
let(:mock_client) { double('MockClient') }
before do
Spaceship::Portal::Key.client = mock_client
end
describe '.all' do
it 'uses the client to fetch all keys' do
mock_client_response(:list_keys, with: no_args) do
[
{
canDownload: false,
canRevoke: true,
keyId: "some-key-id",
keyName: "Test Key via fastlane",
servicesCount: 2
},
{
canDownload: true,
canRevoke: true,
keyId: "B92NE4F7RG",
keyName: "Test Key via browser",
servicesCount: 2
}
]
end
keys = Spaceship::Portal::Key.all
expect(keys.size).to eq(2)
expect(keys.sample).to be_instance_of(Spaceship::Portal::Key)
end
end
describe '.find' do
it 'uses the client to get a single key' do
mock_client_response(:get_key) do
{
keyId: 'some-key-id'
}
end
key = Spaceship::Portal::Key.find('some-key-id')
expect(key).to be_instance_of(Spaceship::Portal::Key)
expect(key.id).to eq('some-key-id')
end
end
describe '.create' do
it 'creates a key with the client' do
expected_service_configs = {
"U27F4V844T" => [],
"DQ8HTZ7739" => [],
"6A7HVUVQ3M" => ["some-music-id"]
}
mock_client_response(:create_key!, with: { name: 'New Key', service_configs: expected_service_configs }) do
{
keyId: 'a-new-key-id'
}
end
key = Spaceship::Portal::Key.create(name: 'New Key', apns: true, device_check: true, music_id: 'some-music-id')
expect(key).to be_instance_of(Spaceship::Portal::Key)
expect(key.id).to eq('a-new-key-id')
end
end
describe 'instance methods' do
let(:key_attributes) do # these keys are intentionally strings.
{
'canDownload' => false,
'canRevoke' => true,
'keyId' => 'some-key-id',
'keyName' => 'fastlane',
'servicesCount' => 3,
'services' => [
{
'name' => 'APNS',
'id' => 'U27F4V844T',
'configurations' => []
},
{
'name' => 'MusicKit',
'id' => '6A7HVUVQ3M',
'configurations' => [
{
'name' => 'music id test',
'identifier' => 'music.com.snatchev.test',
'type' => 'music',
'prefix' => 'some-prefix-id',
'id' => 'some-music-kit-id'
}
]
},
{
'name' => 'DeviceCheck',
'id' => 'DQ8HTZ7739',
'configurations' => []
}
]
}
end
let(:key) { Spaceship::Portal::Key.new(key_attributes) }
it 'should map attributes to methods' do
expect(key.name).to eq('fastlane')
expect(key.id).to eq('some-key-id')
end
it 'should have all of the services' do
expect(key).to have_apns
expect(key).to have_music_kit
expect(key).to have_device_check
end
it 'should have a way of getting the service configurations' do
configs = key.service_configs_for(Spaceship::Portal::Key::MUSIC_KIT_ID)
expect(configs).to be_instance_of(Array)
expect(configs.sample).to be_instance_of(Hash)
expect(configs.first['identifier']).to eq('music.com.snatchev.test')
end
describe '#download' do
it 'returns the p8 file' do
mock_client_response(:download_key) do
%{
-----BEGIN PRIVATE KEY-----
this is the encoded private key contents
-----END PRIVATE KEY-----
}
end
p8_string = key.download
expect(p8_string).to include('PRIVATE KEY')
end
end
describe '#revoke!' do
it 'revokes the key with the client' do
mock_client_response(:revoke_key!)
key.revoke!
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/website_push_spec.rb | spaceship/spec/portal/website_push_spec.rb | describe Spaceship::Portal::WebsitePush do
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Portal::WebsitePush.client }
describe "successfully loads and parses all website pushes" do
it "the number is correct" do
expect(Spaceship::Portal::WebsitePush.all.count).to eq(2)
end
it "inspect works" do
expect(Spaceship::Portal::WebsitePush.all.first.inspect).to include("Portal::WebsitePush")
end
it "parses website pushes correctly" do
website_push = Spaceship::Portal::WebsitePush.all.first
expect(website_push.bundle_id).to eq("web.com.example.one")
expect(website_push.name).to eq("First Website Push")
expect(website_push.status).to eq("current")
expect(website_push.website_id).to eq("44V62UZ8L7")
expect(website_push.app_id).to eq("44V62UZ8L7")
expect(website_push.prefix).to eq("9J57U9392R")
end
it "allows modification of values and properly retrieving them" do
website_push = Spaceship::WebsitePush.all.first
website_push.name = "12"
expect(website_push.name).to eq("12")
end
end
describe "Filter website pushes based on group identifier" do
it "works with specific Website Push IDs" do
website_push = Spaceship::Portal::WebsitePush.find("web.com.example.two")
expect(website_push.website_id).to eq("R7878HDXC3")
end
it "returns nil website push ID wasn't found" do
expect(Spaceship::Portal::WebsitePush.find("asdfasdf")).to be_nil
end
end
describe '#create' do
it 'creates a website push' do
expect(client).to receive(:create_website_push!).with('Fastlane Website Push', 'web.com.fastlane.example', mac: false).and_return({})
website_push = Spaceship::Portal::WebsitePush.create!(bundle_id: 'web.com.fastlane.example', name: 'Fastlane Website Push')
end
end
describe '#delete' do
subject { Spaceship::Portal::WebsitePush.find("web.com.example.two") }
it 'deletes the website push by a given website_id' do
expect(client).to receive(:delete_website_push!).with('R7878HDXC3', mac: false)
website_push = subject.delete!
expect(website_push.website_id).to eq('R7878HDXC3')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/provisioning_profile_template_spec.rb | spaceship/spec/portal/provisioning_profile_template_spec.rb | describe Spaceship::Portal::ProvisioningProfileTemplate do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
it "should factor a new provisioning profile template" do
attrs = {
"description" => "Template description",
"purposeDisplayName" => "Template purpose display name",
"purposeDescription" => "Template purpose description",
"purposeName" => "Template purpose name",
"version" => "1",
"entitlements" => ["com.test.extended.entitlement"]
}
template = Spaceship::Portal::ProvisioningProfileTemplate.factory(attrs)
expect(template.template_description).to eq("Template description")
expect(template.purpose_description).to eq("Template purpose description")
expect(template.purpose_display_name).to eq("Template purpose display name")
expect(template.purpose_name).to eq("Template purpose name")
expect(template.version).to eq("1")
expect(template.entitlements).to eql(["com.test.extended.entitlement"])
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/merchant_spec.rb | spaceship/spec/portal/merchant_spec.rb | require 'spec_helper'
describe Spaceship::Portal::Merchant do
let(:mock_client) { double('MockClient') }
before do
allow(Spaceship::Portal::Merchant).to receive(:client).and_return(mock_client)
end
describe ".all" do
it "fetches all merchants" do
mock_client_response(:merchants, with: any_args) do
[
{
name: "ExampleApp Production",
prefix: "9J57U9392R",
identifier: "merchant.com.example.app.production",
status: "current",
omcId: "LM3IY56BXC"
},
{
name: "ExampleApp Sandbox",
prefix: "9J57U9392R",
identifier: "merchant.com.example.app.sandbox",
status: "current",
omcId: "Z6676498T7"
}
]
end
merchants = Spaceship::Portal::Merchant.all
expect(merchants.count).to eq(2)
expect(merchants.first).to be_instance_of(Spaceship::Portal::Merchant)
end
end
describe ".find" do
it "works with specific Merchant IDs" do
mock_client_response(:merchants, with: any_args) do
[
{
name: "ExampleApp Production",
prefix: "9J57U9392R",
identifier: "merchant.com.example.app.production",
status: "current",
omcId: "LM3IY56BXC"
},
{
name: "ExampleApp Sandbox",
prefix: "9J57U9392R",
identifier: "merchant.com.example.app.sandbox",
status: "current",
omcId: "Z6676498T7"
}
]
end
merchant = Spaceship::Portal::Merchant.find("merchant.com.example.app.sandbox")
expect(merchant).to be_instance_of(Spaceship::Portal::Merchant)
expect(merchant.merchant_id).to eq("Z6676498T7")
end
it "returns nil when merchant ID wasn't found" do
mock_client_response(:merchants, with: any_args) do
[
{
name: "ExampleApp Production",
prefix: "9J57U9392R",
identifier: "merchant.com.example.app.production",
status: "current",
omcId: "LM3IY56BXC"
}
]
end
expect(Spaceship::Portal::Merchant.find("asdfasdf")).to be_nil
end
end
describe ".create" do
it 'creates a merchant' do
allow(mock_client).to receive(:create_merchant!).with("ExampleApp Production", "merchant.com.example.app.production", mac: anything).and_return(
JSON.parse({
name: "ExampleApp Production",
prefix: "9J57U9392R",
identifier: "merchant.com.example.app.production",
status: "current",
omcId: "LM3IY56BXC"
}.to_json)
)
merchant = Spaceship::Portal::Merchant.create!(bundle_id: "merchant.com.example.app.production", name: "ExampleApp Production", mac: false)
expect(merchant).to be_instance_of(Spaceship::Portal::Merchant)
expect(merchant.merchant_id).to eq("LM3IY56BXC")
expect(merchant.bundle_id).to eq("merchant.com.example.app.production")
expect(merchant.name).to eq("ExampleApp Production")
end
end
describe ".delete" do
it 'deletes the merchant by a given merchant_id' do
mock_client_response(:merchants, with: any_args) do
[
{
name: "ExampleApp Production",
prefix: "9J57U9392R",
identifier: "merchant.com.example.app.production",
status: "current",
omcId: "LM3IY56BXC"
}
]
end
allow(mock_client).to receive(:delete_merchant!).with("LM3IY56BXC", mac: anything)
subject = Spaceship::Portal::Merchant.find("merchant.com.example.app.production")
merchant = subject.delete!
expect(merchant.merchant_id).to eq('LM3IY56BXC')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/invite_spec.rb | spaceship/spec/portal/invite_spec.rb | describe Spaceship::Portal::Persons do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
it "should factor a new invite object" do
created = 1_501_106_986_000
expires = 1_503_705_599_000
attrs = {
"inviteId" => "A0B4C6D8EF",
"recipientRole" => "ADMIN",
"inviterName" => "Felix Krause",
"dateCreated" => created,
"recipientEmail" => "abl@g00gle.com",
"dateExpires" => expires
}
invited = Spaceship::Portal::Invite.factory(attrs)
# Roles are downcased to match Person
expect(invited.type).to eq("admin")
# Times are converted from timestamps to objects
expect(invited.created).to eq(Time.at(created / 1000))
expect(invited.expires).to eq(Time.at(expires / 1000))
end
it "should be OK if invite date format changes" do
created = "Wed Aug 2 23:24:08 PDT 2017"
expires = 1_503_705_599
attrs = {
"inviteId" => "A0B4C6D8EF",
"recipientRole" => "ADMIN",
"inviterName" => "Felix Krause",
"dateCreated" => created,
"recipientEmail" => "abl@g00gle.com",
"dateExpires" => expires
}
invited = Spaceship::Portal::Invite.factory(attrs)
# Roles are downcased to match Person
expect(invited.type).to eq("admin")
# If a time field isn't a number, it should be passed through as-is
expect(invited.created).to eq(created)
# If Apple changes time precision the output will be useless but this is
# unlikely; other time-centric fields use string formatted times but all
# numeric timestamps have the same precision.
expect(invited.expires).to eq(Time.at(expires / 1000))
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/device_spec.rb | spaceship/spec/portal/device_spec.rb | describe Spaceship::Device do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Device.client }
subject(:all_devices) { Spaceship::Device.all }
it "successfully loads and parses all devices" do
expect(all_devices.count).to eq(4)
device = all_devices.first
expect(device.id).to eq('AAAAAAAAAA')
expect(device.name).to eq('Felix\'s iPhone')
expect(device.udid).to eq('a03b816861e89fac0a4da5884cb9d2f01bd5641e')
expect(device.platform).to eq('ios')
expect(device.status).to eq('c')
expect(device.model).to eq('iPhone 5 (Model A1428)')
expect(device.device_type).to eq('iphone')
end
subject(:all_devices_disabled) { Spaceship::Device.all(include_disabled: true) }
it "successfully loads and parses all devices including disabled ones" do
expect(all_devices_disabled.count).to eq(6)
device = all_devices_disabled.last
expect(device.id).to eq('DISABLED_B')
expect(device.name).to eq('Old iPod')
expect(device.udid).to eq('44ee59893cb94ead4635743b25012e5b9f8c67c1')
expect(device.platform).to eq('ios')
expect(device.status).to eq('r')
expect(device.model).to eq('iPod touch')
expect(device.device_type).to eq('ipod')
end
subject(:all_phones) { Spaceship::Device.all_iphones }
it "successfully loads and parses all iPhones" do
expect(all_phones.count).to eq(3)
device = all_phones.first
expect(device.id).to eq('AAAAAAAAAA')
expect(device.name).to eq('Felix\'s iPhone')
expect(device.udid).to eq('a03b816861e89fac0a4da5884cb9d2f01bd5641e')
expect(device.platform).to eq('ios')
expect(device.status).to eq('c')
expect(device.model).to eq('iPhone 5 (Model A1428)')
expect(device.device_type).to eq('iphone')
end
subject(:all_ipods) { Spaceship::Device.all_ipod_touches }
it "successfully loads and parses all iPods" do
expect(all_ipods.count).to eq(1)
device = all_ipods.first
expect(device.id).to eq('CCCCCCCCCC')
expect(device.name).to eq('Personal iPhone')
expect(device.udid).to eq('97467684eb8dfa3c6d272eac3890dab0d001c706')
expect(device.platform).to eq('ios')
expect(device.status).to eq('c')
expect(device.model).to eq(nil)
expect(device.device_type).to eq('ipod')
end
subject(:all_apple_tvs) { Spaceship::Device.all_apple_tvs }
it "successfully loads and parses all Apple TVs" do
expect(all_apple_tvs.count).to eq(1)
device = all_apple_tvs.first
expect(device.id).to eq('EEEEEEEEEE')
expect(device.name).to eq('Tracy\'s Apple TV')
expect(device.udid).to eq('8defe35b2cad44affacabd124834acbd8746ff34')
expect(device.platform).to eq('ios')
expect(device.status).to eq('c')
expect(device.model).to eq('The new Apple TV')
expect(device.device_type).to eq('tvOS')
end
subject(:all_watches) { Spaceship::Device.all_watches }
it "successfully loads and parses all Watches" do
expect(all_watches.count).to eq(1)
device = all_watches.first
expect(device.id).to eq('FFFFFFFFFF')
expect(device.name).to eq('Tracy\'s Watch')
expect(device.udid).to eq('8defe35b2cad44aff7d8e9dfe4ca4d2fb94ae509')
expect(device.platform).to eq('ios')
expect(device.status).to eq('c')
expect(device.model).to eq('Apple Watch 38mm')
expect(device.device_type).to eq('watch')
end
it "inspect works" do
expect(subject.first.inspect).to include("Portal::Device")
end
describe "#find" do
it "finds a device by its ID" do
device = Spaceship::Device.find("AAAAAAAAAA")
expect(device.id).to eq("AAAAAAAAAA")
expect(device.udid).to eq("a03b816861e89fac0a4da5884cb9d2f01bd5641e")
end
end
describe "#create" do
it "should create and return a new device" do
expect(client).to receive(:create_device!).with("Demo Device", "7f6c8dc83d77134b5a3a1c53f1202b395b04482b", mac: false).and_return({})
device = Spaceship::Device.create!(name: "Demo Device", udid: "7f6c8dc83d77134b5a3a1c53f1202b395b04482b")
end
it "should fail to create a nil device UDID" do
expect do
Spaceship::Device.create!(name: "Demo Device", udid: nil)
end.to raise_error("You cannot create a device without a device_id (UDID) and name")
end
it "should fail to create a nil device name" do
expect do
Spaceship::Device.create!(name: nil, udid: "7f6c8dc83d77134b5a3a1c53f1202b395b04482b")
end.to raise_error("You cannot create a device without a device_id (UDID) and name")
end
it "should fail to create a device name longer than 50 characters" do
expect do
Spaceship::Device.create!(name: "Demo Device (Apple Watch Series 3 - 42mm GPS Black)", udid: "7f6c8dc83d77134b5a3a1c53f1202b395b04482b")
end.to raise_error("Device name must be 50 characters or less. \"Demo Device (Apple Watch Series 3 - 42mm GPS Black)\" has a 51 character length.")
end
it "should fail to create a device with an invalid UDID" do
expect do
Spaceship::Device.create!(name: "Demo Device", udid: "1234")
end.to raise_error("An invalid value '1234' was provided for the parameter 'deviceNumber'.")
end
it "doesn't trigger an ITC call if the device ID is already registered" do
expect(client).to_not(receive(:create_device!))
device = Spaceship::Device.create!(name: "Personal iPhone", udid: "e5814abb3b1d92087d48b64f375d8e7694932c39")
end
it "doesn't raise an exception if the device name is already registered" do
expect(client).to receive(:create_device!).with("Personal iPhone", "e5814abb3b1d92087d48b64f375d8e7694932c3c", mac: false).and_return({})
device = Spaceship::Device.create!(name: "Personal iPhone", udid: "e5814abb3b1d92087d48b64f375d8e7694932c3c")
end
end
describe "#disable" do
it "finds a device by its ID and disables it" do
device = Spaceship::Device.find("AAAAAAAAAA")
expect(device.status).to eq("c")
expect(device.enabled?).to eq(true)
device.disable!
expect(device.status).to eq("r")
expect(device.enabled?).to eq(false)
end
it "finds a device by its ID and enables it" do
device = Spaceship::Device.find("DISABLED_B", include_disabled: true)
expect(device.status).to eq("r")
expect(device.enabled?).to eq(false)
device.enable!
expect(device.status).to eq("c")
expect(device.enabled?).to eq(true)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/passbook_spec.rb | spaceship/spec/portal/passbook_spec.rb | describe Spaceship::Portal::Passbook do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Portal::Passbook.client }
describe "successfully loads and parses all passbooks" do
it "the number is correct" do
expect(Spaceship::Portal::Passbook.all.count).to eq(2)
end
it "inspect works" do
expect(Spaceship::Portal::Passbook.all.first.inspect).to include("Portal::Passbook")
end
it "parses passbook correctly" do
passbook = Spaceship::Portal::Passbook.all.first
expect(passbook.bundle_id).to eq("pass.com.example.one")
expect(passbook.name).to eq("First Passbook")
expect(passbook.status).to eq("current")
expect(passbook.passbook_id).to eq("44V62UZ8L7")
expect(passbook.prefix).to eq("9J57U9392R")
end
it "allows modification of values and properly retrieving them" do
passbook = Spaceship::Passbook.all.first
passbook.name = "12"
expect(passbook.name).to eq("12")
end
end
describe "Filter passbook based on group identifier" do
it "works with specific Passbook IDs" do
passbook = Spaceship::Portal::Passbook.find("pass.com.example.two")
expect(passbook.passbook_id).to eq("R7878HDXC3")
end
it "returns nil passbook ID wasn't found" do
expect(Spaceship::Portal::Passbook.find("asdfasdf")).to be_nil
end
end
describe '#create' do
it 'creates a passbook' do
expect(client).to receive(:create_passbook!).with('Fastlane Passbook', 'pass.com.fastlane.example').and_return({})
passbook = Spaceship::Portal::Passbook.create!(bundle_id: 'pass.com.fastlane.example', name: 'Fastlane Passbook')
end
end
describe '#delete' do
subject { Spaceship::Portal::Passbook.find("pass.com.example.two") }
it 'deletes the passbook by a given passbook_id' do
expect(client).to receive(:delete_passbook!).with('R7878HDXC3')
passbook = subject.delete!
expect(passbook.passbook_id).to eq('R7878HDXC3')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/portal_client_spec.rb | spaceship/spec/portal/portal_client_spec.rb | require_relative '../mock_servers'
require 'fastlane-sirp'
describe Spaceship::Client do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before {
Spaceship.login
}
subject { Spaceship.client }
describe '#login' do
it 'sets the session cookies' do
response = subject.login(username, password)
expect(subject.cookie).to eq("myacinfo=abcdef")
end
it 'raises an exception if authentication failed' do
expect do
subject.login('bad-username', 'bad-password')
end.to raise_exception(Spaceship::Client::InvalidUserCredentialsError)
end
end
context 'authenticated' do
before { subject.login(username, password) }
describe '#teams' do
let(:teams) { subject.teams }
it 'returns the list of available teams' do
expect(teams).to be_instance_of(Array)
expect(teams.first.keys).to eq(["status", "teamId", "type", "extendedTeamAttributes", "teamAgent", "memberships", "currentTeamMember", "name"])
end
end
describe '#team_id' do
it 'returns the default team_id' do
expect(subject.team_id).to eq('XXXXXXXXXX')
end
it "set custom Team ID" do
allow_any_instance_of(Spaceship::PortalClient).to receive(:teams).and_return([
{ 'teamId' => 'XXXXXXXXXX', 'currentTeamMember' => { 'teamMemberId' => '' } },
{ 'teamId' => 'ABCDEF', 'currentTeamMember' => { 'teamMemberId' => '' } }
])
team_id = "ABCDEF"
subject.select_team(team_id: team_id)
expect(subject.team_id).to eq(team_id)
end
it "shows a warning when user is in multiple teams and didn't call select_team" do
PortalStubbing.adp_stub_multiple_teams
expect(subject.team_id).to eq("SecondTeam")
end
end
describe '#team_name' do
it 'returns the default team_name' do
expect(subject.team_name).to eq('SpaceShip')
end
it "returns team_name from selected team_id" do
allow_any_instance_of(Spaceship::PortalClient).to receive(:teams).and_return([
{ 'teamId' => 'XXXXXXXXXX', 'name' => 'SpaceShip', 'currentTeamMember' => { 'teamMemberId' => '' } },
{ 'teamId' => 'ABCDEF', 'name' => 'PirateShip', 'currentTeamMember' => { 'teamMemberId' => '' } }
])
team_id = "ABCDEF"
subject.select_team(team_id: team_id)
expect(subject.team_id).to eq(team_id)
expect(subject.team_name).to eq('PirateShip')
end
it "return nil if no teams" do
allow_any_instance_of(Spaceship::PortalClient).to receive(:teams).and_return([])
expect(subject.team_name).to eq(nil)
end
end
describe "csrf_tokens" do
it "uses the stored token for all upcoming requests" do
# Temporary stub a request to require the csrf_tokens
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { teamId: 'XXXXXXXXXX', pageSize: "10", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }, headers: { 'csrf' => 'top_secret', 'csrf_ts' => '123123' }).
to_return(status: 200, body: PortalStubbing.adp_read_fixture_file('listDevices.action.json'), headers: { 'Content-Type' => 'application/json' })
# Hard code the tokens
allow(subject).to receive(:csrf_tokens).and_return({ csrf: 'top_secret', csrf_ts: '123123' })
allow(subject).to receive(:page_size).and_return(10) # to have a separate stubbing
expect(subject.devices.count).to eq(4)
end
end
describe '#apps' do
let(:apps) { subject.apps }
it 'returns a list of apps' do
expect(apps).to be_instance_of(Array)
expect(apps.first.keys).to eq(["appIdId", "name", "appIdPlatform", "prefix", "identifier", "isWildCard", "isDuplicate", "features", "enabledFeatures", "isDevPushEnabled", "isProdPushEnabled", "associatedApplicationGroupsCount", "associatedCloudContainersCount", "associatedIdentifiersCount"])
end
end
describe '#app_groups' do
let(:app_groups) { subject.app_groups }
it 'returns a list of apps' do
expect(app_groups).to be_instance_of(Array)
expect(app_groups.first.keys).to eq(["name", "prefix", "identifier", "status", "applicationGroup"])
end
end
describe "#team_information" do
it 'returns all available information' do
s = subject.team_information
expect(s['status']).to eq('active')
expect(s['type']).to eq('Company/Organization')
expect(s['name']).to eq('SpaceShip')
end
end
describe "#in_house?" do
it 'returns false for normal accounts' do
expect(subject.in_house?).to eq(false)
end
it 'returns true for enterprise accounts' do
PortalStubbing.adp_stub_multiple_teams
subject.team_id = 'SecondTeam'
expect(subject.in_house?).to eq(true)
end
end
describe '#create_app' do
it 'should make a request create an explicit app id' do
response = subject.create_app!(:explicit, 'Production App', 'tools.fastlane.spaceship.some-explicit-app')
expect(response['isWildCard']).to eq(false)
expect(response['name']).to eq('Production App')
expect(response['identifier']).to eq('tools.fastlane.spaceship.some-explicit-app')
end
it 'should make a request create a wildcard app id' do
response = subject.create_app!(:wildcard, 'Development App', 'tools.fastlane.spaceship.*')
expect(response['isWildCard']).to eq(true)
expect(response['name']).to eq('Development App')
expect(response['identifier']).to eq('tools.fastlane.spaceship.*')
end
it 'should strip non ASCII characters' do
response = subject.create_app!(:explicit, 'pp Test 1ed9e25c93ac7142ff9df53e7f80e84c', 'tools.fastlane.spaceship.some-explicit-app')
expect(response['isWildCard']).to eq(false)
expect(response['name']).to eq('pp Test 1ed9e25c93ac7142ff9df53e7f80e84c')
expect(response['identifier']).to eq('tools.fastlane.spaceship.some-explicit-app')
end
it 'should make a request create an explicit app id with push feature' do
payload = {}
payload[Spaceship.app_service.push_notification.on.service_id] = Spaceship.app_service.push_notification.on
response = subject.create_app!(:explicit, 'Production App', 'tools.fastlane.spaceship.some-explicit-app', enable_services: payload)
expect(response['enabledFeatures']).to(include("push"))
expect(response['identifier']).to eq('tools.fastlane.spaceship.some-explicit-app')
end
end
describe '#delete_app!' do
it 'should make a request to delete the app' do
response = subject.delete_app!('LXD24VUE49')
expect(response['resultCode']).to eq(0)
end
end
describe '#create_app_group' do
it 'should make a request create an app group' do
response = subject.create_app_group!('Production App Group', 'group.tools.fastlane.spaceship')
expect(response['name']).to eq('Production App Group')
expect(response['identifier']).to eq('group.tools.fastlane')
end
end
describe '#delete_app_group' do
it 'should make a request to delete the app group' do
response = subject.delete_app_group!('2GKKV64NUG')
expect(response['resultCode']).to eq(0)
end
end
describe "#paging" do
it "default page size is correct" do
expect(subject.page_size).to eq(500)
end
it "Properly pages if required with support for a custom page size" do
allow(subject).to receive(:page_size).and_return(8)
expect(subject.devices.count).to eq(9)
expect(subject.devices.last['name']).to eq("The last phone")
end
end
describe '#devices' do
let(:devices) { subject.devices }
it 'returns a list of device hashes' do
expect(devices).to be_instance_of(Array)
expect(devices.first.keys).to eq(["deviceId", "name", "deviceNumber", "devicePlatform", "status", "model", "deviceClass"])
end
end
describe '#certificates' do
let(:certificates) { subject.certificates(["5QPB9NHCEI"]) }
it 'returns a list of certificates hashes' do
expect(certificates).to be_instance_of(Array)
expect(certificates.first.keys).to eq(
%w(certRequestId name statusString dateRequestedString dateRequested
dateCreated expirationDate expirationDateString ownerType ownerName
ownerId canDownload canRevoke certificateId certificateStatusCode
certRequestStatusCode certificateTypeDisplayId serialNum typeString)
)
end
end
describe "#create_device" do
it "works as expected when the name is free" do
device = subject.create_device!("Demo Device", "7f6c8dc83d77134b5a3a1c53f1202b395b04482b")
expect(device['name']).to eq("Demo Device")
expect(device['deviceNumber']).to eq("7f6c8dc83d77134b5a3a1c53f1202b395b04482b")
expect(device['devicePlatform']).to eq('ios')
expect(device['status']).to eq('c')
end
end
describe '#provisioning_profiles' do
it 'makes a call to the developer portal API' do
profiles = subject.provisioning_profiles
expect(profiles).to be_instance_of(Array)
expect(profiles.sample.keys).to include("provisioningProfileId",
"name",
"status",
"type",
"distributionMethod",
"proProPlatform",
"version",
"dateExpire",
"managingApp",
"deviceIds",
"certificateIds")
expect(a_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/profile/listProvisioningProfiles.action')).to have_been_made
end
end
describe '#provisioning_profiles_via_xcode_api' do
it 'makes a call to the developer portal API' do
profiles = subject.provisioning_profiles_via_xcode_api
expect(profiles).to be_instance_of(Array)
expect(profiles.sample.keys).to include("provisioningProfileId",
"name",
"status",
"type",
"distributionMethod",
"proProPlatform",
"version",
"dateExpire",
# "managingApp", not all profiles have it
"deviceIds",
"appId",
"certificateIds")
expect(a_request(:post, /developerservices2\.apple\.com/)).to have_been_made
end
end
describe "#create_provisioning_profile" do
it "works when the name is free" do
response = subject.create_provisioning_profile!("net.sunapps.106 limited", "limited", 'R9YNDTPLJX', ['C8DL7464RQ'], ['C8DLAAAARQ'])
expect(response.keys).to include('name', 'status', 'type', 'appId', 'deviceIds')
expect(response['distributionMethod']).to eq('limited')
end
it "works when the name is already taken" do
error_text = 'Multiple profiles found with the name 'Test Name 3'. Please remove the duplicate profiles and try again.\nThere are no current certificates on this team matching the provided certificate IDs.' # not ", as this would convert the \n
expect do
response = subject.create_provisioning_profile!("taken", "limited", 'R9YNDTPLJX', ['C8DL7464RQ'], ['C8DLAAAARQ'])
end.to raise_error(Spaceship::Client::UnexpectedResponse, error_text)
end
it "works when subplatform is null and mac is false" do
response = subject.create_provisioning_profile!("net.sunapps.106 limited", "limited", 'R9YNDTPLJX', ['C8DL7464RQ'], ['C8DLAAAARQ'], mac: false, sub_platform: nil)
expect(response.keys).to include('name', 'status', 'type', 'appId', 'deviceIds')
expect(response['distributionMethod']).to eq('limited')
end
it "works when template name is specified" do
template_name = 'Subscription Service iOS (dist)'
response = subject.create_provisioning_profile!("net.sunapps.106 limited", "limited", 'R9YNDTPLJX', ['C8DL7464RQ'], [], mac: false, sub_platform: nil, template_name: template_name)
expect(response.keys).to include('name', 'status', 'type', 'appId', 'deviceIds', 'template')
expect(response['template']['purposeDisplayName']).to eq(template_name)
end
end
describe '#delete_provisioning_profile!' do
it 'makes a request to delete a provisioning profile' do
response = subject.delete_provisioning_profile!('2MAY7NPHRU')
expect(response['resultCode']).to eq(0)
end
end
describe '#create_certificate' do
let(:csr) { PortalStubbing.adp_read_fixture_file('certificateSigningRequest.certSigningRequest') }
it 'makes a request to create a certificate' do
response = subject.create_certificate!('BKLRAVXMGM', csr, '2HNR359G63')
expect(response.keys).to include('certificateId', 'certificateType', 'statusString', 'expirationDate', 'certificate')
end
end
describe '#revoke_certificate' do
it 'makes a revoke request and returns the revoked certificate' do
response = subject.revoke_certificate!('XC5PH8DAAA', 'R58UK2EAAA')
expect(response.first.keys).to include('certificateId', 'certificateType', 'certificate')
end
end
describe '#fetch_program_license_agreement_messages' do
it 'makes a request to fetch all Program License Agreement warnings from Olympus' do
# Stub the GET request that the method will make
PortalStubbing.adp_stub_fetch_program_license_agreement_messages
response = subject.fetch_program_license_agreement_messages
# The method should make a GET request to this URL:
expect(a_request(:get, 'https://appstoreconnect.apple.com/olympus/v1/contractMessages')).to have_been_made
# The method should just return the "message" key's value(s) in an array.
expected_first_message = "<b>Review the updated Paid Applications \
Schedule.</b><br />In order to update your existing apps, create \
new in-app purchases, and submit new apps to the App Store, the \
user with the Legal role (Team Agent) must review and accept the \
Paid Applications Schedule (Schedule 2 to the Apple Developer \
Program License Agreement) in the Agreements, Tax, and Banking \
module.<br /><br /> To accept this agreement, they must have \
already accepted the latest version of the Apple Developer \
Program License Agreement in their <a href=\"\
http://developer.apple.com/membercenter/index.action\">account on \
the developer website<a/>.<br />"
expect(response.first).to eq(expected_first_message)
end
end
end
describe 'keys api' do
let(:api_root) { 'https://developer.apple.com/services-account/QH65B2/account/auth/key' }
before do
MockAPI::DeveloperPortalServer.post('/services-account/QH65B2/account/auth/key/:action') do
{
keys: []
}
end
end
describe '#list_keys' do
it 'lists keys' do
subject.list_keys
expect(WebMock).to have_requested(:post, api_root + '/list')
end
end
describe '#get_key' do
it 'gets a key' do
subject.get_key(id: '123')
expect(WebMock).to have_requested(:post, api_root + '/get')
end
end
describe '#download_key' do
it 'downloads a key' do
MockAPI::DeveloperPortalServer.get('/services-account/QH65B2/account/auth/key/download') do
'----- BEGIN PRIVATE KEY -----'
end
subject.download_key(id: '123')
expect(WebMock).to have_requested(:get, api_root + '/download?keyId=123&teamId=XXXXXXXXXX')
end
end
describe '#create_key!' do
it 'creates a key' do
subject.create_key!(name: 'some name', service_configs: [])
expect(WebMock).to have_requested(:post, api_root + '/create')
end
end
describe 'revoke_key!' do
it 'revokes a key' do
subject.revoke_key!(id: '123')
expect(WebMock).to have_requested(:post, api_root + '/revoke')
end
end
end
describe 'merchant api' do
let(:api_root) { 'https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/' }
before do
MockAPI::DeveloperPortalServer.post('/services-account/QH65B2/account/ios/identifiers/:action') do
{
identifierList: [],
omcId: []
}
end
end
describe '#merchants' do
it 'lists merchants' do
subject.merchants
expect(WebMock).to have_requested(:post, api_root + 'listOMCs.action')
end
end
describe '#create_merchant!' do
it 'creates a merchant' do
subject.create_merchant!('ExampleApp Production', 'merchant.com.example.app.production')
expect(WebMock).to have_requested(:post, api_root + 'addOMC.action').with(body: { name: 'ExampleApp Production', identifier: 'merchant.com.example.app.production', teamId: 'XXXXXXXXXX' })
end
end
describe '#delete_merchant!' do
it 'deletes a merchant' do
subject.delete_merchant!('LM3IY56BXC')
expect(WebMock).to have_requested(:post, api_root + 'deleteOMC.action').with(body: { omcId: 'LM3IY56BXC', teamId: 'XXXXXXXXXX' })
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/person_spec.rb | spaceship/spec/portal/person_spec.rb | describe Spaceship::Portal::Persons do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Persons.client }
it "should factor a new person object" do
joined = "2016-06-20T06:30:26Z"
attrs = {
"personId" => "1234",
"firstName" => "Helmut",
"lastName" => "Januschka",
"email" => "helmut@januschka.com",
"developerStatus" => "active",
"dateJoined" => joined,
"teamMemberId" => "1234"
}
person = Spaceship::Portal::Person.factory(attrs)
expect(person.email_address).to eq("helmut@januschka.com")
expect(person.joined).to eq(Time.parse(joined))
end
it "should be OK if person date format changes to timestamp" do
joined = 1_501_106_986_000
attrs = {
"personId" => "1234",
"firstName" => "Helmut",
"lastName" => "Januschka",
"email" => "helmut@januschka.com",
"developerStatus" => "active",
"dateJoined" => joined,
"teamMemberId" => "1234"
}
person = Spaceship::Portal::Person.factory(attrs)
expect(person.joined).to eq(joined)
end
it "should be OK if person date format is unparsable" do
joined = "This is clearly not a timestamp"
attrs = {
"personId" => "1234",
"firstName" => "Helmut",
"lastName" => "Januschka",
"email" => "helmut@januschka.com",
"developerStatus" => "active",
"dateJoined" => joined,
"teamMemberId" => "1234"
}
person = Spaceship::Portal::Person.factory(attrs)
expect(person.joined).to eq(joined)
end
it "should remove a member" do
expect(client).to receive(:team_remove_member!).with("5M8TWKRZ3J")
person = Spaceship::Portal::Persons.find("helmut@januschka.com")
person.remove!
end
it "should change role" do
person = Spaceship::Portal::Persons.find("helmut@januschka.com")
expect { person.change_role("member") }.to_not(raise_error)
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/certificate_spec.rb | spaceship/spec/portal/certificate_spec.rb | describe Spaceship::Certificate do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Portal::Certificate.client }
describe "successfully loads and parses all certificates" do
it "the number is correct" do
expect(Spaceship::Portal::Certificate.all.count).to eq(3)
end
it "inspect works" do
expect(Spaceship::Portal::Certificate.all.first.inspect).to include("Portal::Certificate")
end
it "parses code signing identities correctly" do
cert = Spaceship::Portal::Certificate.all.first
expect(cert.id).to eq('XC5PH8DAAA')
expect(cert.name).to eq('SunApps GmbH')
expect(cert.status).to eq('Issued')
expect(cert.created.class).to eq(Time)
expect(cert.expires.class).to eq(Time)
expect(cert.created.to_s).to eq('2014-11-25 22:55:50 UTC')
expect(cert.expires.to_s).to eq('2015-11-25 22:45:50 UTC')
expect(cert.owner_type).to eq('team')
expect(cert.owner_name).to eq('SunApps GmbH')
expect(cert.owner_id).to eq('5A997XSAAA')
expect(cert.is_push?).to eq(false)
end
it "parses push certificates correctly" do
push = Spaceship::Portal::Certificate.find('32KPRBAAAA') # that's the push certificate
expect(push.id).to eq('32KPRBAAAA')
expect(push.name).to eq('net.sunapps.54')
expect(push.status).to eq('Issued')
expect(push.created.to_s).to eq('2015-04-02 21:34:00 UTC')
expect(push.expires.to_s).to eq('2016-04-01 21:24:00 UTC')
expect(push.owner_type).to eq('bundle')
expect(push.owner_name).to eq('Timelack')
expect(push.owner_id).to eq('3599RCHAAA')
expect(push.is_push?).to eq(true)
end
end
it "Correctly filters the listed certificates" do
certs = Spaceship::Portal::Certificate::Development.all
expect(certs.count).to eq(1)
cert = certs.first
expect(cert.id).to eq('C8DL7464RQ')
expect(cert.name).to eq('Felix Krause')
expect(cert.status).to eq('Issued')
expect(cert.created.to_s).to eq('2014-11-25 22:55:50 UTC')
expect(cert.expires.to_s).to eq('2015-11-25 22:45:50 UTC')
expect(cert.owner_type).to eq('teamMember')
expect(cert.owner_name).to eq('Felix Krause')
expect(cert.owner_id).to eq('5Y354CXU3A')
expect(cert.is_push?).to eq(false)
end
describe '#download' do
let(:cert) { Spaceship::Portal::Certificate.all.first }
it 'downloads the associated .cer file' do
x509 = OpenSSL::X509::Certificate.new(cert.download)
expect(x509.issuer.to_s).to match('Apple Worldwide Developer Relations')
end
it "handles failed download request" do
PortalStubbing.adp_stub_download_certificate_failure
error_text = /^Couldn't download certificate, got this instead:/
expect do
cert.download
end.to raise_error(Spaceship::Client::UnexpectedResponse, error_text)
end
end
describe '#revoke' do
let(:cert) { Spaceship::Portal::Certificate.all.first }
it 'revokes certificate by the given cert id' do
expect(client).to receive(:revoke_certificate!).with('XC5PH8DAAA', 'R58UK2EAAA', mac: false)
cert.revoke!
end
end
describe '#create' do
it 'should create and return a new certificate' do
expect(client).to receive(:create_certificate!).with('UPV3DW712I', /BEGIN CERTIFICATE REQUEST/, 'B7JBD8LHAA', false) {
JSON.parse(PortalStubbing.adp_read_fixture_file('certificateCreate.certRequest.json'))
}
csr, pkey = Spaceship::Portal::Certificate.create_certificate_signing_request
certificate = Spaceship::Portal::Certificate::ProductionPush.create!(csr: csr, bundle_id: 'net.sunapps.151')
expect(certificate).to be_instance_of(Spaceship::Portal::Certificate::ProductionPush)
end
it 'should create a new certificate using a CSR from a file' do
expect(client).to receive(:create_certificate!).with('UPV3DW712I', /BEGIN CERTIFICATE REQUEST/, 'B7JBD8LHAA', false) {
JSON.parse(PortalStubbing.adp_read_fixture_file('certificateCreate.certRequest.json'))
}
csr, pkey = Spaceship::Portal::Certificate.create_certificate_signing_request
Tempfile.open('csr') do |f|
f.write(csr.to_pem)
f.rewind
pem = f.read
Spaceship::Portal::Certificate::ProductionPush.create!(csr: pem, bundle_id: 'net.sunapps.151')
end
end
it 'can create a WebsitePush certificate' do
expect(client).to receive(:create_certificate!).with('3T2ZP62QW8', /BEGIN CERTIFICATE REQUEST/, '44V62UZ8L7', false) {
JSON.parse(PortalStubbing.adp_read_fixture_file('certificateCreate.certRequest.json'))
}
csr, pkey = Spaceship::Portal::Certificate.create_certificate_signing_request
certificate = Spaceship::Portal::Certificate::WebsitePush.create!(csr: csr, bundle_id: 'web.com.example.one')
expect(certificate).to be_instance_of(Spaceship::Portal::Certificate::WebsitePush)
end
it 'raises an error if the user wants to create a certificate for a non-existing app' do
expect do
csr, pkey = Spaceship::Portal::Certificate.create_certificate_signing_request
Spaceship::Portal::Certificate::ProductionPush.create!(csr: csr, bundle_id: 'notExisting')
end.to raise_error("Could not find app with bundle id 'notExisting'")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/portal_permission_spec.rb | spaceship/spec/portal/portal_permission_spec.rb | describe Spaceship::Portal do
describe "InsufficientPermissions" do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship::Portal.login }
let(:certificate) { Spaceship::Certificate.all.first }
it "raises an appropriate Developer Portal error when user doesn't have enough permission to do something" do
stub_request(:get, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/downloadCertificateContent.action?certificateId=XC5PH8DAAA&teamId=XXXXXXXXXX&type=R58UK2EAAA").
to_return(status: 200, body: '{
"responseId": "d069deba-8d07-4aab-844f-72523bcb71a5",
"resultCode": 1200,
"resultString": "webservice.certificate.downloadNotAllowed",
"userString": "You are not permitted to download this certificate.",
"creationTimestamp": "2017-01-26T23:13:00Z",
"requestUrl": "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/downloadCertificateContent.action",
"httpCode": 200
}', headers: { 'Content-Type' => 'application/json' })
expected_error_message = "User spaceship@krausefx.com (Team ID XXXXXXXXXX) doesn't have enough permission for the following action:"
cert = Spaceship::Certificate.all.first
begin
cert.download
rescue Spaceship::Client::InsufficientPermissions => ex
expect(ex.to_s).to include(expected_error_message)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/app_spec.rb | spaceship/spec/portal/app_spec.rb | describe Spaceship::Portal::App do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Portal::App.client }
describe "successfully loads and parses all apps" do
it "the number is correct" do
expect(Spaceship::Portal::App.all.count).to eq(5)
end
it "inspect works" do
expect(Spaceship::Portal::App.all.first.inspect).to include("Portal::App")
end
it "parses app correctly" do
app = Spaceship::Portal::App.all.first
expect(app.app_id).to eq("B7JBD8LHAA")
expect(app.name).to eq("The App Name")
expect(app.platform).to eq("ios")
expect(app.prefix).to eq("5A997XSHK2")
expect(app.bundle_id).to eq("net.sunapps.151")
expect(app.is_wildcard).to eq(false)
end
it "parses wildcard apps correctly" do
app = Spaceship::Portal::App.all.last
expect(app.app_id).to eq("L42E9BTRAA")
expect(app.name).to eq("SunApps")
expect(app.platform).to eq("ios")
expect(app.prefix).to eq("5A997XSHK2")
expect(app.bundle_id).to eq("net.sunapps.*")
expect(app.is_wildcard).to eq(true)
end
it "parses app details correctly" do
app = Spaceship::Portal::App.all.first
app = app.details
expect(app.app_id).to eq("B7JBD8LHAA")
expect(app.name).to eq("The App Name")
expect(app.platform).to eq("ios")
expect(app.prefix).to eq("5A997XSHK2")
expect(app.bundle_id).to eq("net.sunapps.151")
expect(app.is_wildcard).to eq(false)
expect(app.features).to include("push" => true)
expect(app.enable_services).to include("push")
expect(app.dev_push_enabled).to eq(false)
expect(app.prod_push_enabled).to eq(true)
expect(app.app_groups_count).to eq(0)
expect(app.cloud_containers_count).to eq(0)
expect(app.identifiers_count).to eq(0)
expect(app.associated_groups.length).to eq(1)
expect(app.associated_groups[0].group_id).to eq("group.tools.fastlane")
end
it "allows modification of values and properly retrieving them" do
app = Spaceship::App.all.first
app.name = "12"
expect(app.name).to eq("12")
end
end
describe "Filter app based on app identifier" do
it "works with specific App IDs" do
app = Spaceship::Portal::App.find("net.sunapps.151")
expect(app.app_id).to eq("B7JBD8LHAA")
expect(app.is_wildcard).to eq(false)
end
it "works with specific App IDs even with different case" do
app = Spaceship::Portal::App.find("net.sunaPPs.151")
expect(app.app_id).to eq("B7JBD8LHAA")
expect(app.is_wildcard).to eq(false)
end
it "works with wildcard App IDs" do
app = Spaceship::Portal::App.find("net.sunapps.*")
expect(app.app_id).to eq("L42E9BTRAA")
expect(app.is_wildcard).to eq(true)
end
it "returns nil app ID wasn't found" do
expect(Spaceship::Portal::App.find("asdfasdf")).to be_nil
end
end
describe '#create' do
it 'creates an app id with an explicit bundle_id' do
expect(client).to receive(:create_app!).with(:explicit, 'Production App', 'tools.fastlane.spaceship.some-explicit-app', mac: false, enable_services: {}) {
{ 'isWildCard' => true }
}
app = Spaceship::Portal::App.create!(bundle_id: 'tools.fastlane.spaceship.some-explicit-app', name: 'Production App')
expect(app.is_wildcard).to eq(true)
end
it 'creates an app id with an explicit bundle_id and no push notifications' do
expect(client).to receive(:create_app!).with(:explicit, 'Production App', 'tools.fastlane.spaceship.some-explicit-app', mac: false, enable_services: { push_notification: "off" }) {
{ 'enabledFeatures' => ["inAppPurchase"] }
}
app = Spaceship::Portal::App.create!(bundle_id: 'tools.fastlane.spaceship.some-explicit-app', name: 'Production App', enable_services: { push_notification: "off" })
expect(app.enable_services).not_to(include("push"))
end
it 'creates an app id with a wildcard bundle_id' do
expect(client).to receive(:create_app!).with(:wildcard, 'Development App', 'tools.fastlane.spaceship.*', mac: false, enable_services: {}) {
{ 'isWildCard' => false }
}
app = Spaceship::Portal::App.create!(bundle_id: 'tools.fastlane.spaceship.*', name: 'Development App')
expect(app.is_wildcard).to eq(false)
end
end
describe '#delete' do
subject { Spaceship::Portal::App.find("net.sunapps.151") }
it 'deletes the app by a given bundle_id' do
expect(client).to receive(:delete_app!).with('B7JBD8LHAA', mac: false)
app = subject.delete!
expect(app.app_id).to eq('B7JBD8LHAA')
end
end
describe '#update_name' do
subject { Spaceship::Portal::App.find("net.sunapps.151") }
it 'updates the name of the app by given bundle_id' do
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/updateAppIdName.action").
with(body: { "appIdId" => "B7JBD8LHAA", "name" => "The New Name", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: PortalStubbing.adp_read_fixture_file('updateAppIdName.action.json'), headers: { 'Content-Type' => 'application/json' })
app = subject.update_name!('The New Name')
expect(app.app_id).to eq('B7JBD8LHAA')
expect(app.name).to eq('The New Name')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/persons_spec.rb | spaceship/spec/portal/persons_spec.rb | describe Spaceship::Portal::Persons do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Persons.client }
it "should load all persons" do
all = Spaceship::Portal::Persons.all
expect(all.length).to eq(3)
end
it "should load all invites" do
all = Spaceship::Portal::Persons.invited
expect(all.length).to eq(3)
end
it "should find a specific person" do
person = Spaceship::Portal::Persons.find("helmut@januschka.com")
expect(person.email_address).to eq("helmut@januschka.com")
end
it "should invite a new one" do
expect(client).to receive(:team_invite).with("helmut@januschka.com", "admin")
Spaceship::Portal::Persons.invite("helmut@januschka.com", "admin")
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/portal_stubbing.rb | spaceship/spec/portal/portal_stubbing.rb | class PortalStubbing
class << self
def adp_read_fixture_file(filename)
File.read(File.join('spaceship', 'spec', 'portal', 'fixtures', filename))
end
def adp_read_binary_fixture_file(filename)
File.binread(File.join('spaceship', 'spec', 'portal', 'fixtures', filename))
end
# Necessary, as we're now running this in a different context
def stub_request(*args)
WebMock::API.stub_request(*args)
end
# Optional: enterprise
def adp_enterprise_stubbing
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/listCertRequests.action").
with(body: { "pageNumber" => "1", "pageSize" => "500", "sort" => "certRequestStatusCode=asc", "teamId" => "XXXXXXXXXX", "types" => "9RQEK7MSXA" }).
to_return(status: 200, body: adp_read_fixture_file(File.join("enterprise", "listCertRequests.action.json")), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/createProvisioningProfile.action").
with(body: { "appIdId" => "2UMR2S6PAA", "certificateIds" => "Q82WC5JRE9", "deviceIds" => "", "distributionType" => "inhouse", "provisioningProfileName" => "Delete Me", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('create_profile_success.json'), headers: { 'Content-Type' => 'application/json' })
end
# Optional: Team Selection
def adp_stub_multiple_teams
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/listTeams.action').
to_return(status: 200, body: adp_read_fixture_file('listTeams_multiple.action.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_login
# Most stuff is stubbed in tunes_stubbing (since it's shared)
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/listTeams.action').
to_return(status: 200, body: adp_read_fixture_file('listTeams.action.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_provisioning
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/listProvisioningProfiles.action").
to_return(status: 200, body: adp_read_fixture_file('listProvisioningProfiles.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developerservices2.apple.com/services/QH65B2/ios/listProvisioningProfiles.action?includeInactiveProfiles=true&includeExpiredProfiles=true&onlyCountLists=true&teamId=XXXXXXXXXX").
to_return(status: 200, body: adp_read_fixture_file('listProvisioningProfiles.action.plist'), headers: { 'Content-Type' => 'text/x-xml-plist' })
stub_request(:get, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/downloadProfileContent?provisioningProfileId=PP00000001&teamId=XXXXXXXXXX").
to_return(status: 200, body: adp_read_fixture_file("downloaded_provisioning_profile.mobileprovision"), headers: {})
# Download profiles
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "PP00000001", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileAdHoc.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "PP00000006", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileAppStore.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "PP00000002", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileAppStore.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "PP00000003", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileAppStore.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "PP00000004", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileAppStore.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "2MAY7NPHRU", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileAppStore.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "2MAY7NPHRF", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfiletvOSAppStore.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "PP00000005", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileDevelopment.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/getProvisioningProfile.action").
with(body: { "provisioningProfileId" => "PP00000007", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getProvisioningProfileWithTemplateiOSAppStore.action.json'), headers: { 'Content-Type' => 'application/json' })
# Create Profiles
# Name is free
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/createProvisioningProfile.action").
with(body: { "appIdId" => "R9YNDTPLJX", "certificateIds" => "C8DL7464RQ", "deviceIds" => "C8DLAAAARQ", "distributionType" => "limited", "provisioningProfileName" => "net.sunapps.106 limited", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('create_profile_success.json'), headers: { 'Content-Type' => 'application/json' })
# Name already taken
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/createProvisioningProfile.action").
with(body: { "appIdId" => "R9YNDTPLJX", "certificateIds" => "C8DL7464RQ", "deviceIds" => "C8DLAAAARQ", "distributionType" => "limited", "provisioningProfileName" => "taken", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file("create_profile_name_taken.txt"))
# Profile with template
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/createProvisioningProfile.action").
with(body: { "appIdId" => "R9YNDTPLJX", "certificateIds" => "C8DL7464RQ", "deviceIds" => "", "distributionType" => "limited", "provisioningProfileName" => "net.sunapps.106 limited", "teamId" => "XXXXXXXXXX", "template" => "Subscription Service iOS (dist)" }).
to_return(status: 200, body: adp_read_fixture_file('create_profile_with_template_success.json'), headers: { 'Content-Type' => 'application/json' })
# Repair Profiles
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/regenProvisioningProfile.action").
with(body: { "appIdId" => "572XTN75U2", "certificateIds" => "XC5PH8D47H", "deviceIds" => ["AAAAAAAAAA", "BBBBBBBBBB", "CCCCCCCCCC", "DDDDDDDDDD"], "distributionType" => "store", "provisioningProfileName" => "net.sunapps.7 AppStore", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('repair_profile_success.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/regenProvisioningProfile.action").
with(body: { "appIdId" => "572XTN75U2", "certificateIds" => "XC5PH8D47H", "deviceIds" => ["AAAAAAAAAA", "BBBBBBBBBB", "CCCCCCCCCC", "DDDDDDDDDD"], "distributionType" => "store", "provisioningProfileName" => "net.sunapps.7 AppStore", "teamId" => "XXXXXXXXXX", "subPlatform" => "tvOS" }).
to_return(status: 200, body: adp_read_fixture_file('repair_profile_tvos_success.json'), headers: { 'Content-Type' => 'application/json' })
# Delete Profiles
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/deleteProvisioningProfile.action").
with(body: { "provisioningProfileId" => "2MAY7NPHRU", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deleteProvisioningProfile.action.json'), headers: { 'Content-Type' => 'application/json' })
# tvOS Profiles
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/createProvisioningProfile.action").
with(body: { "appIdId" => "2UMR2S6PAA", "certificateIds" => "C8DL7464RQ", "deviceIds" => "EEEEEEEEEE", "distributionType" => "limited", "provisioningProfileName" => "Delete Me", "subPlatform" => "tvOS", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('create_profile_success.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_devices
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { deviceClasses: 'iphone', teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesiPhone.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { deviceClasses: 'ipod', teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesiPod.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { deviceClasses: 'tvOS', teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc' }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesTV.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { deviceClasses: 'watch', teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesWatch.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { deviceClasses: 'tvOS', teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesTV.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { deviceClasses: 'watch', teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesWatch.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevices.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
with(body: { teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "true" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesDisabled.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/deleteDevice.action').
with(body: { "deviceId" => "AAAAAAAAAA", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deleteDevice.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/enableDevice.action').
with(body: { "deviceNumber" => "44ee59893cb94ead4635743b25012e5b9f8c67c1", "displayId" => "DISABLED_B", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('enableDevice.action.json'), headers: { 'Content-Type' => 'application/json' })
# Register a new device
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/device/addDevices.action").
with(body: { "deviceClasses" => "iphone", "deviceNames" => "Demo Device", "deviceNumbers" => "7f6c8dc83d77134b5a3a1c53f1202b395b04482b", "register" => "single", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('addDeviceResponse.action.json'), headers: { 'Content-Type' => 'application/json' })
# Fail to register a new device with an invalid UDID
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/device/addDevices.action").
with(body: { "deviceClasses" => "iphone", "deviceNames" => "Demo Device", "deviceNumbers" => "1234", "register" => "single", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('addDeviceFailureResponse.json'), headers: { 'Content-Type' => 'application/json' })
# Custom paging
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action").
with(body: { "pageNumber" => "1", "pageSize" => "8", "sort" => "name=asc", "teamId" => "XXXXXXXXXX", includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesPage1-2.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action").
with(body: { "pageNumber" => "2", "pageSize" => "8", "sort" => "name=asc", "teamId" => "XXXXXXXXXX", includeRemovedDevices: "false" }).
to_return(status: 200, body: adp_read_fixture_file('listDevicesPage2-2.action.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_certificates
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/listCertRequests.action").
with(body: { "pageNumber" => "1", "pageSize" => "500", "sort" => "certRequestStatusCode=asc", "teamId" => "XXXXXXXXXX", "types" => "83Q87W3TGH,WXV89964HE,5QPB9NHCEI,R58UK2EWSO,9RQEK7MSXA,LA30L5BJEU,JKG5JZ54H7,UPV3DW712I,Y3B2F3TYSI,3T2ZP62QW8,E5D663CMZW,4APLUP237T,MD8Q2VRT6A,3BQKVH9I2X,BKLRAVXMGM,T44PTHVNID,DZQUP8189Y,FGQUP4785Z,S5WE21TULA,FUOY7LWJET" }).
to_return(status: 200, body: adp_read_fixture_file('listCertRequests.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/listCertRequests.action").
with(body: { "pageNumber" => "1", "pageSize" => "500", "sort" => "certRequestStatusCode=asc", 'teamId' => 'XXXXXXXXXX', 'types' => '5QPB9NHCEI' }).
to_return(status: 200, body: adp_read_fixture_file("list_certificates_filtered.json"), headers: { 'Content-Type' => 'application/json' })
# When looking for distribution or development certificates only:
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/listCertRequests.action").
with(body: { "pageNumber" => "1", "pageSize" => "500", "sort" => "certRequestStatusCode=asc", 'teamId' => 'XXXXXXXXXX', 'types' => 'R58UK2EWSO' }).
to_return(status: 200, body: adp_read_fixture_file("list_certificates_filtered.json"), headers: { 'Content-Type' => 'application/json' })
stub_request(:get, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/downloadCertificateContent.action?certificateId=XC5PH8DAAA&teamId=XXXXXXXXXX&type=R58UK2EAAA").
to_return(status: 200, body: adp_read_binary_fixture_file('aps_development.cer')) # note: binary!
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/submitCertificateRequest.action").
with(body: { "appIdId" => "2HNR359G63", "specialIdentifierDisplayId" => "2HNR359G63", "csrContent" => adp_read_fixture_file('certificateSigningRequest.certSigningRequest'), "type" => "BKLRAVXMGM", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('submitCertificateRequest.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/revokeCertificate.action").
with(body: { "certificateId" => "XC5PH8DAAA", "teamId" => "XXXXXXXXXX", "type" => "R58UK2EAAA" }).
to_return(status: 200, body: adp_read_fixture_file('revokeCertificate.action.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_apps
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/listAppIds.action').
with(body: { teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc' }).
to_return(status: 200, body: adp_read_fixture_file('listApps.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/mac/identifiers/listAppIds.action").
with(body: { "pageNumber" => "1", "pageSize" => "500", "sort" => "name=asc", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('listAppsMac.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/getAppIdDetail.action").
with(body: { appIdId: "B7JBD8LHAA", teamId: "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('getAppIdDetail.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/addAppId.action").
with(body: { "name" => "Production App", "identifier" => "tools.fastlane.spaceship.some-explicit-app", "gameCenter" => "on", "inAppPurchase" => "on", "teamId" => "XXXXXXXXXX", "type" => "explicit" }).
to_return(status: 200, body: adp_read_fixture_file('addAppId.action.explicit.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/addAppId.action").
with(body: { "name" => "Development App", "identifier" => "tools.fastlane.spaceship.*", "teamId" => "XXXXXXXXXX", "type" => "wildcard" }).
to_return(status: 200, body: adp_read_fixture_file('addAppId.action.wildcard.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/addAppId.action").
with(body: { "gameCenter" => "on", "identifier" => "tools.fastlane.spaceship.some-explicit-app", "inAppPurchase" => "on", "name" => "pp Test 1ed9e25c93ac7142ff9df53e7f80e84c", "teamId" => "XXXXXXXXXX", "type" => "explicit" }).
to_return(status: 200, body: adp_read_fixture_file('addAppId.action.apostroph.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/deleteAppId.action").
with(body: { "appIdId" => "LXD24VUE49", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deleteAppId.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/addAppId.action").
with(body: { "gameCenter" => "on", "identifier" => "tools.fastlane.spaceship.some-explicit-app", "inAppPurchase" => "on", "push" => "true", "name" => "Production App", "teamId" => "XXXXXXXXXX", "type" => "explicit" }).
to_return(status: 200, body: adp_read_fixture_file('addAppId.action.push.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_persons
# get all members
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/getTeamMembers").
with(body: "{\"teamId\":\"XXXXXXXXXX\"}").
to_return(status: 200, body: adp_read_fixture_file("peopleList.json"), headers: { 'Content-Type' => 'application/json' })
# invite new member
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/sendInvites").
with(body: "{\"invites\":[{\"recipientEmail\":\"helmut@januschka.com\",\"recipientRole\":\"admin\"}],\"teamId\":\"XXXXXXXXXX\"}").
to_return(status: 200, body: "", headers: {})
# get invites
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/getInvites").
with(body: "{\"teamId\":\"XXXXXXXXXX\"}").
to_return(status: 200, body: adp_read_fixture_file("inviteList.json"), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/removeTeamMembers").
with(body: "{\"teamId\":\"XXXXXXXXXX\",\"teamMemberIds\":[\"5M8TWKRZ3J\"]}").
to_return(status: 200, body: "", headers: {})
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/setTeamMemberRoles").
with(body: "{\"teamId\":\"XXXXXXXXXX\",\"role\":\"member\",\"teamMemberIds\":[\"5M8TWKRZ3J\"]}").
to_return(status: 200, body: "", headers: {})
end
def adp_stub_app_groups
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/listApplicationGroups.action').
with(body: { teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc' }).
to_return(status: 200, body: adp_read_fixture_file('listApplicationGroups.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/addApplicationGroup.action").
with(body: { "name" => "Production App Group", "identifier" => "group.tools.fastlane.spaceship", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('addApplicationGroup.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/deleteApplicationGroup.action").
with(body: { "applicationGroup" => "2GKKV64NUG", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deleteApplicationGroup.action.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_passbooks
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/listPassTypeIds.action').
with(body: { teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc' }).
to_return(status: 200, body: adp_read_fixture_file('listPassTypeIds.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/mac/identifiers/listPassTypeIds.action").
with(body: { "pageNumber" => "1", "pageSize" => "500", "sort" => "name=asc", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('listPassTypeIds.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/addPassTypeId.action").
with(body: { "name" => "Fastlane Passbook", "identifier" => "pass.com.fastlane.example", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('addPassTypeId.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/mac/identifiers/addPassTypeId.action").
with(body: { "name" => "Fastlane Passbook", "identifier" => "web.com.fastlane.example", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('addPassTypeId.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/deletePassTypeId.action").
with(body: { "passTypeId" => "R7878HDXC3", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deletePassTypeId.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/mac/identifiers/deletePassTypeId.action").
with(body: { "passTypeId" => "R7878HDXC3", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deletePassTypeId.action.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_website_pushes
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/listWebsitePushIds.action').
with(body: { teamId: 'XXXXXXXXXX', pageSize: "500", pageNumber: "1", sort: 'name=asc' }).
to_return(status: 200, body: adp_read_fixture_file('listWebsitePushIds.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/mac/identifiers/listWebsitePushIds.action").
with(body: { "pageNumber" => "1", "pageSize" => "500", "sort" => "name=asc", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('listWebsitePushIds.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/addWebsitePushId.action").
with(body: { "name" => "Fastlane Website Push", "identifier" => "web.com.fastlane.example", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('addWebsitePushId.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/mac/identifiers/addWebsitePushId.action").
with(body: { "name" => "Fastlane Website Push", "identifier" => "web.com.fastlane.example", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('addWebsitePushId.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/ios/identifiers/deleteWebsitePushId.action").
with(body: { "websitePushId" => "R7878HDXC3", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deleteWebsitePushId.action.json'), headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://developer.apple.com/services-account/QH65B2/account/mac/identifiers/deleteWebsitePushId.action").
with(body: { "websitePushId" => "R7878HDXC3", "teamId" => "XXXXXXXXXX" }).
to_return(status: 200, body: adp_read_fixture_file('deleteWebsitePushId.action.json'), headers: { 'Content-Type' => 'application/json' })
end
def adp_stub_download_certificate_failure
stub_request(:get, 'https://developer.apple.com/services-account/QH65B2/account/ios/certificate/downloadCertificateContent.action?certificateId=XC5PH8DAAA&teamId=XXXXXXXXXX&type=R58UK2EAAA').
to_return(status: 404, body: adp_read_fixture_file('download_certificate_failure.html'))
end
def adp_stub_download_provisioning_profile_failure
stub_request(:get, "https://developer.apple.com/services-account/QH65B2/account/ios/profile/downloadProfileContent?provisioningProfileId=PP00000001&teamId=XXXXXXXXXX").
to_return(status: 404, body: adp_read_fixture_file('download_certificate_failure.html'))
end
def adp_stub_fetch_program_license_agreement_messages
stub_request(:get, 'https://appstoreconnect.apple.com/olympus/v1/contractMessages').
to_return(status: 200, body: adp_read_fixture_file('program_license_agreement_messages.json'), headers: { 'Content-Type' => 'application/json' })
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/app_group_spec.rb | spaceship/spec/portal/app_group_spec.rb | describe Spaceship::Portal::AppGroup do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before { Spaceship.login }
let(:client) { Spaceship::Portal::AppGroup.client }
describe "successfully loads and parses all app groups" do
it "the number is correct" do
expect(Spaceship::Portal::AppGroup.all.count).to eq(2)
end
it "inspect works" do
expect(Spaceship::Portal::AppGroup.all.first.inspect).to include("Portal::AppGroup")
end
it "parses app group correctly" do
group = Spaceship::Portal::AppGroup.all.first
expect(group.group_id).to eq("group.com.example.one")
expect(group.name).to eq("First group")
expect(group.status).to eq("current")
expect(group.app_group_id).to eq("44V62UZ8L7")
expect(group.prefix).to eq("9J57U9392R")
end
it "allows modification of values and properly retrieving them" do
group = Spaceship::AppGroup.all.first
group.name = "12"
expect(group.name).to eq("12")
end
end
describe "Filter app group based on group identifier" do
it "works with specific App Group IDs" do
group = Spaceship::Portal::AppGroup.find("group.com.example.two")
expect(group.app_group_id).to eq("2GKKV64NUG")
end
it "returns nil app group ID wasn't found" do
expect(Spaceship::Portal::AppGroup.find("asdfasdf")).to be_nil
end
end
describe '#create' do
it 'creates an app group' do
expect(client).to receive(:create_app_group!).with('Production App Group', 'group.tools.fastlane').and_return({})
group = Spaceship::Portal::AppGroup.create!(group_id: 'group.tools.fastlane', name: 'Production App Group')
end
end
describe '#delete' do
subject { Spaceship::Portal::AppGroup.find("group.com.example.two") }
it 'deletes the app group by a given app_group_id' do
expect(client).to receive(:delete_app_group!).with('2GKKV64NUG')
group = subject.delete!
expect(group.app_group_id).to eq('2GKKV64NUG')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/enterprise_spec.rb | spaceship/spec/portal/enterprise_spec.rb | describe Spaceship::ProvisioningProfile do
describe "Enterprise Profiles" do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before do
Spaceship.login
PortalStubbing.adp_enterprise_stubbing
end
let(:client) { Spaceship::ProvisioningProfile.client }
describe "List the code signing certificate as In House profiles" do
it "uses the correct class" do
certs = Spaceship::Certificate::InHouse.all
expect(certs.count).to eq(1)
cert = certs.first
expect(cert).to be_kind_of(Spaceship::Certificate::InHouse)
expect(cert.name).to eq("SunApps GmbH")
end
end
describe "Create a new In House Profile" do
it "uses the correct type for the create request" do
cert = Spaceship::Certificate::InHouse.all.first
result = Spaceship::ProvisioningProfile::InHouse.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: cert)
expect(result.raw_data['provisioningProfileId']).to eq('W2MY88F6GE')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/portal/tvos_profile_spec.rb | spaceship/spec/portal/tvos_profile_spec.rb | describe Spaceship::ProvisioningProfile do
describe "Development tvOS Profiles" do
# Skip tunes login and login with portal
include_examples "common spaceship login", true
before do
Spaceship.login
PortalStubbing.adp_enterprise_stubbing
end
let(:client) { Spaceship::ProvisioningProfile.client }
describe "Create a new Development tvOS Profile" do
it "uses the correct type for the create request" do
cert = Spaceship::Certificate::Development.all.first
result = Spaceship::ProvisioningProfile::Development.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: cert, devices: nil, mac: false, sub_platform: 'tvOS')
expect(result.raw_data['provisioningProfileId']).to eq('W2MY88F6GE')
end
it "does not allow tvos as a subplatform" do
cert = Spaceship::Certificate::Development.all.first
expect do
Spaceship::ProvisioningProfile::Development.create!(name: 'Delete Me', bundle_id: 'net.sunapps.1', certificate: cert, devices: nil, mac: false, sub_platform: 'tvos')
end.to raise_error('Invalid sub_platform tvos, valid values are tvOS')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/tunes_permissions_spec.rb | spaceship/spec/tunes/tunes_permissions_spec.rb | describe Spaceship::Tunes do
describe "InsufficientPermissions" do
include_examples "common spaceship login"
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
it "raises an appropriate App Store Connect error when user doesn't have enough permission to do something" do
stub_request(:post, "https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/812106519").
to_return(status: 200, body: '{
"data": null,
"messages": {
"warn": null,
"error": ["Forbidden"],
"info": null
},
"statusCode": "ERROR"
}', headers: { 'Content-Type' => 'application/json' })
expected_error_message = if Gem::Version.create('3.4.0') <= Gem::Version.create(RUBY_VERSION)
"User spaceship@krausefx.com doesn't have enough permission for the following action: Spaceship::TunesClient#update_app_version"
else
"User spaceship@krausefx.com doesn't have enough permission for the following action: update_app_version"
end
e = app.edit_version
expect(e.description["German"]).to eq("My title")
e.description["German"] = "Something new"
begin
e.save!
rescue Spaceship::Client::InsufficientPermissions => ex
expect(ex.to_s).to include(expected_error_message)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/b2b_user_spec.rb | spaceship/spec/tunes/b2b_user_spec.rb | require 'spec_helper'
class B2bUserSpec
describe Spaceship::Tunes::B2bUser do
include_examples "common spaceship login"
before { TunesStubbing.itc_stub_app_pricing_intervals }
let(:client) { Spaceship::AppVersion.client }
let(:app) { Spaceship::Application.all.first }
let(:mock_client) { double('MockClient') }
let(:b2b_user) do
Spaceship::Tunes::B2bUser.new(
'value' => {
'dsUsername' => "b2b1@abc.com",
'delete' => false,
'add' => false,
'company' => 'b2b1'
},
"isEditable" => true,
"isRequired" => false
)
end
before do
allow(Spaceship::Tunes::TunesBase).to receive(:client).and_return(mock_client)
allow(mock_client).to receive(:team_id).and_return('')
end
describe 'b2b_user' do
it 'parses the data correctly' do
expect(b2b_user).to be_instance_of(Spaceship::Tunes::B2bUser)
expect(b2b_user.add).to eq(false)
expect(b2b_user.delete).to eq(false)
expect(b2b_user.ds_username).to eq('b2b1@abc.com')
end
end
describe 'from_username' do
it 'creates correct object to add' do
b2b_user_created = Spaceship::Tunes::B2bUser.from_username("b2b2@def.com")
expect(b2b_user_created.add).to eq(true)
expect(b2b_user_created.delete).to eq(false)
expect(b2b_user_created.ds_username).to eq('b2b2@def.com')
end
it 'creates correct object to add with explicit input' do
b2b_user_created = Spaceship::Tunes::B2bUser.from_username("b2b2@def.com", is_add_type: true)
expect(b2b_user_created.add).to eq(true)
expect(b2b_user_created.delete).to eq(false)
expect(b2b_user_created.ds_username).to eq('b2b2@def.com')
end
it 'creates correct object to remove' do
b2b_user_created = Spaceship::Tunes::B2bUser.from_username("b2b2@def.com", is_add_type: false)
expect(b2b_user_created.add).to eq(false)
expect(b2b_user_created.delete).to eq(true)
expect(b2b_user_created.ds_username).to eq('b2b2@def.com')
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/language_converter_spec.rb | spaceship/spec/tunes/language_converter_spec.rb | describe Spaceship::Tunes::LanguageConverter do
let(:klass) { Spaceship::Tunes::LanguageConverter }
describe "#from_itc_to_standard" do
it "works with valid inputs" do
expect(klass.from_itc_to_standard('English')).to eq('en-US')
expect(klass.from_itc_to_standard('English_CA')).to eq('en-CA')
expect(klass.from_itc_to_standard('Brazilian Portuguese')).to eq('pt-BR')
end
it "returns nil when element can't be found" do
expect(klass.from_itc_to_standard('asdfasdf')).to eq(nil)
end
end
describe "#from_standard_to_itc" do
it "works with valid inputs" do
expect(klass.from_standard_to_itc('en-US')).to eq('English')
expect(klass.from_standard_to_itc('pt-BR')).to eq('Brazilian Portuguese')
end
it "works with alternative values too" do
expect(klass.from_standard_to_itc('de')).to eq('German')
end
it "returns nil when element can't be found" do
expect(klass.from_standard_to_itc('asdfasdf')).to eq(nil)
end
end
describe "from readable to value" do
it "works with valid inputs" do
expect(klass.from_itc_readable_to_itc('UK English')).to eq('English_UK')
end
it "returns nil when element doesn't exist" do
expect(klass.from_itc_readable_to_itc('notHere')).to eq(nil)
end
end
describe "from value to readable" do
it "works with valid inputs" do
expect(klass.from_itc_to_itc_readable('English_UK')).to eq('UK English')
end
it "returns nil when element doesn't exist" do
expect(klass.from_itc_to_itc_readable('notHere')).to eq(nil)
end
end
end
describe String do
describe "#to_itc_locale" do
# verify all available itc primary languages match the right locale (itc variation)
it "redirects to the actual converter" do
expect("German".to_itc_locale).to eq("de-DE")
expect("Traditional Chinese".to_itc_locale).to eq("zh-Hant")
expect("Simplified Chinese".to_itc_locale).to eq("zh-Hans")
expect("Danish".to_itc_locale).to eq("da")
expect("Australian English".to_itc_locale).to eq("en-AU")
expect("UK English".to_itc_locale).to eq("en-GB")
expect("Canadian English".to_itc_locale).to eq("en-CA")
expect("English".to_itc_locale).to eq("en-US")
expect("Finnish".to_itc_locale).to eq("fin")
expect("French".to_itc_locale).to eq("fr-FR")
expect("Canadian French".to_itc_locale).to eq("fr-CA")
expect("Greek".to_itc_locale).to eq("el")
expect("Indonesian".to_itc_locale).to eq("id")
expect("Italian".to_itc_locale).to eq("it")
expect("Japanese".to_itc_locale).to eq("ja")
expect("Korean".to_itc_locale).to eq("ko")
expect("Malay".to_itc_locale).to eq("ms")
expect("Dutch".to_itc_locale).to eq("nl-NL")
expect("Norwegian".to_itc_locale).to eq("no")
expect("Brazilian Portuguese".to_itc_locale).to eq("pt-BR")
expect("Portuguese".to_itc_locale).to eq("pt-PT")
expect("Russian".to_itc_locale).to eq("ru")
expect("Swedish".to_itc_locale).to eq("sv")
expect("Mexican Spanish".to_itc_locale).to eq("es-MX")
expect("Spanish".to_itc_locale).to eq("es-ES")
expect("Thai".to_itc_locale).to eq("th")
expect("Turkish".to_itc_locale).to eq("tr")
expect("Vietnamese".to_itc_locale).to eq("vi")
end
end
describe "#to_language_code" do
it "redirects to the actual converter" do
expect("German".to_language_code).to eq("de-DE")
end
end
describe "#to_full_language" do
it "redirects to the actual converter" do
expect("de".to_full_language).to eq("German")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/app_submission_spec.rb | spaceship/spec/tunes/app_submission_spec.rb | describe Spaceship::AppSubmission do
include_examples "common spaceship login"
let(:client) { Spaceship::AppSubmission.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
describe "successfully creates a new app submission" do
it "generates a new app submission from App Store Connect response" do
TunesStubbing.itc_stub_app_submissions
submission = app.create_submission
expect(submission.application).to eq(app)
expect(submission.version.version).to eq(app.edit_version.version)
expect(submission.export_compliance_platform).to eq("ios")
expect(submission.export_compliance_app_type).to eq("iOS App")
expect(submission.export_compliance_compliance_required).to eq(true)
end
it "submits a valid app submission to App Store Connect" do
TunesStubbing.itc_stub_app_submissions
submission = app.create_submission
submission.content_rights_contains_third_party_content = true
submission.content_rights_has_rights = true
submission.complete!
expect(submission.submitted_for_review).to eq(true)
end
it "raises an error when submitting an app that has validation errors" do
TunesStubbing.itc_stub_app_submissions_invalid
expect do
app.create_submission
end.to raise_error("[German]: The App Name you entered has already been used. [English]: The App Name you entered has already been used. You must provide an address line. There are errors on the page and for 2 of your localizations.")
end
it "raises an error when submitting an app that is already in review" do
TunesStubbing.itc_stub_app_submissions_already_submitted
submission = app.create_submission
submission.content_rights_contains_third_party_content = true
submission.content_rights_has_rights = true
expect do
submission.complete!
end.to raise_exception("Problem processing review submission.")
expect(submission.submitted_for_review).to eq(false)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/build_spec.rb | spaceship/spec/tunes/build_spec.rb | # describe Spaceship::Tunes::Build do
# before { Spaceship::Tunes.login }
# subject { Spaceship::Tunes.client }
# let(:username) { 'spaceship@krausefx.com' }
# let(:password) { 'so_secret' }
# describe "properly parses the build from the train" do
# let(:app) { Spaceship::Application.all.first }
# it "filled in all required values (ios)" do
# train = app.build_trains(platform: 'ios').values.first
# build = train.builds.first
# expect(build.build_train).to eq(train)
# expect(build.upload_date).to eq(1_443_144_470_000)
# expect(build.valid).to eq(true)
# expect(build.id).to eq(5_577_102)
# expect(build.build_version).to eq("10")
# expect(build.train_version).to eq("1.0")
# expect(build.icon_url).to eq('https://is3-ssl.mzstatic.com/image/thumb/Newsstand3/v4/94/80/28/948028c9-59e7-7b29-e75b-f57e97421ece/Icon-76@2x.png.png/150x150bb-80.png')
# expect(build.app_name).to eq('Updated by fastlane')
# expect(build.platform).to eq('ios')
# expect(build.internal_expiry_date).to eq(1_445_737_214_000)
# expect(build.external_expiry_date).to eq(0)
# expect(build.internal_testing_enabled).to eq(true)
# expect(build.external_testing_enabled).to eq(false)
# expect(build.watch_kit_enabled).to eq(false)
# expect(build.ready_to_install).to eq(true)
# # Analytics
# expect(build.install_count).to eq(0)
# expect(build.internal_install_count).to eq(0)
# expect(build.external_install_count).to eq(0)
# expect(build.session_count).to eq(0)
# expect(build.crash_count).to eq(0)
# end
# it "filled in all required values (appletvos)" do
# train = app.build_trains(platform: 'appletvos').values.first
# build = train.builds.first
# expect(build.build_train).to eq(train)
# expect(build.upload_date).to eq(1_443_144_470_000)
# expect(build.valid).to eq(true)
# expect(build.id).to eq(5_577_102)
# expect(build.build_version).to eq("10")
# expect(build.train_version).to eq("1.0")
# expect(build.icon_url).to eq('https://is3-ssl.mzstatic.com/image/thumb/Newsstand3/v4/94/80/28/948028c9-59e7-7b29-e75b-f57e97421ece/Icon-76@2x.png.png/150x150bb-80.png')
# expect(build.app_name).to eq('Updated by fastlane')
# expect(build.platform).to eq('appletvos')
# expect(build.internal_expiry_date).to eq(1_445_737_214_000)
# expect(build.external_expiry_date).to eq(0)
# expect(build.internal_testing_enabled).to eq(true)
# expect(build.external_testing_enabled).to eq(false)
# expect(build.watch_kit_enabled).to eq(false)
# expect(build.ready_to_install).to eq(true)
# # Analytics
# expect(build.install_count).to eq(0)
# expect(build.internal_install_count).to eq(0)
# expect(build.external_install_count).to eq(0)
# expect(build.session_count).to eq(0)
# expect(build.crash_count).to eq(0)
# end
# describe "#testing_status" do
# before do
# now = Time.at(1_444_440_842)
# allow(Time).to receive(:now) { now }
# end
# it "properly describes a build" do
# build1 = app.build_trains.values.first.builds.first
# expect(build1.testing_status).to eq("Internal")
# expect(build1.external_testing_status).to eq("submitForReview")
# build2 = app.build_trains.values.last.builds.first
# expect(build2.testing_status).to eq("Inactive")
# expect(build2.external_testing_status).to eq("approvedInactive")
# end
# end
# describe "submitting/rejecting a build (ios)" do
# before do
# train = app.build_trains(platform: 'ios').values.first
# @build = train.builds.first
# end
# it "#cancel_beta_review!" do
# @build.cancel_beta_review!
# end
# it "#submit_for_beta_review!" do
# r = @build.submit_for_beta_review!({
# changelog: "Custom Changelog"
# })
# expect(r).to eq({
# app_id: "898536088",
# train: "1.0",
# build_number: "10",
# platform: "ios",
# changelog: "Custom Changelog"
# })
# end
# end
# describe "submitting/rejecting a build (appletvos)" do
# before do
# train = app.build_trains(platform: 'appletvos').values.first
# @build = train.builds.first
# end
# it "#cancel_beta_review!" do
# @build.cancel_beta_review!
# end
# it "#submit_for_beta_review!" do
# r = @build.submit_for_beta_review!({
# changelog: "Custom Changelog"
# })
# expect(r).to eq({
# app_id: "898536088",
# train: "1.0",
# build_number: "10",
# platform: "appletvos",
# changelog: "Custom Changelog"
# })
# end
# end
# end
# end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/pricing_tier.spec.rb | spaceship/spec/tunes/pricing_tier.spec.rb | describe Spaceship::Tunes::PricingTier do
include_examples "common spaceship login"
let(:client) { Spaceship::AppVersion.client }
describe "Pricing Tiers" do
it "inspect works" do
pricing_tiers = client.pricing_tiers
expect(pricing_tiers.inspect).to include("Tunes::PricingTier")
expect(pricing_tiers.inspect).to include("Tunes::PricingInfo")
end
it "correctly creates all pricing tiers including pricing infos" do
pricing_tiers = client.pricing_tiers
tier_1 = client.pricing_tiers[1]
expect(pricing_tiers.length).to eq(95)
expect(tier_1.pricing_info.length).to eq(48)
end
it "correctly parses the pricing tiers" do
tier_1 = client.pricing_tiers[1]
expect(tier_1).not_to(be_nil)
expect(tier_1.tier_stem).to eq('1')
expect(tier_1.tier_name).to eq('Tier 1')
expect(tier_1.pricing_info).not_to(be_empty)
end
it "correctly parses the pricing information" do
tier_1_first_pricing_info = client.pricing_tiers[1].pricing_info[0]
expect(tier_1_first_pricing_info.country).to eq('United States')
expect(tier_1_first_pricing_info.country_code).to eq('US')
expect(tier_1_first_pricing_info.currency_symbol).to eq('$')
expect(tier_1_first_pricing_info.wholesale_price).to eq(0.7)
expect(tier_1_first_pricing_info.retail_price).to eq(0.99)
expect(tier_1_first_pricing_info.f_retail_price).to eq('$0.99')
expect(tier_1_first_pricing_info.f_wholesale_price).to eq('$0.70')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/iap_subscription_pricing_tier_spec.rb | spaceship/spec/tunes/iap_subscription_pricing_tier_spec.rb | describe Spaceship::Tunes::IAPSubscriptionPricingTier do
before { TunesStubbing.itc_stub_iap }
include_examples "common spaceship login"
let(:client) { Spaceship::AppVersion.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
let(:pricing_tiers) { client.subscription_pricing_tiers(app.apple_id) }
describe "In-App-Purchase Subscription Pricing Tier" do
subject { pricing_tiers }
it "inspect works" do
expect(subject.inspect).to include("Tunes::IAPSubscriptionPricingTier")
expect(subject.inspect).to include("Tunes::IAPSubscriptionPricingInfo")
end
it "correctly creates all 200 subscription pricing tiers" do
expect(subject).to all(be_an(Spaceship::Tunes::IAPSubscriptionPricingTier))
expect(subject.size).to eq(200)
end
describe "Subscription Pricing Tier Info" do
subject { pricing_tiers.flat_map(&:pricing_info) }
it "correctly creates all 155 pricing infos for each country" do
expect(subject).to all(be_an(Spaceship::Tunes::IAPSubscriptionPricingInfo))
expect(subject.size).to eq(155 * 200)
end
end
end
describe "parsing the first subscription pricing tier" do
subject { pricing_tiers.first }
it "correctly parses the pricing tier information" do
expect(subject).to have_attributes(
tier_stem: "1",
tier_name: "ITC.addons.pricing.tier.1",
pricing_info: be_an(Array)
)
end
it "correctly parses the pricing info" do
expect(subject.pricing_info.first).to have_attributes(
country_code: "IN",
currency_symbol: "R",
wholesale_price: 6.09,
wholesale_price2: 7.39,
retail_price: 10,
f_retail_price: "Rs 10",
f_wholesale_price: "Rs 6.09",
f_wholesale_price2: "Rs 7.39"
)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/members_spec.rb | spaceship/spec/tunes/members_spec.rb | describe Spaceship::Tunes::Members do
include_examples "common spaceship login"
before { TunesStubbing.itc_stub_members }
describe "members" do
it "should return a list with members" do
members = Spaceship::Members.all
expect(members.length).to eq(3)
end
it "finds one member by email" do
member = Spaceship::Members.find("helmut@januschka.com")
expect(member.class).to eq(Spaceship::Tunes::Member)
expect(member.email_address).to eq("helmut@januschka.com")
end
describe "creates a new member" do
it "role: admin, apps: all" do
Spaceship::Members.create!(firstname: "Helmut", lastname: "Januschka", email_address: "helmut@januschka.com")
end
it "role: developer apps: all" do
Spaceship::Members.create!(firstname: "Helmut", lastname: "Januschka", email_address: "helmut@januschka.com", roles: ["developer"])
end
it "role: appmanager, apps: 898536088" do
Spaceship::Members.create!(firstname: "Helmut", lastname: "Januschka", email_address: "helmut@januschka.com", roles: ["appmanager"], apps: ["898536088"])
end
end
describe "updates roles and apps for an existing member" do
it "role: admin, apps: all" do
member = Spaceship::Members.find("helmut@januschka.com")
Spaceship::Members.update_member_roles!(member, roles: [], apps: [])
end
it "role: developer apps: all" do
member = Spaceship::Members.find("hjanuschka@gmail.com")
Spaceship::Members.update_member_roles!(member, roles: ["developer"])
end
it "role: appmanager, apps: 898536088" do
member = Spaceship::Members.find("hjanuschka+no-accept@gmail.com")
Spaceship::Members.update_member_roles!(member, roles: ["appmanager"], apps: ["898536088"])
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/b2b_organization_spec.rb | spaceship/spec/tunes/b2b_organization_spec.rb | require 'spec_helper'
# require_relative '../../../spaceship/lib/spaceship/tunes/b2b_organization'
class B2bOrganizationSpec
describe Spaceship::Tunes::B2bOrganization do
include_examples "common spaceship login"
before { TunesStubbing.itc_stub_app_pricing_intervals }
let(:client) { Spaceship::AppVersion.client }
let(:app) { Spaceship::Application.all.first }
let(:mock_client) { double('MockClient') }
let(:b2b_organization) do
Spaceship::Tunes::B2bOrganization.new(
'value' => {
'type' => "DELETE",
'depCustomerId' => 'abcdefgh',
'organizationId' => '1234567890',
'name' => 'My awesome company'
}
)
end
before do
allow(Spaceship::Tunes::TunesBase).to receive(:client).and_return(mock_client)
allow(mock_client).to receive(:team_id).and_return('')
end
describe 'b2b_organization' do
it 'parses the data correctly' do
expect(b2b_organization).to be_instance_of(Spaceship::Tunes::B2bOrganization)
expect(b2b_organization.type).to eq("DELETE")
expect(b2b_organization.dep_customer_id).to eq("abcdefgh")
expect(b2b_organization.dep_organization_id).to eq('1234567890')
expect(b2b_organization.name).to eq('My awesome company')
end
end
describe 'from_id_info' do
it 'creates correct object' do
b2b_org_created = Spaceship::Tunes::B2bOrganization.from_id_info(dep_id: 'jklmnopqr',
dep_name: 'Another awesome company',
type: Spaceship::Tunes::B2bOrganization::TYPE::ADD)
expect(b2b_org_created.type).to eq("ADD")
expect(b2b_org_created.dep_customer_id).to eq('jklmnopqr')
expect(b2b_org_created.name).to eq('Another awesome company')
end
end
describe '==' do
it 'works correctly' do
org1 = Spaceship::Tunes::B2bOrganization.new(
'value' => {
'type' => "DELETE",
'depCustomerId' => 'abcdefgh',
'organizationId' => '1234567890',
'name' => 'My awesome company'
}
)
org2 = Spaceship::Tunes::B2bOrganization.new(
'value' => {
'type' => "DELETE",
'depCustomerId' => 'abcdefgh',
'organizationId' => nil,
'name' => 'My awesome company'
}
)
org3 = Spaceship::Tunes::B2bOrganization.new(
'value' => {
'type' => "NO_CHANGE",
'depCustomerId' => 'abcdefgh',
'organizationId' => '1234567890',
'name' => 'My awesome company'
}
)
expect(org1 == org2).to eq(true)
expect(org1 != org2).to eq(false)
expect(org1 == org3).to eq(false)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/server_failures_spec.rb | spaceship/spec/tunes/server_failures_spec.rb | describe Spaceship::TunesClient do
describe "Random Server Failures" do
include_examples "common spaceship login"
let(:client) { Spaceship::Application.client }
let(:app) { Spaceship::Application.all.first }
describe "#build_trains failing" do
# it "automatically re-tries the request when getting a ITC.response.error.OPERATION_FAILED when receive build trains" do
# # Ensuring the fix for https://github.com/fastlane/fastlane/issues/6419
# # First, stub a failing request
# stub_request(:get, "https://appstoreconnect.apple.com/testflight/v2/providers/1234/apps/898536088/platforms/ios/trains").
# # to_return(status: 200, body: TunesStubbing.itc_read_fixture_file('build_trains_operation_failed.json'), headers: { 'Content-Type' => 'application/json' }).times(2).
# to_return(status: 200, body: TunesStubbing.itc_read_fixture_file('build_trains.json'), headers: { 'Content-Type' => 'application/json' })
# build_trains = app.build_trains(platform: 'ios')
# # expect(build_trains).to be_a(Spaceship::TestFlight::BuildTrains)
# end
# it "raises an exception after retrying a failed request multiple times" do
# stub_request(:get, "https://appstoreconnect.apple.com/testflight/v2/providers/1234/apps/898536088/platforms/ios/trains").
# to_return(status: 200, body: TunesStubbing.itc_read_fixture_file('build_trains_operation_failed.json'), headers: { 'Content-Type' => 'application/json' })
# error_message = 'Temporary App Store Connect error: {"data"=>nil, "messages"=>{"warn"=>nil, "error"=>["ITC.response.error.OPERATION_FAILED"], "info"=>nil}, "statusCode"=>"ERROR"}'
# expect do
# build_trains = app.build_trains(platform: 'ios')
# end.to raise_exception(Spaceship::Client::UnexpectedResponse, error_message)
# end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/app_version_spec.rb | spaceship/spec/tunes/app_version_spec.rb | describe Spaceship::AppVersion, all: true do
include_examples "common spaceship login"
let(:client) { Spaceship::AppVersion.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
describe "successfully loads and parses the app version" do
it "inspect works" do
expect(app.edit_version.inspect).to include("Tunes::AppVersion")
end
it "parses the basic version details correctly" do
version = app.edit_version
expect(version.application).to eq(app)
expect(version.is_live?).to eq(false)
expect(version.current_build_number).to eq("9")
expect(version.copyright).to eq("2015 SunApps GmbH")
expect(version.version_id).to eq(812_106_519)
expect(version.raw_status).to eq('readyForSale')
expect(version.can_reject_version).to eq(false)
expect(version.can_prepare_for_upload).to eq(false)
expect(version.can_send_version_live).to eq(false)
expect(version.release_on_approval).to eq(true)
expect(version.auto_release_date).to eq(nil)
expect(version.ratings_reset).to eq(false)
expect(version.can_beta_test).to eq(true)
expect(version.version).to eq('0.9.13')
expect(version.supports_apple_watch).to eq(false)
expect(version.large_app_icon.url).to eq('https://is1-ssl.mzstatic.com/image/thumb/Purple3/v4/02/88/4d/02884d3d-92ea-5e6a-2a7b-b19da39f73a6/pr_source.png/0x0ss.jpg')
expect(version.large_app_icon.original_file_name).to eq('AppIconFull.png')
expect(version.watch_app_icon.url).to eq('https://is1-ssl.mzstatic.com/image/thumb//0x0ss.jpg')
expect(version.watch_app_icon.original_file_name).to eq('OriginalName.png')
expect(version.transit_app_file).to eq(nil)
expect(version.platform).to eq("ios")
end
it "parses the localized values correctly" do
version = app.edit_version
expect(version.description['English']).to eq('Super Description here')
expect(version.description['German']).to eq('My title')
expect(version.keywords['English']).to eq('Some random titles')
expect(version.keywords['German']).to eq('More random stuff')
expect(version.support_url['German']).to eq('http://url.com')
expect(version.release_notes['German']).to eq('Wow, News')
expect(version.release_notes['English']).to eq('Also News')
expect(version.description.keys).to eq(version.description.languages)
expect(version.description.keys).to eq(["German", "English"])
end
it "parses the review information correctly" do
version = app.edit_version
expect(version.review_first_name).to eq('Felix')
expect(version.review_last_name).to eq('Krause')
expect(version.review_phone_number).to eq('+4123123123')
expect(version.review_email).to eq('felix@sunapps.net')
expect(version.review_demo_user).to eq('MyUser@gmail.com')
expect(version.review_user_needed).to eq(true)
expect(version.review_demo_password).to eq('SuchPass')
expect(version.review_notes).to eq('Such Notes here')
end
describe "supports setting of the app rating" do
before do
@v = app.edit_version
@v.update_rating({
'CARTOON_FANTASY_VIOLENCE' => 1,
'MATURE_SUGGESTIVE' => 2,
'GAMBLING' => 0,
'UNRESTRICTED_WEB_ACCESS' => 1,
'GAMBLING_CONTESTS' => 0
})
end
it "infrequent_mild" do
val = @v.raw_data['ratings']['nonBooleanDescriptors'].find do |a|
a['name'].include?('CARTOON_FANTASY_VIOLENCE')
end
expect(val['level']).to eq("ITC.apps.ratings.level.INFREQUENT_MILD")
end
it "infrequent_mild" do
val = @v.raw_data['ratings']['nonBooleanDescriptors'].find do |a|
a['name'].include?('CARTOON_FANTASY_VIOLENCE')
end
expect(val['level']).to eq("ITC.apps.ratings.level.INFREQUENT_MILD")
end
it "none" do
val = @v.raw_data['ratings']['nonBooleanDescriptors'].find do |a|
a['name'].include?('GAMBLING')
end
expect(val['level']).to eq("ITC.apps.ratings.level.NONE")
end
it "boolean true" do
val = @v.raw_data['ratings']['booleanDescriptors'].find do |a|
a['name'].include?('UNRESTRICTED_WEB_ACCESS')
end
expect(val['level']).to eq("ITC.apps.ratings.level.YES")
end
it "boolean false" do
val = @v.raw_data['ratings']['booleanDescriptors'].find do |a|
a['name'].include?('GAMBLING_CONTESTS')
end
expect(val['level']).to eq("ITC.apps.ratings.level.NO")
end
end
describe "#candidate_builds" do
it "properly fetches and parses all builds ready to be deployed" do
version = app.edit_version
res = version.candidate_builds
build = res.first
expect(build.build_version).to eq("9")
expect(build.train_version).to eq("1.1")
expect(build.icon_url).to eq("https://is5-ssl.mzstatic.com/image/thumb/Newsstand3/v4/70/6a/7f/706a7f53-bac9-0a43-eb07-9f2cbb9a7d71/Icon-76@2x.png.png/150x150bb-80.png")
expect(build.upload_date).to eq(1_443_150_586_000)
expect(build.processing).to eq(false)
expect(build.apple_id).to eq("898536088")
end
it "allows choosing of the build for the version to submit" do
version = app.edit_version
build = version.candidate_builds.first
version.select_build(build)
expect(version.raw_data['preReleaseBuildVersionString']['value']).to eq("9")
expect(version.raw_data['preReleaseBuildTrainVersionString']).to eq("1.1")
expect(version.raw_data['preReleaseBuildUploadDate']).to eq(1_443_150_586_000)
end
end
describe "release an app version" do
it "allows release the edit version" do
version = app.edit_version
version.raw_status = 'pendingDeveloperRelease'
status = version.release!
# Note right now we don't really update the raw_data after the release
expect(version.raw_status).to eq('pendingDeveloperRelease')
end
end
describe "release an app version in phased release to all users" do
it "allows releasing the live version to all users" do
version = app.live_version
version.raw_status = 'readyForSale'
status = version.release_to_all_users!
expect(version.raw_status).to eq('readyForSale')
end
end
describe "#url" do
it "live version" do
expect(app.live_version.url).to eq("https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/#{app.apple_id}/#{app.platform}/versioninfo/deliverable")
end
it "edit version" do
expect(app.edit_version.url).to eq("https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/ng/app/#{app.apple_id}/#{app.platform}/versioninfo/")
end
end
describe "App Status" do
it "parses readyForSale" do
version = app.live_version
expect(version.app_status).to eq("Ready for Sale")
expect(version.current_build_number).to eq("9")
expect(version.app_status).to eq(Spaceship::Tunes::AppStatus::READY_FOR_SALE)
end
it "parses prepareForUpload" do
expect(Spaceship::Tunes::AppStatus.get_from_string('prepareForUpload')).to eq(Spaceship::Tunes::AppStatus::PREPARE_FOR_SUBMISSION)
end
it "parses rejected" do
expect(Spaceship::Tunes::AppStatus.get_from_string('rejected')).to eq(Spaceship::Tunes::AppStatus::REJECTED)
end
it "parses pendingDeveloperRelease" do
expect(Spaceship::Tunes::AppStatus.get_from_string('pendingDeveloperRelease')).to eq(Spaceship::Tunes::AppStatus::PENDING_DEVELOPER_RELEASE)
end
it "parses metadataRejected" do
expect(Spaceship::Tunes::AppStatus.get_from_string('metadataRejected')).to eq(Spaceship::Tunes::AppStatus::METADATA_REJECTED)
end
it "parses removedFromSale" do
expect(Spaceship::Tunes::AppStatus.get_from_string('removedFromSale')).to eq(Spaceship::Tunes::AppStatus::REMOVED_FROM_SALE)
end
end
describe "Screenshots" do
it "properly parses all the screenshots" do
v = app.live_version
# This app only has screenshots in the English version
expect(v.screenshots['German']).to eq([])
s1 = v.screenshots["English"].first
expect(s1.device_type).to eq('iphone4')
expect(s1.url).to eq('https://is1-ssl.mzstatic.com/image/thumb/Purple62/v4/4f/26/50/4f265065-b11d-857b-6232-d219ad4791d2/pr_source.png/0x0ss.jpg')
expect(s1.sort_order).to eq(1)
expect(s1.original_file_name).to eq('ftl_250ec6b31ba0da4c4e8e22fdf83d71a1_65ea94f6b362563260a5742b93659729.png')
expect(s1.language).to eq("English")
expect(v.screenshots["English"].count).to eq(13)
# 2 iPhone 6 Plus Screenshots
expect(v.screenshots["English"].count { |s| s.device_type == 'iphone6Plus' }).to eq(3)
end
end
# describe "AppTrailers", :trailers do
# it "properly parses all the trailers" do
# v = app.live_version
# # This app only has screenshots in the English version
# expect(v.trailers["German"]).to eq([])
# s1 = v.trailers["English"].first
# expect(s1.device_type).to eq("ipad")
# expect(s1.language).to eq("English")
# expect(s1.preview_frame_time_code).to eq("00:05")
# expect(s1.is_portrait).to eq(false)
# expect(v.trailers["English"].count).to eq(1)
# expect(v.trailers["English"].count { |s| s.device_type == "iphone6Plus" }).to eq(0)
# end
# end
end
describe "Modifying the app version" do
let(:version) { app.edit_version }
it "doesn't allow modification of localized properties without the language" do
begin
version.description = "Yes"
raise "Should raise exception before"
rescue NoMethodError => ex
expected_message = if Gem::Version.create('3.4.0') <= Gem::Version.create(RUBY_VERSION)
"undefined method 'description='"
else
"undefined method `description='"
end
expect(ex.to_s).to include(expected_message)
end
end
describe "Modifying the app large and watch icon", :du do
before do
allow(Spaceship::UploadFile).to receive(:from_path) do |path|
du_uploadimage_correct_jpg if path == "path_to_jpg"
end
json = JSON.parse(du_read_fixture_file("upload_image_success.json"))
allow(client.du_client).to receive(:upload_large_icon).and_return(json)
allow(client.du_client).to receive(:upload_watch_icon).and_return(json)
end
it "stores extra information in the raw_data" do
version.upload_large_icon!("path_to_jpg")
expect(version.raw_data["largeAppIcon"]["value"]).to eq({
assetToken: "Purple7/v4/65/04/4d/65044dae-15b0-a5e0-d021-5aa4162a03a3/pr_source.jpg",
originalFileName: "ftl_FAKEMD5_icon1024.jpg",
size: 198_508,
height: 1024,
width: 1024,
checksum: "d41d8cd98f00b204e9800998ecf8427e"
})
end
it "deletes the large app data" do
version.upload_large_icon!(nil)
expect(version.large_app_icon.url).to eq(nil)
expect(version.large_app_icon.original_file_name).to eq(nil)
expect(version.large_app_icon.asset_token).to eq(nil)
end
it "deletes the watch app data" do
version.upload_watch_icon!(nil)
expect(version.watch_app_icon.url).to eq(nil)
expect(version.watch_app_icon.original_file_name).to eq(nil)
expect(version.watch_app_icon.asset_token).to eq(nil)
end
end
# describe "Modifying the app trailers", :trailers do
# let(:ipad_trailer_path) { "path_to_trailer.mov" }
# let(:ipad_trailer_preview_path) { "path_to_trailer_preview.jpg" }
# let(:ipad_external_valid_trailer_preview_path) { "path_to_my_screenshot.jpg" }
# let(:ipad_external_invalid_trailer_preview_path) { "path_to_my_invalid_screenshot.jpg.jpg" }
# before do
# allow(Spaceship::UploadFile).to receive(:from_path) do |path|
# r = du_uploadtrailer_correct_mov if path == ipad_trailer_path
# r = du_uploadtrailer_preview_correct_jpg if path == ipad_trailer_preview_path
# r = du_uploadtrailer_preview_correct_jpg if path == ipad_external_valid_trailer_preview_path
# r
# end
# allow(Spaceship::Utilities).to receive(:grab_video_preview) do |path|
# r = ipad_trailer_preview_path if path == ipad_trailer_path
# r
# end
# allow(Spaceship::Utilities).to receive(:portrait?) do |path|
# r = true if path == ipad_trailer_preview_path
# r = true if path == ipad_external_invalid_trailer_preview_path
# r = true if path == ipad_external_valid_trailer_preview_path
# r
# end
# allow(Spaceship::Utilities).to receive(:resolution) do |path|
# r = [900, 1200] if path == ipad_trailer_path
# r = [768, 1024] if path == ipad_trailer_preview_path
# r = [700, 1000] if path == ipad_external_invalid_trailer_preview_path
# r = [768, 1024] if path == ipad_external_valid_trailer_preview_path
# r
# end
# json = JSON.parse(du_read_fixture_file("upload_trailer_response_success.json"))
# allow(client.du_client).to receive(:upload_trailer).and_return(json)
# json = JSON.parse(du_read_upload_trailer_preview_response_success)
# allow(client.du_client).to receive(:upload_trailer_preview).and_return(json)
# end
# def trailers(device)
# version.trailers["English"].select { |s| s.device_type == device }
# end
# def ipad_trailers
# trailers("ipad")
# end
# it "cannot add a trailer to iphone35" do
# expect do
# version.upload_trailer!(ipad_trailer_path, "English", 'iphone35')
# end.to raise_error "No app trailer supported for iphone35"
# end
# it "requires timestamp with a specific format" do
# expect do
# version.upload_trailer!(ipad_trailer_path, "English", 'ipad', "00:01.000")
# end.to raise_error "Invalid timestamp 00:01.000"
# expect do
# version.upload_trailer!(ipad_trailer_path, "English", 'ipad', "01.000")
# end.to raise_error "Invalid timestamp 01.000"
# end
# it "can add a new trailer" do
# # remove existing
# version.upload_trailer!(nil, "English", 'ipad')
# count = ipad_trailers.count
# expect(count).to eq(0)
# version.upload_trailer!(ipad_trailer_path, "English", 'ipad')
# count_after = ipad_trailers.count
# expect(count_after).to eq(count + 1)
# expect(count_after).to eq(count + 1)
# trailer = ipad_trailers[0]
# expect(trailer.video_asset_token).to eq("VideoSource40/v4/e3/48/1a/e3481a8f-ec25-e19f-5048-270d7acaf89a/pr_source.mov")
# expect(trailer.picture_asset_token).to eq("Purple69/v4/5f/2b/81/5f2b814d-1083-5509-61fb-c0845f7a9374/pr_source.jpg")
# expect(trailer.descriptionXML).to match(/FoghornLeghorn/)
# expect(trailer.preview_frame_time_code).to eq("00:00:05:00")
# expect(trailer.video_url).to eq(nil)
# expect(trailer.preview_image_url).to eq(nil)
# expect(trailer.full_sized_preview_image_url).to eq(nil)
# expect(trailer.device_type).to eq("ipad")
# expect(trailer.language).to eq("English")
# end
# it "can modify the preview of an existing trailer and automatically generates a new screenshot preview" do
# json = JSON.parse(du_read_upload_trailer_preview_2_response_success)
# allow(client.du_client).to receive(:upload_trailer_preview).and_return(json)
# count = ipad_trailers.count
# expect(count).to eq(1)
# version.upload_trailer!(ipad_trailer_path, "English", 'ipad', "06.12")
# count_after = ipad_trailers.count
# expect(count_after).to eq(count)
# trailer = ipad_trailers[0]
# expect(trailer.video_asset_token).to eq(nil)
# expect(trailer.picture_asset_token).to eq("Purple70/v4/5f/2b/81/5f2b814d-1083-5509-61fb-c0845f7a9374/pr_source.jpg")
# expect(trailer.descriptionXML).to eq(nil)
# expect(trailer.preview_frame_time_code).to eq("00:00:06:12")
# expect(trailer.video_url).to eq("http://a1713.phobos.apple.com/us/r30/PurpleVideo7/v4/be/38/db/be38db8d-868a-d442-87dc-cb6d630f921e/P37134684_default.m3u8")
# expect(trailer.preview_image_url).to eq("https://is1-ssl.mzstatic.com/image/thumb/PurpleVideo5/v4/b7/41/5e/b7415e96-5ad5-6cf5-9323-15122145e53f/Job21976428-61a9-456b-af46-26c1303ae607-91524171-PreviewImage_AppTrailer_quicktime-Time1438426738374.png/500x500bb-80.png")
# expect(trailer.full_sized_preview_image_url).to eq("https://is1-ssl.mzstatic.com/image/thumb/PurpleVideo5/v4/b7/41/5e/b7415e96-5ad5-6cf5-9323-15122145e53f/Job21976428-61a9-456b-af46-26c1303ae607-91524171-PreviewImage_AppTrailer_quicktime-Time1438426738374.png/900x1200ss-80.png")
# expect(trailer.device_type).to eq("ipad")
# expect(trailer.language).to eq("English")
# end
# it "can add a new trailer given a valid externally provided preview screenshot" do
# # remove existing
# version.upload_trailer!(nil, "English", 'ipad')
# expect do
# version.upload_trailer!(ipad_trailer_path, "English", 'ipad', '12.34', ipad_external_invalid_trailer_preview_path)
# end.to raise_error "Invalid portrait screenshot resolution for device ipad. Should be [768, 1024]"
# end
# it "can add a new trailer given a valid externally provided preview screenshot" do
# # remove existing
# version.upload_trailer!(nil, "English", 'ipad')
# count = ipad_trailers.count
# expect(count).to eq(0)
# version.upload_trailer!(ipad_trailer_path, "English", 'ipad', '12.34', ipad_external_valid_trailer_preview_path)
# count_after = ipad_trailers.count
# expect(count_after).to eq(count + 1)
# trailer = ipad_trailers[0]
# expect(trailer.video_asset_token).to eq("VideoSource40/v4/e3/48/1a/e3481a8f-ec25-e19f-5048-270d7acaf89a/pr_source.mov")
# expect(trailer.picture_asset_token).to eq("Purple69/v4/5f/2b/81/5f2b814d-1083-5509-61fb-c0845f7a9374/pr_source.jpg")
# expect(trailer.descriptionXML).to match(/FoghornLeghorn/)
# expect(trailer.preview_frame_time_code).to eq("00:00:12:34")
# expect(trailer.video_url).to eq(nil)
# expect(trailer.preview_image_url).to eq(nil)
# expect(trailer.full_sized_preview_image_url).to eq(nil)
# expect(trailer.device_type).to eq("ipad")
# expect(trailer.language).to eq("English")
# end
# # IDEA: can we detect trailer source change ?
# it "remove the video trailer" do
# count = ipad_trailers.count
# expect(count).to eq(1)
# version.upload_trailer!(nil, "English", 'ipad')
# count_after = ipad_trailers.count
# expect(count_after).to eq(count - 1)
# end
# end
describe "Reading and modifying the geojson file", :du do
before do
json = JSON.parse(du_read_upload_geojson_response_success)
allow(client.du_client).to receive(:upload_geojson).and_return(json)
end
it "default geojson data is nil when value field is missing" do
expect(version.raw_data["transitAppFile"]["value"]).to eq(nil)
expect(version.transit_app_file).to eq(nil)
end
it "modifies the geojson file data after update" do
allow(Spaceship::Utilities).to receive(:md5digest).and_return("FAKEMD5")
file_name = "upload_valid.geojson"
version.upload_geojson!(du_fixture_file_path(file_name))
expect(version.transit_app_file.name).to eq("ftl_FAKEMD5_#{file_name}")
expect(version.transit_app_file.url).to eq(nil)
expect(version.transit_app_file.asset_token).to eq("Purple1/v4/45/50/9d/45509d39-6a5d-7f55-f919-0fbc7436be61/pr_source.geojson")
end
it "deletes the geojson" do
version.upload_geojson!(du_fixture_file_path("upload_valid.geojson"))
version.upload_geojson!(nil)
expect(version.raw_data["transitAppFile"]["value"]).to eq(nil)
expect(version.transit_app_file).to eq(nil)
end
end
describe "Upload screenshots", :screenshots do
before do
allow(Spaceship::UploadFile).to receive(:from_path) do |path|
du_uploadimage_correct_screenshot if path == "path_to_screenshot"
end
end
let(:screenshot_path) { "path_to_screenshot" }
describe "Parameter checks" do
it "prevents from using negative sort_order" do
expect do
version.upload_screenshot!(screenshot_path, -1, "English", 'iphone4', false)
end.to raise_error("sort_order must be higher than 0")
end
it "prevents from using sort_order 0" do
expect do
version.upload_screenshot!(screenshot_path, 0, "English", 'iphone4', false)
end.to raise_error("sort_order must be higher than 0")
end
it "prevents from using too large sort_order" do
expect do
version.upload_screenshot!(screenshot_path, 11, "English", 'iphone4', false)
end.to raise_error("sort_order must not be > 10")
end
# not really sure if we want to enforce that
# it "prevents from letting holes in sort_orders" do
# expect do
# version.upload_screenshot!(screenshot_path, 4, "English", 'iphone4', false)
# end.to raise_error "FIXME"
# end
it "prevent from using invalid language" do
expect do
version.upload_screenshot!(screenshot_path, 1, "NotALanguage", 'iphone4', false)
end.to raise_error("App Store Connect error: NotALanguage isn't an activated language")
end
it "prevent from using invalid language" do
expect do
version.upload_screenshot!(screenshot_path, 1, "English_CA", 'iphone4', false)
end.to raise_error("App Store Connect error: English_CA isn't an activated language")
end
it "prevent from using invalid device" do
expect do
version.upload_screenshot!(screenshot_path, 1, "English", :android, false)
end.to raise_error("App Store Connect error: android isn't a valid device name")
end
end
describe "Add, Replace, Remove screenshots" do
before do
allow(Spaceship::Utilities).to receive(:md5digest).and_return("FAKEMD5")
end
it "can add a new screenshot to the list" do
du_upload_screenshot_success
count = version.screenshots["English"].count
version.upload_screenshot!(screenshot_path, 4, "English", 'iphone4', false)
expect(version.screenshots["English"].count).to eq(count + 1)
end
it "can add a new iMessage screenshot to the list" do
du_upload_messages_screenshot_success
count = version.screenshots["English"].count
version.upload_screenshot!(screenshot_path, 4, "English", 'iphone4', true)
expect(version.screenshots["English"].count).to eq(count + 1)
end
it "auto-sets the 'scaled' parameter when the user provides a screenshot" do
def fetch_family(device_type, language)
lang_details = version.raw_data["details"]["value"].find { |a| a["language"] == language }
return lang_details["displayFamilies"]["value"].find { |value| value["name"] == device_type }
end
device_type = "iphone35"
language = "English"
du_upload_screenshot_success
family = fetch_family(device_type, language)
expect(family["scaled"]["value"]).to eq(true)
version.upload_screenshot!(screenshot_path, 1, language, device_type, false)
family = fetch_family(device_type, language)
expect(family["scaled"]["value"]).to eq(false)
end
it "auto-sets the 'scaled' parameter when the user provides an iMessage screenshot" do
def fetch_family(device_type, language)
lang_details = version.raw_data["details"]["value"].find { |a| a["language"] == language }
return lang_details["displayFamilies"]["value"].find { |value| value["name"] == device_type }
end
device_type = "iphone4"
language = "English"
du_upload_messages_screenshot_success
family = fetch_family(device_type, language)
expect(family["messagesScaled"]["value"]).to eq(true)
version.upload_screenshot!(screenshot_path, 1, language, device_type, true)
family = fetch_family(device_type, language)
expect(family["messagesScaled"]["value"]).to eq(false)
end
it "can replace an existing screenshot with existing sort_order" do
du_upload_screenshot_success
count = version.screenshots["English"].count
version.upload_screenshot!(screenshot_path, 2, "English", 'iphone4', false)
expect(version.screenshots["English"].count).to eq(count)
end
it "can remove existing screenshot" do
count = version.screenshots["English"].count
version.upload_screenshot!(nil, 2, "English", 'iphone4', false)
expect(version.screenshots["English"].count).to eq(count - 1)
end
it "fails with error if the screenshot to remove doesn't exist" do
expect do
version.upload_screenshot!(nil, 5, "English", 'iphone4', false)
end.to raise_error("cannot remove screenshot with nonexistent sort_order")
end
end
end
it "allows modifications of localized values" do
new_title = 'New Title'
version.description["English"] = new_title
lang = version.languages.find { |a| a['language'] == "English" }
expect(lang['description']['value']).to eq(new_title)
end
describe "Pushing the changes back to the server" do
it "raises an exception if there was an error" do
TunesStubbing.itc_stub_invalid_update
expect do
version.save!
end.to raise_error("[German]: The App Name you entered has already been used. [English]: The App Name you entered has already been used. You must provide an address line. There are errors on the page and for 2 of your localizations.")
end
it "works with valid update data" do
TunesStubbing.itc_stub_valid_update
expect(client).to receive(:update_app_version!).with('898536088', 812_106_519, version.raw_data)
version.save!
end
it "overwrites release_upon_approval if auto_release_date is set" do
TunesStubbing.itc_stub_valid_version_update_with_autorelease_and_release_on_datetime
version.release_on_approval = true
version.auto_release_date = 1_480_435_200_000
returned = Spaceship::Tunes::AppVersion.new(version.save!)
expect(returned.release_on_approval).to eq(false)
expect(returned.auto_release_date).to eq(1_480_435_200_000)
end
end
describe "update_app_version! retry mechanism" do
let(:update_success_data) { JSON.parse(TunesStubbing.itc_read_fixture_file('update_app_version_success.json'))['data'] }
def setup_handle_itc_response_failure(nb_failures)
@times_called = 0
allow(client).to receive(:handle_itc_response) do |data|
@times_called += 1
raise Spaceship::TunesClient::ITunesConnectTemporaryError, "simulated try again" if @times_called <= nb_failures
update_success_data
end
# arbitrary stub to prevent mock network failures. We override itc_response
TunesStubbing.itc_stub_valid_update
end
def setup_handle_itc_potential_server_failure(nb_failures)
@times_called = 0
allow(client).to receive(:handle_itc_response) do |data|
@times_called += 1
raise Spaceship::TunesClient::ITunesConnectPotentialServerError, "simulated try again" if @times_called <= nb_failures
update_success_data
end
# arbitrary stub to prevent mock network failures. We override itc_response
TunesStubbing.itc_stub_valid_update
end
it "retries when ITC is temporarily unable to save changes" do
setup_handle_itc_response_failure(1)
version.save!
expect(@times_called).to eq(2)
end
it "retries when ITC throws an error and it might be a server issue" do
setup_handle_itc_potential_server_failure(1)
version.save!
expect(@times_called).to eq(2)
end
it "retries a maximum number of times when ITC is temporarily unable to save changes" do
setup_handle_itc_response_failure(6) # set to more than should happen
expect do
version.save!
end.to raise_error(Spaceship::TunesClient::ITunesConnectTemporaryError)
expect(@times_called).to eq(5)
end
it "retries a maximum number of times when ITC is not responding properly" do
setup_handle_itc_potential_server_failure(4) # set to more than should happen
expect do
version.save!
end.to raise_error(Spaceship::TunesClient::ITunesConnectPotentialServerError)
expect(@times_called).to eq(3)
end
end
describe "Accessing different languages" do
it "raises an exception if language is not available" do
expect do
version.description["ja-JP"]
end.to raise_error("Language 'ja-JP' is not activated / available for this app version.")
end
# it "allows the creation of a new language" do
# version.create_languages!(['German', 'English_CA'])
# expect(version.name['German']).to eq("yep, that's the name")
# expect(version.name['English_CA']).to eq("yep, that's the name")
# end
end
describe "Rejecting" do
it 'rejects' do
TunesStubbing.itc_stub_reject_version_success
version.can_reject_version = true
expect(client).to receive(:reject!).with('898536088', 812_106_519)
version.reject!
end
it 'raises exception when not rejectable' do
TunesStubbing.itc_stub_valid_update
expect do
version.reject!
end.to raise_error("Version not rejectable")
end
end
end
describe "Modifying the app live version" do
let(:version) { app.live_version }
describe "Generate promo codes", focus: true do
it "fetches remaining promocodes" do
promocodes = version.generate_promocodes!(1)
expect(promocodes.effective_date).to eq(1_457_864_552_300)
expect(promocodes.expiration_date).to eq(1_460_283_752_300)
expect(promocodes.username).to eq('joe@wewanttoknow.com')
expect(promocodes.codes.count).to eq(1)
expect(promocodes.codes[0]).to eq('6J49JFRPTXXXX')
expect(promocodes.version.app_id).to eq(816_549_081)
expect(promocodes.version.app_name).to eq('DragonBox Numbers')
expect(promocodes.version.version).to eq('1.5.0')
expect(promocodes.version.platform).to eq('ios')
expect(promocodes.version.number_of_codes).to eq(3)
expect(promocodes.version.maximum_number_of_codes).to eq(100)
expect(promocodes.version.contract_file_name).to eq('promoCodes/ios/spqr5/PromoCodeHolderTermsDisplay_en_us.html')
end
end
end
describe "Validate attachment file" do
before { Spaceship::Tunes.login }
let(:client) { Spaceship::AppVersion.client }
describe "successfully loads and parses the app version and attachment" do
it "contains the right information" do
TunesStubbing.itc_stub_app_attachment
v = app.edit_version(platform: 'ios')
expect(v.review_attachment_file.original_file_name).to eq("attachment.txt")
expect(v.review_attachment_file.asset_token).to eq("test/v4/02/88/4d/02884d3d-92ea-5e6a-2a7b-b19da39f73a6/attachment.txt")
expect(v.review_attachment_file.url).to eq("https://iosapps-ssl.itunes.apple.com/itunes-assets/test/v4/02/88/4d/02884d3d-92ea-5e6a-2a7b-b19da39f73a6/attachment.txt")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/app_details_spec.rb | spaceship/spec/tunes/app_details_spec.rb | describe Spaceship::Tunes::AppDetails do
include_examples "common spaceship login"
let(:client) { Spaceship::AppVersion.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
describe "App Details are properly loaded" do
it "contains all the relevant information" do
details = app.details
expect(details.name['en-US']).to eq("Updated by fastlane")
expect(details.privacy_url['en-US']).to eq('https://fastlane.tools')
expect(details.primary_category).to eq('MZGenre.Sports')
end
end
describe "Modifying the app category" do
it "prefixes the category with MZGenre for all category types" do
details = app.details
details.primary_category = "Weather"
expect(details.primary_category).to eq("MZGenre.Weather")
details.primary_first_sub_category = "Weather"
expect(details.primary_first_sub_category).to eq("MZGenre.Weather")
details.primary_second_sub_category = "Weather"
expect(details.primary_second_sub_category).to eq("MZGenre.Weather")
details.secondary_category = "Weather"
expect(details.secondary_category).to eq("MZGenre.Weather")
details.secondary_first_sub_category = "Weather"
expect(details.secondary_first_sub_category).to eq("MZGenre.Weather")
details.secondary_second_sub_category = "Weather"
expect(details.secondary_second_sub_category).to eq("MZGenre.Weather")
end
it "prefixes the category with MZGenre.Apps for Stickers types" do
details = app.details
details.primary_category = "Stickers"
expect(details.primary_category).to eq("MZGenre.Apps.Stickers")
details.primary_first_sub_category = "Stickers.Art"
expect(details.primary_first_sub_category).to eq("MZGenre.Apps.Stickers.Art")
details.primary_second_sub_category = "Stickers.Art"
expect(details.primary_second_sub_category).to eq("MZGenre.Apps.Stickers.Art")
details.secondary_category = "Stickers"
expect(details.secondary_category).to eq("MZGenre.Apps.Stickers")
details.secondary_first_sub_category = "Stickers.Art"
expect(details.secondary_first_sub_category).to eq("MZGenre.Apps.Stickers.Art")
details.secondary_second_sub_category = "Stickers.Art"
expect(details.secondary_second_sub_category).to eq("MZGenre.Apps.Stickers.Art")
details.primary_category = "Apps.Stickers"
expect(details.primary_category).to eq("MZGenre.Apps.Stickers")
end
it "doesn't prefix if the prefix is already there" do
details = app.details
details.primary_category = "MZGenre.Weather"
expect(details.primary_category).to eq("MZGenre.Weather")
details.primary_category = "MZGenre.Apps.Stickers"
expect(details.primary_category).to eq("MZGenre.Apps.Stickers")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/iap_family_list_spec.rb | spaceship/spec/tunes/iap_family_list_spec.rb | describe Spaceship::Tunes::IAPFamilyList do
before { TunesStubbing.itc_stub_iap }
include_examples "common spaceship login"
let(:client) { Spaceship::Application.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
let(:purchase) { app.in_app_purchases }
describe "IAP FamilyList" do
it "Creates a Object" do
element = app.in_app_purchases.families.all.first
expect(element.class).to eq(Spaceship::Tunes::IAPFamilyList)
expect(element.name).to eq("Product name1234")
end
it "Loads Edit Version" do
edit_version = app.in_app_purchases.families.all.first.edit
expect(edit_version.class).to eq(Spaceship::Tunes::IAPFamilyDetails)
expect(edit_version.family_id).to eq("20373395")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/iap_list_spec.rb | spaceship/spec/tunes/iap_list_spec.rb | describe Spaceship::Tunes::IAPList do
before { TunesStubbing.itc_stub_iap }
include_examples "common spaceship login"
let(:client) { Spaceship::Application.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
let(:purchase) { app.in_app_purchases }
describe "IAPList" do
it "Creates a Object" do
element = app.in_app_purchases.find("go.find.me")
expect(element.class).to eq(Spaceship::Tunes::IAPList)
expect(element.product_id).to eq("go.find.me")
expect(element.status).to eq("Missing Metadata")
expect(element.type).to eq("Consumable")
end
it "Loads Edit Version" do
edit_version = app.in_app_purchases.find("go.find.me").edit
expect(edit_version.class).to eq(Spaceship::Tunes::IAPDetail)
expect(edit_version.product_id).to eq("go.find.me")
end
it "Loads Edit Version of Recurring IAP" do
edit_version = app.in_app_purchases.find("x.a.a.b.b.c.d.x.y.z").edit
expect(edit_version.class).to eq(Spaceship::Tunes::IAPDetail)
expect(edit_version.product_id).to eq("x.a.a.b.b.c.d.x.y.z")
expect(edit_version.pricing_intervals[0][:tier]).to eq(2)
expect(edit_version.pricing_intervals[0][:country]).to eq("BB")
end
it "can delete" do
deleted = app.in_app_purchases.find("go.find.me").delete!
expect(deleted).to eq(nil)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/language_item_spec.rb | spaceship/spec/tunes/language_item_spec.rb | describe Spaceship::Tunes::LanguageItem do
include_examples "common spaceship login"
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
describe "language code inspection" do
it "prints out all languages with their values" do
str = app.edit_version.description.inspect
expect(str).to eq("German: My title\nEnglish: Super Description here\n")
end
it "localCode is also used for language keys" do
# details.name uses `localCode` instead of `languages`
keys = app.details.name.keys
expect(keys).to eq(["en-US", "de-DE"])
end
it "localCode is also used for inspect method" do
# details.name uses `localeCode` instead of `languages`
inspect_string = app.details.name.inspect
expect(inspect_string).to eq("en-US: Updated by fastlane\nde-DE: why new itc 2\n")
end
it "localCode is also used for get_lang method" do
# details.name uses `localeCode` instead of `languages`
english_name = app.details.name["en-US"]
expect(english_name).to eq("Updated by fastlane")
end
it "ensure test data is setup as expected" do
# details.name uses `localeCode` instead of `languages`, so no nodes should exist for `languages`
original_array = app.details.name.original_array
locale_node = original_array.flat_map { |value| value["localeCode"] }
languages_node = original_array.each_with_object([]) do |value, languages|
language = value["languages"]
languages << language unless language.nil?
end
expect(locale_node).to eq(["en-US", "de-DE"])
expect(languages_node).to be_empty
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/iap_detail_spec.rb | spaceship/spec/tunes/iap_detail_spec.rb | describe Spaceship::Tunes::IAPDetail do
before { TunesStubbing.itc_stub_iap }
include_examples "common spaceship login"
let(:client) { Spaceship::Application.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
let(:detailed) { app.in_app_purchases.find("go.find.me").edit }
describe "Details of an IAP" do
it "Loads full details of a single iap" do
expect(detailed.class).to eq(Spaceship::Tunes::IAPDetail)
expect(detailed.reference_name).to eq("created by spaceship")
end
it "Read language versions" do
expect(detailed.versions["de-DE".to_sym][:name]).to eq("test name german1")
end
it "humanizes status" do
expect(detailed.status).to eq("Ready to Submit")
end
it "humanizes type" do
expect(detailed.type).to eq("Consumable")
end
it "read pricing_intervals" do
expect(detailed.pricing_intervals.first[:tier]).to eq(1)
expect(detailed.pricing_intervals.first[:country]).to eq("WW")
end
describe "pricing_info" do
subject { detailed.pricing_info }
context "when iap is not cleared for sale yet" do
before { allow(detailed).to receive(:cleared_for_sale).and_return(false) }
it "returns an empty array" do
expect(subject).to eq([])
end
end
context "when iap is a non-subscription product" do
let(:pricing_tiers) { client.pricing_tiers('898536088') }
let(:interval) do
{ tier: 1, begin_date: nil, end_date: nil, grandfathered: nil, country: "WW" }
end
before { expect(detailed).to receive(:pricing_intervals).at_least(:once).and_return([interval]) }
it "returns all pricing infos of the specified tier" do
expect(subject).to all(be_an(Spaceship::Tunes::PricingInfo))
expect(subject.size).to eq(48)
end
it "returns the matching entries from the price tier matrix" do
tier = pricing_tiers.find { |p| p.tier_stem == "1" }
expect(subject).to match_array(tier.pricing_info)
end
end
context "when iap is a subscription product with territorial pricing" do
let(:pricing_tiers) { client.subscription_pricing_tiers(app.apple_id) }
let(:intervals) do
[
{ tier: 22, begin_date: nil, end_date: nil, grandfathered: {}, country: "QA" },
{ tier: 10, begin_date: nil, end_date: nil, grandfathered: {}, country: "CL" }
]
end
before { allow(detailed).to receive(:pricing_intervals).at_least(:once).and_return(intervals) }
it "returns pricing infos for each country" do
expect(subject).to all(be_an(Spaceship::Tunes::IAPSubscriptionPricingInfo))
expect(subject.size).to eq(2)
end
it "returns the matching entries from the subscription price tier matrix" do
qa = pricing_tiers
.find { |t| t.tier_stem == "22" }
.pricing_info
.find { |p| p.country_code == "QA" }
cl = pricing_tiers
.find { |t| t.tier_stem == "10" }
.pricing_info
.find { |p| p.country_code == "CL" }
expect(subject).to contain_exactly(qa, cl)
end
end
end
end
describe "modification" do
it "saved" do
detailed.cleared_for_sale = false
expect(client).to receive(:update_iap!).with(app_id: '898536088', purchase_id: "1195137656", data: detailed.raw_data)
detailed.save!
end
it "saved and changed screenshot" do
detailed.review_screenshot = "#{Dir.tmpdir}/fastlane_tests"
expect(client.du_client).to receive(:upload_purchase_review_screenshot).and_return({ "token" => "tok", "height" => 100, "width" => 200, "md5" => "xxxx" })
expect(client.du_client).to receive(:get_picture_type).and_return("MZPFT.SortedScreenShot")
expect(Spaceship::Utilities).to receive(:content_type).and_return("image/jpg")
expect(client).to receive(:update_iap!).with(app_id: '898536088', purchase_id: "1195137656", data: detailed.raw_data)
detailed.save!
end
it "saved with subscription pricing goal" do
edited = app.in_app_purchases.find("x.a.a.b.b.c.d.x.y.z").edit
price_goal = TunesStubbing.itc_read_fixture_file('iap_price_goal_calc.json')
transformed_pricing_intervals = JSON.parse(price_goal)["data"].map do |language_code, value|
existing_interval =
edited.pricing_intervals.find { |interval| interval[:country] == language_code }
grandfathered =
if existing_interval
existing_interval[:grandfathered].clone
else
{ "value" => "FUTURE_NONE" }
end
{
"value" => {
"tierStem" => value["tierStem"],
"priceTierEffectiveDate" => value["priceTierEffectiveDate"],
"priceTierEndDate" => value["priceTierEndDate"],
"country" => language_code,
"grandfathered" => grandfathered
}
}
end
expect(client).to receive(:update_iap!).with(app_id: '898536088', purchase_id: "1195137657", data: edited.raw_data)
expect(client).to receive(:update_recurring_iap_pricing!).with(app_id: '898536088', purchase_id: "1195137657", pricing_intervals: transformed_pricing_intervals)
edited.subscription_price_target = { currency: "EUR", tier: 1 }
edited.save!
end
it "saved with changed pricing detail" do
edited = app.in_app_purchases.find("go.find.me").edit
expect(client).to receive(:update_iap!).with(app_id: '898536088', purchase_id: "1195137656", data: edited.raw_data)
edited.pricing_intervals = [
{
country: "WW",
begin_date: nil,
end_date: nil,
tier: 4
}
]
edited.save!
expect(edited.pricing_intervals).to eq([{ tier: 4, begin_date: nil, end_date: nil, grandfathered: nil, country: "WW" }])
end
it "saved with changed pricing detail for recurring product" do
edited = app.in_app_purchases.find("x.a.a.b.b.c.d.x.y.z").edit
edited.pricing_intervals = [
{
country: "WW",
begin_date: nil,
end_date: nil,
tier: 4
}
]
expect(client).to receive(:update_iap!).with(app_id: '898536088', purchase_id: "1195137657", data: edited.raw_data)
expect(client).to receive(:update_recurring_iap_pricing!).with(app_id: '898536088', purchase_id: "1195137657", pricing_intervals: edited.raw_data["pricingIntervals"])
edited.save!
end
it "saved with changed versions" do
edited = app.in_app_purchases.find("go.find.me").edit
expect(client).to receive(:update_iap!).with(app_id: '898536088', purchase_id: "1195137656", data: edited.raw_data)
edited.versions = {
'en-US' => {
name: "Edit It",
description: "Description has at least 10 characters"
}
}
edited.save!
expect(edited.versions).to eq({ "en-US": { name: "Edit It", description: "Description has at least 10 characters", id: nil, status: nil } })
end
end
describe "Deletion" do
it "delete" do
expect(client).to receive(:delete_iap!).with(app_id: '898536088', purchase_id: "1195137656")
detailed.delete!
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/iap_families_spec.rb | spaceship/spec/tunes/iap_families_spec.rb | describe Spaceship::Tunes::IAPFamilies do
before { TunesStubbing.itc_stub_iap }
include_examples "common spaceship login"
let(:client) { Spaceship::Application.client }
let(:app) { Spaceship::Application.all.find { |a| a.apple_id == "898536088" } }
let(:purchase) { app.in_app_purchases }
describe "Subscription Families" do
it "Loads IAP Families List" do
list = purchase.families.all
expect(list.kind_of?(Array)).to eq(true)
expect(list.first.name).to eq("Product name1234")
end
it "Creates a new IAP Subscription Family" do
purchase.families.create!(
reference_name: "First Product in Family",
product_id: "new.product",
name: "Family Name",
versions: {
'de-DE' => {
subscription_name: "Subname German",
name: 'App Name German'
},
'da' => {
subscription_name: "Subname DA",
name: 'App Name DA'
}
}
)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/spaceship/spec/tunes/build_train_spec.rb | spaceship/spec/tunes/build_train_spec.rb | # describe Spaceship::Tunes::BuildTrain do
# before { Spaceship::Tunes.login }
# subject { Spaceship::Tunes.client }
# let(:username) { 'spaceship@krausefx.com' }
# let(:password) { 'so_secret' }
# describe "properly parses the train" do
# let(:app) { Spaceship::Application.all.first }
# it "inspect works" do
# expect(Spaceship::Application.all.first.build_trains.values.first.inspect).to include("Tunes::BuildTrain")
# end
# it "works filled in all required values (appletvos)" do
# trains = app.build_trains(platform: 'appletvos')
# expect(trains.count).to eq(2)
# train = trains.values.first
# expect(train.version_string).to eq("1.0")
# expect(train.platform).to eq("appletvos")
# expect(train.application).to eq(app)
# # TestFlight
# expect(trains.values.first.external_testing_enabled).to eq(false)
# expect(trains.values.first.internal_testing_enabled).to eq(true)
# expect(trains.values.last.external_testing_enabled).to eq(false)
# expect(trains.values.last.internal_testing_enabled).to eq(false)
# end
# it "works filled in all required values (ios)" do
# trains = app.build_trains(platform: 'ios')
# expect(trains.count).to eq(2)
# train = trains.values.first
# expect(train.version_string).to eq("1.0")
# expect(train.platform).to eq("ios")
# expect(train.application).to eq(app)
# # TestFlight
# expect(trains.values.first.external_testing_enabled).to eq(false)
# expect(trains.values.first.internal_testing_enabled).to eq(true)
# expect(trains.values.last.external_testing_enabled).to eq(false)
# expect(trains.values.last.internal_testing_enabled).to eq(false)
# end
# it "returns all processing builds (ios)" do
# builds = app.all_processing_builds(platform: 'ios')
# expect(builds.count).to eq(3)
# end
# it "returns all processing builds (tvos)" do
# builds = app.all_processing_builds(platform: 'appletvos')
# expect(builds.count).to eq(3)
# end
# describe "Accessing builds (ios)" do
# it "lets the user fetch the builds for a given train" do
# train = app.build_trains(platform: 'ios').values.first
# expect(train.builds.count).to eq(1)
# end
# it "lets the user fetch the builds using the version as a key" do
# train = app.build_trains(platform: 'ios')['1.0']
# expect(train.version_string).to eq('1.0')
# expect(train.platform).to eq('ios')
# expect(train.internal_testing_enabled).to eq(true)
# expect(train.external_testing_enabled).to eq(false)
# expect(train.builds.count).to eq(1)
# end
# end
# describe "Accessing builds (tvos)" do
# it "lets the user fetch the builds for a given train" do
# train = app.build_trains(platform: 'appletvos').values.first
# expect(train.builds.count).to eq(1)
# end
# it "lets the user fetch the builds using the version as a key" do
# train = app.build_trains['1.0']
# expect(train.version_string).to eq('1.0')
# expect(train.platform).to eq('appletvos')
# expect(train.internal_testing_enabled).to eq(true)
# expect(train.external_testing_enabled).to eq(false)
# expect(train.builds.count).to eq(1)
# end
# end
# describe "Processing builds (ios)" do
# it "properly extracted the processing builds from a train" do
# train = app.build_trains(platform: 'ios')['1.0']
# expect(train.platform).to eq('ios')
# expect(train.processing_builds.count).to eq(0)
# end
# end
# describe "Processing builds (tvos)" do
# it "properly extracted the processing builds from a train" do
# train = app.build_trains(platform: 'appletvos')['1.0']
# expect(train.platform).to eq('appletvos')
# expect(train.processing_builds.count).to eq(0)
# end
# end
# describe "#update_testing_status (ios)" do
# it "just works (tm)" do
# train1 = app.build_trains(platform: 'ios')['1.0']
# train2 = app.build_trains(platform: 'ios')['1.1']
# expect(train1.platform).to eq('ios')
# expect(train2.platform).to eq('ios')
# expect(train1.internal_testing_enabled).to eq(true)
# expect(train2.internal_testing_enabled).to eq(false)
# train2.update_testing_status!(true, 'internal')
# expect(train2.internal_testing_enabled).to eq(true)
# end
# end
# describe "#update_testing_status (tvos)" do
# it "just works (tm)" do
# train1 = app.build_trains(platform: 'appletvos')['1.0']
# train2 = app.build_trains(platform: 'appletvos')['1.1']
# expect(train1.platform).to eq('appletvos')
# expect(train2.platform).to eq('appletvos')
# expect(train1.internal_testing_enabled).to eq(true)
# expect(train2.internal_testing_enabled).to eq(false)
# train2.update_testing_status!(true, 'internal')
# expect(train2.internal_testing_enabled).to eq(true)
# end
# end
# end
# end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.