spaceship 0.31.8 → 0.31.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f34363edf546d130d7ab1c2d98cb1bcd9d57a358
4
- data.tar.gz: 7839f0cfd68685a391b87faa16dd2e781f258dee
3
+ metadata.gz: 3007b65bb9eddd5604158b7c809a0e6f05c4e8d6
4
+ data.tar.gz: 50ade9d99cea43718791fa7f48fa6f2855e91851
5
5
  SHA512:
6
- metadata.gz: 6e5b05cae3b0e1cbc8d97bdc48979cef96bb5ab39e3c5f1d56a924be78fd65a6cfa898be2ccffb052eb1ace9dfdeec6eb124eb38ce92d9052d525f7f05849972
7
- data.tar.gz: b34093969e1884de121c5e645bbd0d10757afabecfb9b718a20d7c3cd80a72a147b3c1df92ed8fe5aae8fc75ed34b9fa961b345566a28ae1b1e9c36c62602071
6
+ metadata.gz: 3c353f411cbd5de26fa6187889de6ebb47192f1e7a2fd151ebe3232adc4b171288716530ce89c155335b3379a94eeaff9a3cea0b4139bbca16b5a9f47d3b5cac
7
+ data.tar.gz: 8d05c8f60cfa4b79c21e63f56b7bdac0d8bee1a5d38067aa641491875941207ea311c21bc91dd17e74ffe9c4714dfe7ee673785aa633522e82d29dfe02dbc9db
@@ -28,6 +28,8 @@ module Spaceship
28
28
  # /tmp/spaceship[time]_[pid].log by default
29
29
  attr_accessor :logger
30
30
 
31
+ attr_accessor :csrf_tokens
32
+
31
33
  # Base class for errors that want to present their message as
32
34
  # preferred error info for fastlane error handling. See:
33
35
  # fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb
@@ -345,11 +347,15 @@ module Spaceship
345
347
  raise ex # re-raise the exception
346
348
  end
347
349
 
350
+ # memorize the last csrf tokens from responses
351
+ def csrf_tokens
352
+ @csrf_tokens || {}
353
+ end
354
+
348
355
  private
349
356
 
350
357
  def do_login(user, password)
351
358
  @loggedin = false
352
- @requested_csrf_token = nil
353
359
  ret = send_login_request(user, password) # different in subclasses
354
360
  @loggedin = true
355
361
  ret
@@ -365,11 +371,6 @@ module Spaceship
365
371
  end
366
372
  end
367
373
 
368
- # memorize the last csrf tokens from responses
369
- def csrf_tokens
370
- @csrf_tokens || {}
371
- end
372
-
373
374
  def request(method, url_or_path = nil, params = nil, headers = {}, &block)
374
375
  headers.merge!(csrf_tokens)
375
376
  headers['User-Agent'] = USER_AGENT
@@ -1,4 +1,5 @@
1
1
  module Spaceship
2
+ # rubocop:disable Metrics/ClassLength
2
3
  class PortalClient < Spaceship::Client
3
4
  #####################################################
4
5
  # @!group Init and Login
@@ -129,7 +130,7 @@ module Spaceship
129
130
  end
130
131
 
131
132
  def update_service_for_app(app, service)
132
- ensure_csrf
133
+ ensure_csrf(Spaceship::App)
133
134
 
134
135
  request(:post, service.service_uri, {
135
136
  teamId: team_id,
@@ -142,7 +143,7 @@ module Spaceship
142
143
  end
143
144
 
144
145
  def associate_groups_with_app(app, groups)
145
- ensure_csrf
146
+ ensure_csrf(Spaceship::AppGroup)
146
147
 
147
148
  request(:post, 'account/ios/identifiers/assignApplicationGroupToAppId.action', {
148
149
  teamId: team_id,
@@ -158,7 +159,7 @@ module Spaceship
158
159
  # We moved the ensure_csrf to the top of this method
159
160
  # as we got some users with issues around creating new apps
160
161
  # https://github.com/fastlane/fastlane/issues/5813
161
- ensure_csrf
162
+ ensure_csrf(Spaceship::App)
162
163
 
163
164
  ident_params = case type.to_sym
164
165
  when :explicit
@@ -188,6 +189,8 @@ module Spaceship
188
189
  end
189
190
 
190
191
  def delete_app!(app_id, mac: false)
192
+ ensure_csrf(Spaceship::App)
193
+
191
194
  r = request(:post, "account/#{platform_slug(mac)}/identifiers/deleteAppId.action", {
192
195
  teamId: team_id,
193
196
  appIdId: app_id
@@ -212,7 +215,7 @@ module Spaceship
212
215
  end
213
216
 
214
217
  def create_app_group!(name, group_id)
215
- ensure_csrf
218
+ ensure_csrf(Spaceship::AppGroup)
216
219
 
217
220
  r = request(:post, 'account/ios/identifiers/addApplicationGroup.action', {
218
221
  name: name,
@@ -223,7 +226,7 @@ module Spaceship
223
226
  end
224
227
 
225
228
  def delete_app_group!(app_group_id)
226
- ensure_csrf
229
+ ensure_csrf(Spaceship::AppGroup)
227
230
 
228
231
  r = request(:post, 'account/ios/identifiers/deleteApplicationGroup.action', {
229
232
  teamId: team_id,
@@ -262,7 +265,7 @@ module Spaceship
262
265
  end
263
266
 
264
267
  def create_device!(device_name, device_id, mac: false)
265
- ensure_csrf
268
+ ensure_csrf(Spaceship::Device)
266
269
 
267
270
  req = request(:post) do |r|
268
271
  r.url "https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/addDevice.action"
@@ -294,7 +297,7 @@ module Spaceship
294
297
  end
295
298
 
296
299
  def create_certificate!(type, csr, app_id = nil)
297
- ensure_csrf
300
+ ensure_csrf(Spaceship::Certificate)
298
301
 
299
302
  r = request(:post, 'account/ios/certificate/submitCertificateRequest.action', {
300
303
  teamId: team_id,
@@ -322,7 +325,7 @@ module Spaceship
322
325
  end
323
326
 
324
327
  def revoke_certificate!(certificate_id, type, mac: false)
325
- ensure_csrf
328
+ ensure_csrf(Spaceship::Certificate)
326
329
 
327
330
  r = request(:post, "account/#{platform_slug(mac)}/certificate/revokeCertificate.action", {
328
331
  teamId: team_id,
@@ -350,7 +353,9 @@ module Spaceship
350
353
  end
351
354
 
352
355
  def create_provisioning_profile!(name, distribution_method, app_id, certificate_ids, device_ids, mac: false, sub_platform: nil)
353
- ensure_csrf
356
+ # Calling provisioning_profiles uses a different api end point than creating or deleting them so we
357
+ # use a different entity to gather the csrf token
358
+ ensure_csrf(Spaceship::App)
354
359
 
355
360
  params = {
356
361
  teamId: team_id,
@@ -380,7 +385,9 @@ module Spaceship
380
385
  end
381
386
 
382
387
  def delete_provisioning_profile!(profile_id, mac: false)
383
- ensure_csrf
388
+ # Calling provisioning_profiles uses a different api end point than creating or deleting them so we
389
+ # use a different entity to gather the csrf token
390
+ ensure_csrf(Spaceship::App)
384
391
 
385
392
  r = request(:post, "account/#{platform_slug(mac)}/profile/deleteProvisioningProfile.action", {
386
393
  teamId: team_id,
@@ -390,7 +397,9 @@ module Spaceship
390
397
  end
391
398
 
392
399
  def repair_provisioning_profile!(profile_id, name, distribution_method, app_id, certificate_ids, device_ids, mac: false)
393
- ensure_csrf
400
+ # Calling provisioning_profiles uses a different api end point than creating or deleting them so we
401
+ # use a different entity to gather the csrf token
402
+ ensure_csrf(Spaceship::App)
394
403
 
395
404
  r = request(:post, "account/#{platform_slug(mac)}/profile/regenProvisioningProfile.action", {
396
405
  teamId: team_id,
@@ -407,27 +416,34 @@ module Spaceship
407
416
 
408
417
  private
409
418
 
410
- def ensure_csrf
411
- # It's important we store this state here
412
- # as we always want to request something at least once
413
- return unless @requested_csrf_token.nil?
419
+ # This is a cache of entity type (App, AppGroup, Certificate, Device) to csrf_tokens
420
+ def csrf_cache
421
+ @csrf_cache || {}
422
+ end
423
+
424
+ # Ensures that there are csrf tokens for the appropriate entity type
425
+ # Relies on store_csrf_tokens to set csrf_tokens to the appropriate value
426
+ # then stores that in the correct place in cache
427
+ def ensure_csrf(klass)
428
+ if csrf_cache[klass]
429
+ self.csrf_tokens = csrf_cache[klass]
430
+ return
431
+ end
414
432
 
415
- # Update 23rd August 2016
416
- # Instead of calling `Certificate::Production.all` we call `App.all`
417
- # We've had issues when we only requested certificates, instead of apps, we don't know why
418
- # Source: https://github.com/fastlane/fastlane/issues/5827
433
+ self.csrf_tokens = nil
419
434
 
420
435
  # If we directly create a new resource (e.g. app) without querying anything before
421
436
  # we don't have a valid csrf token, that's why we have to do at least one request
422
- App.all
437
+ klass.all
423
438
 
424
439
  # Update 18th August 2016
425
440
  # For some reason, we have to query the resource twice to actually get a valid csrf_token
426
441
  # I couldn't find out why, the first response does have a valid Set-Cookie header
427
442
  # But it still needs this second request
428
- App.all
443
+ klass.all
429
444
 
430
- @requested_csrf_token = true if csrf_tokens.count > 0
445
+ csrf_cache[klass] = self.csrf_tokens
431
446
  end
432
447
  end
448
+ # rubocop:enable Metrics/ClassLength
433
449
  end
@@ -1,4 +1,4 @@
1
1
  module Spaceship
2
- VERSION = "0.31.8".freeze
2
+ VERSION = "0.31.9".freeze
3
3
  DESCRIPTION = "Ruby library to access the Apple Dev Center and iTunes Connect".freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spaceship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.8
4
+ version: 0.31.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
@@ -391,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
391
  version: '0'
392
392
  requirements: []
393
393
  rubyforge_project:
394
- rubygems_version: 2.5.1
394
+ rubygems_version: 2.2.2
395
395
  signing_key:
396
396
  specification_version: 4
397
397
  summary: Ruby library to access the Apple Dev Center and iTunes Connect