spaceship_stub 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/spaceship_stub/tunes_stubbing.rb +450 -0
- data/lib/spaceship_stub.rb +73 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3b7c781e095754dd529ada37308e4015e4c3dd9
|
4
|
+
data.tar.gz: a047ecbf4eb7b522d7ae003b56090084be024abb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 725fb241162412e57113cfdff8a5b4ce644088042f08f05afc5d90e54d2ee0d1269dc33c96b0581339a3930b5a2365edc958c4bef92e42405602e7b800c1a3c4
|
7
|
+
data.tar.gz: b5ec0f7f721a800fe3b97a99e237cc2bd10e4b2e36a610ea512cdc4f2b580f0a34f2de33b473c58f8652e9d93858ab32a5e713a3a8c32cca91a84e00e961785d
|
@@ -0,0 +1,450 @@
|
|
1
|
+
# rubocop:disable Metrics/ClassLength
|
2
|
+
class TunesStubbing
|
3
|
+
class << self
|
4
|
+
def itc_read_fixture_file(filename)
|
5
|
+
File.read(File.join('spaceship', 'spec', 'tunes', 'fixtures', filename))
|
6
|
+
end
|
7
|
+
|
8
|
+
# Necessary, as we're now running this in a different context
|
9
|
+
def stub_request(*args)
|
10
|
+
WebMock::API.stub_request(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def itc_stub_login
|
14
|
+
# Retrieving the current login URL
|
15
|
+
itc_service_key_path = File.expand_path("~/Library/Caches/spaceship_itc_service_key.txt")
|
16
|
+
File.delete(itc_service_key_path) if File.exist?(itc_service_key_path)
|
17
|
+
|
18
|
+
stub_request(:get, 'https://itunesconnect.apple.com/itc/static-resources/controllers/login_cntrl.js').
|
19
|
+
to_return(status: 200, body: itc_read_fixture_file('login_cntrl.js'))
|
20
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa").
|
21
|
+
to_return(status: 200, body: "")
|
22
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa").
|
23
|
+
to_return(status: 200, body: "")
|
24
|
+
stub_request(:get, "https://olympus.itunes.apple.com/v1/session").
|
25
|
+
to_return(status: 200, body: "") # we don't actually care about the body
|
26
|
+
stub_request(:get, "https://olympus.itunes.apple.com/v1/app/config?hostname=itunesconnect.apple.com").
|
27
|
+
to_return(status: 200, body: { authServiceKey: 'e0abc' }.to_json, headers: { 'Content-Type' => 'application/json' })
|
28
|
+
|
29
|
+
# Actual login
|
30
|
+
stub_request(:post, "https://idmsa.apple.com/appleauth/auth/signin").
|
31
|
+
with(body: { "accountName" => "spaceship@krausefx.com", "password" => "so_secret", "rememberMe" => true }.to_json).
|
32
|
+
to_return(status: 200, body: '{}', headers: { 'Set-Cookie' => "myacinfo=abcdef;" })
|
33
|
+
|
34
|
+
# Failed login attempts
|
35
|
+
stub_request(:post, "https://idmsa.apple.com/appleauth/auth/signin").
|
36
|
+
with(body: { "accountName" => "bad-username", "password" => "bad-password", "rememberMe" => true }.to_json).
|
37
|
+
to_return(status: 401, body: '{}', headers: { 'Set-Cookie' => 'session=invalid' })
|
38
|
+
end
|
39
|
+
|
40
|
+
def itc_stub_applications
|
41
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/manageyourapps/summary/v2").
|
42
|
+
to_return(status: 200, body: itc_read_fixture_file('app_summary.json'), headers: { 'Content-Type' => 'application/json' })
|
43
|
+
|
44
|
+
# Create Version stubbing
|
45
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/version/create/1013943394").
|
46
|
+
with(body: "{\"version\":\"0.1\"}").
|
47
|
+
to_return(status: 200, body: itc_read_fixture_file('create_version_success.json'), headers: { 'Content-Type' => 'application/json' })
|
48
|
+
|
49
|
+
# Create Application
|
50
|
+
# Pre-Fill request
|
51
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2/?platformString=ios").
|
52
|
+
to_return(status: 200, body: itc_read_fixture_file('create_application_prefill_request.json'), headers: { 'Content-Type' => 'application/json' })
|
53
|
+
|
54
|
+
# Actual success request
|
55
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2").
|
56
|
+
to_return(status: 200, body: itc_read_fixture_file('create_application_success.json'), headers: { 'Content-Type' => 'application/json' })
|
57
|
+
|
58
|
+
# Overview of application to get the versions
|
59
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/1013943394/overview").
|
60
|
+
to_return(status: 200, body: itc_read_fixture_file('app_overview.json'), headers: { 'Content-Type' => 'application/json' })
|
61
|
+
|
62
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/overview").
|
63
|
+
to_return(status: 200, body: itc_read_fixture_file('app_overview.json'), headers: { 'Content-Type' => 'application/json' })
|
64
|
+
|
65
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/1000000000/overview").
|
66
|
+
to_return(status: 200, body: itc_read_fixture_file('app_overview_stuckinprepare.json'), headers: { 'Content-Type' => 'application/json' })
|
67
|
+
|
68
|
+
# App Details
|
69
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/details").
|
70
|
+
to_return(status: 200, body: itc_read_fixture_file('app_details.json'), headers: { 'Content-Type' => 'application/json' })
|
71
|
+
|
72
|
+
# Versions History
|
73
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/stateHistory?platform=ios").
|
74
|
+
to_return(status: 200, body: itc_read_fixture_file('app_versions_history.json'), headers: { 'Content-Type' => 'application/json' })
|
75
|
+
|
76
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/versions/814624685/stateHistory?platform=ios").
|
77
|
+
to_return(status: 200, body: itc_read_fixture_file('app_version_states_history.json'), headers: { 'Content-Type' => 'application/json' })
|
78
|
+
end
|
79
|
+
|
80
|
+
def itc_stub_ratings
|
81
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/reviews/summary").
|
82
|
+
to_return(status: 200, body: itc_read_fixture_file('ratings.json'), headers: { 'Content-Type' => 'application/json' })
|
83
|
+
|
84
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/reviews/summary?storefront=US").
|
85
|
+
to_return(status: 200, body: itc_read_fixture_file('ratings_US.json'), headers: { 'Content-Type' => 'application/json' })
|
86
|
+
|
87
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/reviews?index=0&storefront=US&versionId=").
|
88
|
+
to_return(status: 200, body: itc_read_fixture_file('review_by_storefront.json'), headers: { 'Content-Type' => 'application/json' })
|
89
|
+
end
|
90
|
+
|
91
|
+
def itc_stub_build_details
|
92
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/buildHistory?platform=ios").
|
93
|
+
to_return(status: 200, body: itc_read_fixture_file('build_history.json'), headers: { 'Content-Type' => 'application/json' })
|
94
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/2.0.1/buildHistory?platform=ios").
|
95
|
+
to_return(status: 200, body: itc_read_fixture_file('build_history_for_train.json'), headers: { 'Content-Type' => 'application/json' })
|
96
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/trains/2.0.1/builds/4/details").
|
97
|
+
to_return(status: 200, body: itc_read_fixture_file('build_details.json'), headers: { 'Content-Type' => 'application/json' })
|
98
|
+
end
|
99
|
+
|
100
|
+
def itc_stub_candiate_builds
|
101
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/versions/812106519/candidateBuilds").
|
102
|
+
to_return(status: 200, body: itc_read_fixture_file('candiate_builds.json'), headers: { 'Content-Type' => 'application/json' })
|
103
|
+
end
|
104
|
+
|
105
|
+
def itc_stub_applications_first_create
|
106
|
+
# Create First Application
|
107
|
+
# Pre-Fill request
|
108
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2/?platformString=ios").
|
109
|
+
to_return(status: 200, body: itc_read_fixture_file('create_application_prefill_first_request.json'), headers: { 'Content-Type' => 'application/json' })
|
110
|
+
end
|
111
|
+
|
112
|
+
def itc_stub_applications_broken_first_create
|
113
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2").
|
114
|
+
to_return(status: 200, body: itc_read_fixture_file('create_application_first_broken.json'), headers: { 'Content-Type' => 'application/json' })
|
115
|
+
end
|
116
|
+
|
117
|
+
def itc_stub_broken_create
|
118
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2").
|
119
|
+
to_return(status: 200, body: itc_read_fixture_file('create_application_broken.json'), headers: { 'Content-Type' => 'application/json' })
|
120
|
+
end
|
121
|
+
|
122
|
+
def itc_stub_broken_create_wildcard
|
123
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/create/v2").
|
124
|
+
to_return(status: 200, body: itc_read_fixture_file('create_application_wildcard_broken.json'), headers: { 'Content-Type' => 'application/json' })
|
125
|
+
end
|
126
|
+
|
127
|
+
def itc_stub_app_versions
|
128
|
+
# Receiving app version
|
129
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/813314674").
|
130
|
+
to_return(status: 200, body: itc_read_fixture_file('app_version.json'), headers: { 'Content-Type' => 'application/json' })
|
131
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/113314675").
|
132
|
+
to_return(status: 200, body: itc_read_fixture_file('app_version.json'), headers: { 'Content-Type' => 'application/json' })
|
133
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/1000000000/platforms/ios/versions/800000000").
|
134
|
+
to_return(status: 200, body: itc_read_fixture_file('app_version.json'), headers: { 'Content-Type' => 'application/json' })
|
135
|
+
end
|
136
|
+
|
137
|
+
def itc_stub_app_submissions
|
138
|
+
# Start app submission
|
139
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/versions/812106519/submit/summary").
|
140
|
+
to_return(status: 200, body: itc_read_fixture_file('app_submission/start_success.json'), headers: { 'Content-Type' => 'application/json' })
|
141
|
+
|
142
|
+
# Complete app submission
|
143
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/version/submit/complete").
|
144
|
+
to_return(status: 200, body: itc_read_fixture_file('app_submission/complete_success.json'), headers: { 'Content-Type' => 'application/json' })
|
145
|
+
end
|
146
|
+
|
147
|
+
def itc_stub_app_submissions_already_submitted
|
148
|
+
# Start app submission
|
149
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/versions/812106519/submit/summary").
|
150
|
+
to_return(status: 200, body: itc_read_fixture_file('app_submission/start_success.json'), headers: { 'Content-Type' => 'application/json' })
|
151
|
+
|
152
|
+
# Complete app submission
|
153
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/version/submit/complete").
|
154
|
+
to_return(status: 200, body: itc_read_fixture_file('app_submission/complete_failed.json'), headers: { 'Content-Type' => 'application/json' })
|
155
|
+
end
|
156
|
+
|
157
|
+
def itc_stub_app_submissions_invalid
|
158
|
+
# Start app submission
|
159
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/versions/812106519/submit/summary").
|
160
|
+
to_return(status: 200, body: itc_read_fixture_file('app_submission/start_failed.json'), headers: { 'Content-Type' => 'application/json' })
|
161
|
+
end
|
162
|
+
|
163
|
+
def itc_stub_resolution_center
|
164
|
+
# Called from the specs to simulate invalid server responses
|
165
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/resolutionCenter?v=latest").
|
166
|
+
to_return(status: 200, body: itc_read_fixture_file('app_resolution_center.json'), headers: { 'Content-Type' => 'application/json' })
|
167
|
+
|
168
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/resolutionCenter?v=latest").
|
169
|
+
to_return(status: 200, body: itc_read_fixture_file('app_resolution_center.json'), headers: { 'Content-Type' => 'application/json' })
|
170
|
+
end
|
171
|
+
|
172
|
+
def itc_stub_build_trains
|
173
|
+
%w(internal external).each do |type|
|
174
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?platform=ios&testingType=#{type}").
|
175
|
+
to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: { 'Content-Type' => 'application/json' })
|
176
|
+
|
177
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?platform=appletvos&testingType=#{type}").
|
178
|
+
to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: { 'Content-Type' => 'application/json' })
|
179
|
+
|
180
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/trains/?testingType=#{type}").
|
181
|
+
to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: { 'Content-Type' => 'application/json' })
|
182
|
+
|
183
|
+
# Update build trains
|
184
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/testingTypes/#{type}/trains/").
|
185
|
+
to_return(status: 200, body: itc_read_fixture_file('build_trains.json'), headers: { 'Content-Type' => 'application/json' })
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def itc_stub_testers
|
190
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/pre/int").
|
191
|
+
to_return(status: 200, body: itc_read_fixture_file('testers/get_internal.json'), headers: { 'Content-Type' => 'application/json' })
|
192
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/pre/ext").
|
193
|
+
to_return(status: 200, body: itc_read_fixture_file('testers/get_external.json'), headers: { 'Content-Type' => 'application/json' })
|
194
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/user/internalTesters/898536088/").
|
195
|
+
to_return(status: 200, body: itc_read_fixture_file('testers/existing_internal_testers.json'), headers: { 'Content-Type' => 'application/json' })
|
196
|
+
|
197
|
+
# Creating new testers is stubbed in `testers_spec.rb`
|
198
|
+
end
|
199
|
+
|
200
|
+
def itc_stub_testflight
|
201
|
+
%w(appletvos ios).each do |type|
|
202
|
+
# Test information
|
203
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/#{type}/trains/1.0/builds/10/testInformation").
|
204
|
+
to_return(status: 200, body: itc_read_fixture_file("testflight_build_info_#{type}.json"), headers: { 'Content-Type' => 'application/json' })
|
205
|
+
|
206
|
+
# Reject review
|
207
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/#{type}/trains/1.0/builds/10/reject").
|
208
|
+
with(body: "{}").
|
209
|
+
to_return(status: 200, body: "{}", headers: { 'Content-Type' => 'application/json' })
|
210
|
+
|
211
|
+
# Submission
|
212
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/#{type}/trains/1.0/builds/10/review/submit").
|
213
|
+
to_return(status: 200, body: itc_read_fixture_file("testflight_submission_submit_#{type}.json"), headers: { 'Content-Type' => 'application/json' })
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def itc_stub_resolution_center_valid
|
218
|
+
# Called from the specs to simulate valid server responses
|
219
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/resolutionCenter?v=latest").
|
220
|
+
to_return(status: 200, body: itc_read_fixture_file('app_resolution_center_valid.json'), headers: { 'Content-Type' => 'application/json' })
|
221
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/resolutionCenter?v=latest").
|
222
|
+
to_return(status: 200, body: itc_read_fixture_file('app_resolution_center_valid.json'), headers: { 'Content-Type' => 'application/json' })
|
223
|
+
end
|
224
|
+
|
225
|
+
def itc_stub_invalid_update
|
226
|
+
# Called from the specs to simulate invalid server responses
|
227
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/812106519").
|
228
|
+
to_return(status: 200, body: itc_read_fixture_file('update_app_version_failed.json'), headers: { 'Content-Type' => 'application/json' })
|
229
|
+
end
|
230
|
+
|
231
|
+
def itc_stub_valid_update
|
232
|
+
# Called from the specs to simulate valid server responses
|
233
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/812106519").
|
234
|
+
to_return(status: 200, body: itc_read_fixture_file("update_app_version_success.json"),
|
235
|
+
headers: { "Content-Type" => "application/json" })
|
236
|
+
end
|
237
|
+
|
238
|
+
def itc_stub_valid_version_update_with_autorelease_and_release_on_datetime
|
239
|
+
# Called from the specs to simulate valid server responses
|
240
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/platforms/ios/versions/812106519").
|
241
|
+
to_return(status: 200, body: itc_read_fixture_file("update_app_version_with_autorelease_overwrite_success.json"),
|
242
|
+
headers: { "Content-Type" => "application/json" })
|
243
|
+
end
|
244
|
+
|
245
|
+
def itc_stub_app_version_ref
|
246
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/version/ref").
|
247
|
+
to_return(status: 200, body: itc_read_fixture_file("app_version_ref.json"),
|
248
|
+
headers: { "Content-Type" => "application/json" })
|
249
|
+
end
|
250
|
+
|
251
|
+
def itc_stub_user_detail
|
252
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/user/detail").
|
253
|
+
to_return(status: 200, body: itc_read_fixture_file("user_detail.json"),
|
254
|
+
headers: { "Content-Type" => "application/json" })
|
255
|
+
end
|
256
|
+
|
257
|
+
def itc_stub_sandbox_testers
|
258
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/iap").
|
259
|
+
to_return(status: 200, body: itc_read_fixture_file("sandbox_testers.json"),
|
260
|
+
headers: { "Content-Type" => "application/json" })
|
261
|
+
end
|
262
|
+
|
263
|
+
def itc_stub_create_sandbox_tester
|
264
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/iap/add").
|
265
|
+
with(body: JSON.parse(itc_read_fixture_file("create_sandbox_tester_payload.json"))).
|
266
|
+
to_return(status: 200, body: itc_read_fixture_file("create_sandbox_tester.json"),
|
267
|
+
headers: { "Content-Type" => "application/json" })
|
268
|
+
end
|
269
|
+
|
270
|
+
def itc_stub_delete_sandbox_tester
|
271
|
+
body = JSON.parse(itc_read_fixture_file("delete_sandbox_tester_payload.json"))
|
272
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/iap/delete").
|
273
|
+
with(body: JSON.parse(itc_read_fixture_file("delete_sandbox_tester_payload.json")).to_json).
|
274
|
+
to_return(status: 200, body: itc_read_fixture_file("delete_sandbox_tester.json"),
|
275
|
+
headers: { "Content-Type" => "application/json" })
|
276
|
+
end
|
277
|
+
|
278
|
+
def itc_stub_pricing_tiers
|
279
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/pricing/matrix").
|
280
|
+
to_return(status: 200, body: itc_read_fixture_file("pricing_tiers.json"),
|
281
|
+
headers: { "Content-Type" => "application/json" })
|
282
|
+
end
|
283
|
+
|
284
|
+
def itc_stub_release_to_store
|
285
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/versions/812106519/releaseToStore").
|
286
|
+
with(body: "898536088").
|
287
|
+
to_return(status: 200, body: itc_read_fixture_file("update_app_version_success.json"),
|
288
|
+
headers: { "Content-Type" => "application/json" })
|
289
|
+
end
|
290
|
+
|
291
|
+
def itc_stub_promocodes
|
292
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/promocodes/versions").
|
293
|
+
to_return(status: 200, body: itc_read_fixture_file("promocodes.json"),
|
294
|
+
headers: { "Content-Type" => "application/json" })
|
295
|
+
end
|
296
|
+
|
297
|
+
def itc_stub_generate_promocodes
|
298
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/promocodes/versions/812106519").
|
299
|
+
to_return(status: 200, body: itc_read_fixture_file("promocodes_generated.json"),
|
300
|
+
headers: { "Content-Type" => "application/json" })
|
301
|
+
end
|
302
|
+
|
303
|
+
def itc_stub_promocodes_history
|
304
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/promocodes/history").
|
305
|
+
to_return(status: 200, body: itc_read_fixture_file("promocodes_history.json"),
|
306
|
+
headers: { "Content-Type" => "application/json" })
|
307
|
+
end
|
308
|
+
|
309
|
+
def itc_stub_iap
|
310
|
+
# pricing goal calculator
|
311
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/1195137656/pricing/equalize/EUR/1").
|
312
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_price_goal_calc.json"),
|
313
|
+
headers: { "Content-Type" => "application/json" })
|
314
|
+
# delete iap
|
315
|
+
stub_request(:delete, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/1194457865").
|
316
|
+
to_return(status: 200, body: "", headers: {})
|
317
|
+
# create consumable iap
|
318
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps").
|
319
|
+
with(body: itc_read_fixture_file("iap_create.json")).
|
320
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_detail.json"),
|
321
|
+
headers: { "Content-Type" => "application/json" })
|
322
|
+
|
323
|
+
# iap consumable template
|
324
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/consumable/template").
|
325
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_consumable_template.json"),
|
326
|
+
headers: { "Content-Type" => "application/json" })
|
327
|
+
# iap edit family
|
328
|
+
stub_request(:put, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/family/20373395/").
|
329
|
+
with(body: itc_read_fixture_file("iap_family_edit_versions.json")).
|
330
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_family_detail.json"),
|
331
|
+
headers: { "Content-Type" => "application/json" })
|
332
|
+
|
333
|
+
# iap edit family
|
334
|
+
stub_request(:put, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/family/20373395/").
|
335
|
+
with(body: itc_read_fixture_file("iap_family_edit.json")).
|
336
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_family_detail.json"),
|
337
|
+
headers: { "Content-Type" => "application/json" })
|
338
|
+
|
339
|
+
# iap family detail
|
340
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/family/20372345").
|
341
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_family_detail.json"),
|
342
|
+
headers: { "Content-Type" => "application/json" })
|
343
|
+
# create IAP family
|
344
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/family/").
|
345
|
+
with(body: JSON.parse(itc_read_fixture_file("iap_family_create.json"))).
|
346
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_family_create_success.json"), headers: { "Content-Type" => "application/json" })
|
347
|
+
|
348
|
+
# load IAP Family Template
|
349
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/family/template").
|
350
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_family_template.json"),
|
351
|
+
headers: { "Content-Type" => "application/json" })
|
352
|
+
|
353
|
+
# update IAP
|
354
|
+
stub_request(:put, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/1195137656").
|
355
|
+
with(body: JSON.parse(itc_read_fixture_file("iap_update.json"))).
|
356
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_detail.json"),
|
357
|
+
headers: { "Content-Type" => "application/json" })
|
358
|
+
|
359
|
+
# iap details
|
360
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/1194457865").
|
361
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_detail.json"),
|
362
|
+
headers: { "Content-Type" => "application/json" })
|
363
|
+
|
364
|
+
# list families
|
365
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/families").
|
366
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_families.json"),
|
367
|
+
headers: { "Content-Type" => "application/json" })
|
368
|
+
|
369
|
+
# list iaps
|
370
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps").
|
371
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_list.json"),
|
372
|
+
headers: { "Content-Type" => "application/json" })
|
373
|
+
|
374
|
+
# subscription pricing tiers
|
375
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/iaps/pricing/matrix/recurring").
|
376
|
+
to_return(status: 200, body: itc_read_fixture_file("iap_pricing_tiers.json"),
|
377
|
+
headers: { "Content-Type" => "application/json" })
|
378
|
+
end
|
379
|
+
|
380
|
+
def itc_stub_reject_version_success
|
381
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/versions/812106519/reject").
|
382
|
+
to_return(status: 200, body: itc_read_fixture_file("reject_app_version_success.json"),
|
383
|
+
headers: { "Content-Type" => "application/json" })
|
384
|
+
end
|
385
|
+
|
386
|
+
def itc_stub_supported_countries
|
387
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/pricing/supportedCountries").
|
388
|
+
to_return(status: 200, body: itc_read_fixture_file(File.join('supported_countries.json')),
|
389
|
+
headers: { 'Content-Type' => 'application/json' })
|
390
|
+
end
|
391
|
+
|
392
|
+
def itc_stub_app_pricing_intervals
|
393
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/pricing/intervals").
|
394
|
+
to_return(status: 200, body: itc_read_fixture_file(File.join('app_pricing_intervals.json')),
|
395
|
+
headers: { 'Content-Type' => 'application/json' })
|
396
|
+
end
|
397
|
+
|
398
|
+
def itc_stub_app_add_territory
|
399
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/pricing/intervals").
|
400
|
+
with(body: JSON.parse(itc_read_fixture_file(File.join('availability', 'add_request.json'))).to_json).
|
401
|
+
to_return(status: 200, body: itc_read_fixture_file(File.join('availability', 'add_response.json')),
|
402
|
+
headers: { 'Content-Type' => 'application/json' })
|
403
|
+
end
|
404
|
+
|
405
|
+
def itc_stub_app_remove_territory
|
406
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/pricing/intervals").
|
407
|
+
with(body: JSON.parse(itc_read_fixture_file(File.join('availability', 'remove_request.json'))).to_json).
|
408
|
+
to_return(status: 200, body: itc_read_fixture_file(File.join('availability', 'remove_response.json')),
|
409
|
+
headers: { 'Content-Type' => 'application/json' })
|
410
|
+
end
|
411
|
+
|
412
|
+
def itc_stub_app_uninclude_future_territories
|
413
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/898536088/pricing/intervals").
|
414
|
+
with(body: JSON.parse(itc_read_fixture_file(File.join('availability', 'uninclude_all_future_territories_request.json'))).to_json).
|
415
|
+
to_return(status: 200, body: itc_read_fixture_file(File.join('availability', 'uninclude_all_future_territories_response.json')),
|
416
|
+
headers: { 'Content-Type' => 'application/json' })
|
417
|
+
end
|
418
|
+
|
419
|
+
def itc_stub_members
|
420
|
+
# resend notification
|
421
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/itc/helmut@januschka.com/resendInvitation").
|
422
|
+
to_return(status: 200, body: "", headers: {})
|
423
|
+
|
424
|
+
# create member default (admin, all-apps)
|
425
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/itc/create").
|
426
|
+
with(body: JSON.parse(itc_read_fixture_file("member_create.json"))).
|
427
|
+
to_return(status: 200, body: "", headers: {})
|
428
|
+
|
429
|
+
# create member role: developer, apps: all
|
430
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/itc/create").
|
431
|
+
with(body: JSON.parse(itc_read_fixture_file("member_create_developer.json"))).
|
432
|
+
to_return(status: 200, body: "", headers: {})
|
433
|
+
|
434
|
+
# create member role: appmanager, apps: 12345
|
435
|
+
stub_request(:post, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/itc/create").
|
436
|
+
with(body: JSON.parse(itc_read_fixture_file("member_create_appmanager_single_app.json"))).
|
437
|
+
to_return(status: 200, body: "", headers: {})
|
438
|
+
|
439
|
+
# member template
|
440
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/itc/create").
|
441
|
+
to_return(status: 200, body: itc_read_fixture_file(File.join('member_template.json')),
|
442
|
+
headers: { "Content-Type" => "application/json" })
|
443
|
+
|
444
|
+
# Load member list
|
445
|
+
stub_request(:get, "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/ra/users/itc").
|
446
|
+
to_return(status: 200, body: itc_read_fixture_file(File.join('member_list.json')),
|
447
|
+
headers: { "Content-Type" => "application/json" })
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# require_relative 'client_stubbing'
|
2
|
+
# require_relative 'portal/portal_stubbing'
|
3
|
+
require_relative 'spaceship_stub/tunes_stubbing'
|
4
|
+
# require_relative 'du/du_stubbing'
|
5
|
+
|
6
|
+
module SpaceshipStub
|
7
|
+
class << self
|
8
|
+
def stub
|
9
|
+
# Ensure that no ENV vars which interfere with testing are set
|
10
|
+
set_auth_vars = [
|
11
|
+
'FASTLANE_SESSION',
|
12
|
+
'FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD',
|
13
|
+
'FASTLANE_PASSWORD'
|
14
|
+
].select { |var| ENV.key?(var) }
|
15
|
+
|
16
|
+
if set_auth_vars.any?
|
17
|
+
abort "[!] Please `unset` the following ENV vars which interfere with spaceship testing: #{set_auth_vars.join(', ')}".red
|
18
|
+
end
|
19
|
+
|
20
|
+
@cache_paths = [
|
21
|
+
File.expand_path("/tmp/spaceship_itc_service_key.txt")
|
22
|
+
]
|
23
|
+
|
24
|
+
@cache_paths.each { |path| try_delete path }
|
25
|
+
ENV["DELIVER_USER"] = "spaceship@krausefx.com"
|
26
|
+
ENV["DELIVER_PASSWORD"] = "so_secret"
|
27
|
+
ENV['SPACESHIP_AVOID_XCODE_API'] = 'true'
|
28
|
+
|
29
|
+
ENV.delete("FASTLANE_USER")
|
30
|
+
|
31
|
+
TunesStubbing.itc_stub_login
|
32
|
+
PortalStubbing.adp_stub_login
|
33
|
+
|
34
|
+
PortalStubbing.adp_stub_app_groups
|
35
|
+
PortalStubbing.adp_stub_apps
|
36
|
+
|
37
|
+
PortalStubbing.adp_stub_provisioning
|
38
|
+
PortalStubbing.adp_stub_certificates
|
39
|
+
PortalStubbing.adp_stub_devices
|
40
|
+
PortalStubbing.adp_stub_persons
|
41
|
+
PortalStubbing.adp_stub_website_pushes
|
42
|
+
|
43
|
+
TunesStubbing.itc_stub_applications
|
44
|
+
TunesStubbing.itc_stub_app_versions
|
45
|
+
TunesStubbing.itc_stub_build_trains
|
46
|
+
TunesStubbing.itc_stub_testers
|
47
|
+
TunesStubbing.itc_stub_testflight
|
48
|
+
TunesStubbing.itc_stub_app_version_ref
|
49
|
+
TunesStubbing.itc_stub_user_detail
|
50
|
+
TunesStubbing.itc_stub_sandbox_testers
|
51
|
+
TunesStubbing.itc_stub_create_sandbox_tester
|
52
|
+
TunesStubbing.itc_stub_delete_sandbox_tester
|
53
|
+
TunesStubbing.itc_stub_candiate_builds
|
54
|
+
TunesStubbing.itc_stub_pricing_tiers
|
55
|
+
TunesStubbing.itc_stub_release_to_store
|
56
|
+
TunesStubbing.itc_stub_promocodes
|
57
|
+
TunesStubbing.itc_stub_generate_promocodes
|
58
|
+
TunesStubbing.itc_stub_promocodes_history
|
59
|
+
TunesStubbing.itc_stub_supported_countries
|
60
|
+
TunesStubbing.itc_stub_iap
|
61
|
+
end
|
62
|
+
|
63
|
+
def unstub
|
64
|
+
@cache_paths.each { |path| try_delete path }
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def try_delete(path)
|
70
|
+
FileUtils.rm_f(path) if File.exist? path
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spaceship_stub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Minh Luong
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: stubbing out Fastlane::Spaceship for writing specs
|
14
|
+
email: en14vn@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/spaceship_stub.rb
|
20
|
+
- lib/spaceship_stub/tunes_stubbing.rb
|
21
|
+
homepage: https://github.com/luongm/spaceship_stub
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.2.2
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Rails gem for stubbing out Fastlane::Spaceship for writing specs
|
45
|
+
test_files: []
|