spaceship_stub 0.0.3 → 0.0.4
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 +4 -4
- data/lib/spaceship_stub/spaceship/spec/portal/app_group_spec.rb +57 -0
- data/lib/spaceship_stub/spaceship/spec/portal/app_spec.rb +136 -0
- data/lib/spaceship_stub/spaceship/spec/portal/certificate_spec.rb +116 -0
- data/lib/spaceship_stub/spaceship/spec/portal/device_spec.rb +142 -0
- data/lib/spaceship_stub/spaceship/spec/portal/enterprise_spec.rb +28 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addAppId.action.apostroph.json +51 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addAppId.action.explicit.json +51 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addAppId.action.nopush.json +50 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addAppId.action.wildcard.json +49 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addApplicationGroup.action.json +22 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addDeviceResponse.action.json +30 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addDeviceResponse.action.plist +33 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/addWebsitePushId.action.json +22 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/aps_development.cer +0 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/certificateCreate.certRequest.json +44 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/certificateSigningRequest.certSigningRequest +16 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/create_profile_name_taken.txt +1 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/create_profile_success.json +64 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/deleteAppId.action.json +16 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/deleteApplicationGroup.action.json +16 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/deleteDevice.action.json +13 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/deleteProvisioningProfile.action.json +16 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/deleteWebsitePushId.action.json +16 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/dev_center_provisioning_profiles_response.json +829 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/download_certificate_failure.html +13 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/downloaded_provisioning_profile.mobileprovision +51 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/enableDevice.action.json +22 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/getAppIdDetail.action.json +55 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/getProvisioningProfileAdHoc.action.json +108 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/getProvisioningProfileAppStore.action.json +91 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/getProvisioningProfileDevelopment.action.json +108 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/getProvisioningProfiletvOSAppStore.action.json +93 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listApplicationGroups.action.json +30 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listApps.action.json +97 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listAppsMac.action.json +97 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listCertRequests.action.json +80 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevices.action.json +53 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevicesDisabled.action.json +71 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevicesPage1-2.action.json +65 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevicesPage2-2.action.json +23 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevicesTV.action.json +26 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevicesWatch.action.json +26 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevicesiPhone.action.json +44 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listDevicesiPod.action.json +26 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listProvisioningProfiles.action.json +126 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listProvisioningProfiles.action.plist +597 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listTeams.action.json +61 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listTeams_multiple.action.json +105 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/listWebsitePushIds.action.json +31 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/list_certificates_filtered.json +38 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/peopleList.json +34 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/profileContentDownload.action +0 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/repair_profile_success.json +65 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/repair_profile_tvos_success.json +66 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/revokeCertificate.action.json +56 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/submitCertificateRequest.action.json +59 -0
- data/lib/spaceship_stub/spaceship/spec/portal/fixtures/updateAppIdName.action.json +44 -0
- data/lib/spaceship_stub/spaceship/spec/portal/person_spec.rb +27 -0
- data/lib/spaceship_stub/spaceship/spec/portal/persons_spec.rb +19 -0
- data/lib/spaceship_stub/spaceship/spec/portal/portal_client_spec.rb +279 -0
- data/lib/spaceship_stub/spaceship/spec/portal/portal_permission_spec.rb +26 -0
- data/lib/spaceship_stub/spaceship/spec/portal/portal_stubbing.rb +293 -0
- data/lib/spaceship_stub/spaceship/spec/portal/tvos_profile_spec.rb +24 -0
- data/lib/spaceship_stub/spaceship/spec/portal/website_push_spec.rb +57 -0
- metadata +65 -1
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"creationTimestamp": "2015-04-29T16:07:12Z",
|
3
|
+
"resultCode": 0,
|
4
|
+
"userLocale": "en_US",
|
5
|
+
"protocolVersion": "QH65B2",
|
6
|
+
"requestId": "048120d0-d6eb-49b9-9c70-dff6ee4b3373",
|
7
|
+
"requestUrl": "https://developer.apple.com:443//services-account/QH65B2/account/ios/certificate/submitCertificateRequest.action?content-type=text/x-url-arguments&accept=application/json&requestId=048120d0-d6eb-49b9-9c70-dff6ee4b3373&userLocale=en_US&teamId=S56PJTAYEL",
|
8
|
+
"responseId": "a64fde92-de9e-46d2-b184-98af3d0a6c11",
|
9
|
+
"isAdmin": true,
|
10
|
+
"isMember": false,
|
11
|
+
"isAgent": false,
|
12
|
+
"pageNumber": null,
|
13
|
+
"pageSize": null,
|
14
|
+
"totalRecords": null,
|
15
|
+
"certRequest": {
|
16
|
+
"certRequestId": "ESF52FQGU6",
|
17
|
+
"statusCode": 4,
|
18
|
+
"statusString": "Issued",
|
19
|
+
"csrPlatform": "ios",
|
20
|
+
"dateRequestedString": "Apr 29, 2015",
|
21
|
+
"dateRequested": "2015-04-29T16:07:11Z",
|
22
|
+
"expirationDate": "2016-04-28T15:57:11Z",
|
23
|
+
"expirationDateString": "Apr 28, 2016",
|
24
|
+
"certificateId": "HG3FQ9M282",
|
25
|
+
"typeString": "APNs Production iOS",
|
26
|
+
"certificateType": {
|
27
|
+
"certificateTypeDisplayId": "UPV3DW712I",
|
28
|
+
"name": "APNs Production iOS",
|
29
|
+
"platform": "ios",
|
30
|
+
"permissionType": "production",
|
31
|
+
"distributionType": "production",
|
32
|
+
"distributionMethod": "push",
|
33
|
+
"ownerType": "bundle",
|
34
|
+
"daysOverlap": 364,
|
35
|
+
"maxActive": 2
|
36
|
+
},
|
37
|
+
"certificate": {
|
38
|
+
"name": null,
|
39
|
+
"certificateId": "HG3FQ9M282",
|
40
|
+
"serialNumber": "7C4B29A2943BACA0",
|
41
|
+
"status": "Issued",
|
42
|
+
"statusCode": 0,
|
43
|
+
"expirationDate": "2016-04-28",
|
44
|
+
"certificatePlatform": "ios",
|
45
|
+
"certificateType": {
|
46
|
+
"certificateTypeDisplayId": "UPV3DW712I",
|
47
|
+
"name": "APNs Production iOS",
|
48
|
+
"platform": "ios",
|
49
|
+
"permissionType": "production",
|
50
|
+
"distributionType": "production",
|
51
|
+
"distributionMethod": "push",
|
52
|
+
"ownerType": "bundle",
|
53
|
+
"daysOverlap": 364,
|
54
|
+
"maxActive": 2
|
55
|
+
},
|
56
|
+
"hasAskKey": false
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"creationTimestamp": "2015-06-16T07:47:39Z",
|
3
|
+
"resultCode": 0,
|
4
|
+
"userLocale": "en_US",
|
5
|
+
"protocolVersion": "QH65B2",
|
6
|
+
"requestId": "8ac49b41-3e33-4ad7-a4ec-11b8fec30b45",
|
7
|
+
"requestUrl": "https://developer.apple.com:443//services-account/QH65B2/account/ios/identifiers/getAppIdDetail.action",
|
8
|
+
"responseId": "348c13a8-fa35-4cac-b49e-09366fa1fa04",
|
9
|
+
"isAdmin": true,
|
10
|
+
"isMember": false,
|
11
|
+
"isAgent": true,
|
12
|
+
"appId": {
|
13
|
+
"appIdId": "B7JBD8LHAA",
|
14
|
+
"name": "The New Name",
|
15
|
+
"appIdPlatform": "ios",
|
16
|
+
"prefix": "5A997XSHK2",
|
17
|
+
"identifier": "net.sunapps.151",
|
18
|
+
"isWildCard": false,
|
19
|
+
"isDuplicate": false,
|
20
|
+
"features": {
|
21
|
+
"push": true,
|
22
|
+
"inAppPurchase": true,
|
23
|
+
"gameCenter": true,
|
24
|
+
"passbook": false,
|
25
|
+
"dataProtection": "",
|
26
|
+
"homeKit": false,
|
27
|
+
"cloudKitVersion": 1,
|
28
|
+
"iCloud": false,
|
29
|
+
"LPLF93JG7M": false,
|
30
|
+
"IAD53UNK2F": false,
|
31
|
+
"V66P55NK2I": false,
|
32
|
+
"SKC3T5S89Y": false,
|
33
|
+
"APG3427HIY": false,
|
34
|
+
"HK421J6T7P": false,
|
35
|
+
"WC421J6T7P": false
|
36
|
+
},
|
37
|
+
"enabledFeatures": ["gameCenter", "inAppPurchase", "push"],
|
38
|
+
"isDevPushEnabled": false,
|
39
|
+
"isProdPushEnabled": true,
|
40
|
+
"associatedApplicationGroupsCount": 0,
|
41
|
+
"associatedCloudContainersCount": 0,
|
42
|
+
"associatedIdentifiersCount": 0
|
43
|
+
}
|
44
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
describe Spaceship::Portal::Persons do
|
2
|
+
before { Spaceship.login }
|
3
|
+
let(:client) { Spaceship::Persons.client }
|
4
|
+
it "should factor a new person object" do
|
5
|
+
attrs = {
|
6
|
+
"personId" => "1234",
|
7
|
+
"firstName" => "Helmut",
|
8
|
+
"lastName" => "Januschka",
|
9
|
+
"email" => "helmut@januschka.com",
|
10
|
+
"developerStatus" => "active",
|
11
|
+
"dateJoined" => "XXXXX",
|
12
|
+
"teamMemberId" => "1234"
|
13
|
+
}
|
14
|
+
person = Spaceship::Portal::Person.factory(attrs)
|
15
|
+
expect(person.email_address).to eq("helmut@januschka.com")
|
16
|
+
end
|
17
|
+
it "Should remove a member" do
|
18
|
+
expect(client).to receive(:team_remove_member!).with("5M8TWKRZ3J")
|
19
|
+
person = Spaceship::Portal::Persons.find("helmut@januschka.com")
|
20
|
+
person.remove!
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should change role" do
|
24
|
+
person = Spaceship::Portal::Persons.find("helmut@januschka.com")
|
25
|
+
expect { person.change_role("member") }.to_not raise_error
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
describe Spaceship::Portal::Persons do
|
2
|
+
before { Spaceship.login }
|
3
|
+
let(:client) { Spaceship::Persons.client }
|
4
|
+
|
5
|
+
it "Should load all persons" do
|
6
|
+
all = Spaceship::Portal::Persons.all
|
7
|
+
expect(all.length).to eq(3)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "Should find a specific person" do
|
11
|
+
person = Spaceship::Portal::Persons.find("helmut@januschka.com")
|
12
|
+
expect(person.email_address).to eq("helmut@januschka.com")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should invite a new one" do
|
16
|
+
expect(client).to receive(:team_invite).with("helmut@januschka.com", "admin")
|
17
|
+
Spaceship::Portal::Persons.invite("helmut@januschka.com", "admin")
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,279 @@
|
|
1
|
+
describe Spaceship::Client do
|
2
|
+
before { Spaceship.login }
|
3
|
+
subject { Spaceship.client }
|
4
|
+
let(:username) { 'spaceship@krausefx.com' }
|
5
|
+
let(:password) { 'so_secret' }
|
6
|
+
|
7
|
+
describe '#login' do
|
8
|
+
it 'sets the session cookies' do
|
9
|
+
response = subject.login(username, password)
|
10
|
+
expect(response.env.request_headers['Cookie']).to eq('myacinfo=abcdef')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'raises an exception if authentication failed' do
|
14
|
+
expect do
|
15
|
+
subject.login('bad-username', 'bad-password')
|
16
|
+
end.to raise_exception(Spaceship::Client::InvalidUserCredentialsError)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'authenticated' do
|
21
|
+
before { subject.login(username, password) }
|
22
|
+
describe '#teams' do
|
23
|
+
let(:teams) { subject.teams }
|
24
|
+
it 'returns the list of available teams' do
|
25
|
+
expect(teams).to be_instance_of(Array)
|
26
|
+
expect(teams.first.keys).to eq(["status", "teamId", "type", "extendedTeamAttributes", "teamAgent", "memberships", "currentTeamMember", "name"])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#team_id' do
|
31
|
+
it 'returns the default team_id' do
|
32
|
+
expect(subject.team_id).to eq('XXXXXXXXXX')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "set custom Team ID" do
|
36
|
+
team_id = "ABCDEF"
|
37
|
+
subject.team_id = team_id
|
38
|
+
expect(subject.team_id).to eq(team_id)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "shows a warning when user is in multiple teams and didn't call select_team" do
|
42
|
+
PortalStubbing.adp_stub_multiple_teams
|
43
|
+
expect(subject.team_id).to eq("SecondTeam")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "csrf_tokens" do
|
48
|
+
it "uses the stored token for all upcoming requests" do
|
49
|
+
# Temporary stub a request to require the csrf_tokens
|
50
|
+
stub_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/device/listDevices.action').
|
51
|
+
with(body: { teamId: 'XXXXXXXXXX', pageSize: "10", pageNumber: "1", sort: 'name=asc', includeRemovedDevices: "false" }, headers: { 'csrf' => 'top_secret', 'csrf_ts' => '123123' }).
|
52
|
+
to_return(status: 200, body: PortalStubbing.adp_read_fixture_file('listDevices.action.json'), headers: { 'Content-Type' => 'application/json' })
|
53
|
+
|
54
|
+
# Hard code the tokens
|
55
|
+
allow(subject).to receive(:csrf_tokens).and_return({ csrf: 'top_secret', csrf_ts: '123123' })
|
56
|
+
allow(subject).to receive(:page_size).and_return(10) # to have a separate stubbing
|
57
|
+
|
58
|
+
expect(subject.devices.count).to eq(4)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#apps' do
|
63
|
+
let(:apps) { subject.apps }
|
64
|
+
it 'returns a list of apps' do
|
65
|
+
expect(apps).to be_instance_of(Array)
|
66
|
+
expect(apps.first.keys).to eq(["appIdId", "name", "appIdPlatform", "prefix", "identifier", "isWildCard", "isDuplicate", "features", "enabledFeatures", "isDevPushEnabled", "isProdPushEnabled", "associatedApplicationGroupsCount", "associatedCloudContainersCount", "associatedIdentifiersCount"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#app_groups' do
|
71
|
+
let(:app_groups) { subject.app_groups }
|
72
|
+
it 'returns a list of apps' do
|
73
|
+
expect(app_groups).to be_instance_of(Array)
|
74
|
+
expect(app_groups.first.keys).to eq(["name", "prefix", "identifier", "status", "applicationGroup"])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#team_information" do
|
79
|
+
it 'returns all available information' do
|
80
|
+
s = subject.team_information
|
81
|
+
expect(s['status']).to eq('active')
|
82
|
+
expect(s['type']).to eq('Company/Organization')
|
83
|
+
expect(s['name']).to eq('SpaceShip')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#in_house?" do
|
88
|
+
it 'returns false for normal accounts' do
|
89
|
+
expect(subject.in_house?).to eq(false)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'returns true for enterprise accounts' do
|
93
|
+
PortalStubbing.adp_stub_multiple_teams
|
94
|
+
|
95
|
+
subject.team_id = 'SecondTeam'
|
96
|
+
expect(subject.in_house?).to eq(true)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#create_app' do
|
101
|
+
it 'should make a request create an explicit app id' do
|
102
|
+
response = subject.create_app!(:explicit, 'Production App', 'tools.fastlane.spaceship.some-explicit-app')
|
103
|
+
expect(response['isWildCard']).to eq(false)
|
104
|
+
expect(response['name']).to eq('Production App')
|
105
|
+
expect(response['identifier']).to eq('tools.fastlane.spaceship.some-explicit-app')
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should make a request create a wildcard app id' do
|
109
|
+
response = subject.create_app!(:wildcard, 'Development App', 'tools.fastlane.spaceship.*')
|
110
|
+
expect(response['isWildCard']).to eq(true)
|
111
|
+
expect(response['name']).to eq('Development App')
|
112
|
+
expect(response['identifier']).to eq('tools.fastlane.spaceship.*')
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should strip non ASCII characters' do
|
116
|
+
response = subject.create_app!(:explicit, 'pp Test 1ed9e25c93ac7142ff9df53e7f80e84c', 'tools.fastlane.spaceship.some-explicit-app')
|
117
|
+
expect(response['isWildCard']).to eq(false)
|
118
|
+
expect(response['name']).to eq('pp Test 1ed9e25c93ac7142ff9df53e7f80e84c')
|
119
|
+
expect(response['identifier']).to eq('tools.fastlane.spaceship.some-explicit-app')
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should make a request create an explicit app id with no push feature' do
|
123
|
+
payload = {}
|
124
|
+
payload[Spaceship.app_service.push_notification.on.service_id] = Spaceship.app_service.push_notification.on
|
125
|
+
response = subject.create_app!(:explicit, 'Production App', 'tools.fastlane.spaceship.some-explicit-app', enable_services: payload)
|
126
|
+
expect(response['enabledFeatures']).to_not include("push")
|
127
|
+
expect(response['identifier']).to eq('tools.fastlane.spaceship.some-explicit-app')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#delete_app!' do
|
132
|
+
it 'should make a request to delete the app' do
|
133
|
+
response = subject.delete_app!('LXD24VUE49')
|
134
|
+
expect(response['resultCode']).to eq(0)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#create_app_group' do
|
139
|
+
it 'should make a request create an app group' do
|
140
|
+
response = subject.create_app_group!('Production App Group', 'group.tools.fastlane.spaceship')
|
141
|
+
expect(response['name']).to eq('Production App Group')
|
142
|
+
expect(response['identifier']).to eq('group.tools.fastlane')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe '#delete_app_group' do
|
147
|
+
it 'should make a request to delete the app group' do
|
148
|
+
response = subject.delete_app_group!('2GKKV64NUG')
|
149
|
+
expect(response['resultCode']).to eq(0)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "#paging" do
|
154
|
+
it "default page size is correct" do
|
155
|
+
expect(subject.page_size).to eq(500)
|
156
|
+
end
|
157
|
+
|
158
|
+
it "Properly pages if required with support for a custom page size" do
|
159
|
+
allow(subject).to receive(:page_size).and_return(8)
|
160
|
+
|
161
|
+
expect(subject.devices.count).to eq(9)
|
162
|
+
expect(subject.devices.last['name']).to eq("The last phone")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe '#devices' do
|
167
|
+
let(:devices) { subject.devices }
|
168
|
+
it 'returns a list of device hashes' do
|
169
|
+
expect(devices).to be_instance_of(Array)
|
170
|
+
expect(devices.first.keys).to eq(["deviceId", "name", "deviceNumber", "devicePlatform", "status", "model", "deviceClass"])
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe '#certificates' do
|
175
|
+
let(:certificates) { subject.certificates(["5QPB9NHCEI"]) }
|
176
|
+
it 'returns a list of certificates hashes' do
|
177
|
+
expect(certificates).to be_instance_of(Array)
|
178
|
+
expect(certificates.first.keys).to eq(
|
179
|
+
%w(certRequestId name statusString dateRequestedString dateRequested
|
180
|
+
dateCreated expirationDate expirationDateString ownerType ownerName
|
181
|
+
ownerId canDownload canRevoke certificateId certificateStatusCode
|
182
|
+
certRequestStatusCode certificateTypeDisplayId serialNum typeString)
|
183
|
+
)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
describe "#create_device" do
|
188
|
+
it "works as expected when the name is free" do
|
189
|
+
device = subject.create_device!("Demo Device", "7f6c8dc83d77134b5a3a1c53f1202b395b04482b")
|
190
|
+
expect(device['name']).to eq("Demo Device")
|
191
|
+
expect(device['deviceNumber']).to eq("7f6c8dc83d77134b5a3a1c53f1202b395b04482b")
|
192
|
+
expect(device['devicePlatform']).to eq('ios')
|
193
|
+
expect(device['status']).to eq('c')
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe '#provisioning_profiles' do
|
198
|
+
it 'makes a call to the developer portal API' do
|
199
|
+
profiles = subject.provisioning_profiles
|
200
|
+
expect(profiles).to be_instance_of(Array)
|
201
|
+
expect(profiles.sample.keys).to include("provisioningProfileId",
|
202
|
+
"name",
|
203
|
+
"status",
|
204
|
+
"type",
|
205
|
+
"distributionMethod",
|
206
|
+
"proProPlatform",
|
207
|
+
"version",
|
208
|
+
"dateExpire",
|
209
|
+
"managingApp",
|
210
|
+
"deviceIds",
|
211
|
+
"certificateIds")
|
212
|
+
expect(a_request(:post, 'https://developer.apple.com/services-account/QH65B2/account/ios/profile/listProvisioningProfiles.action')).to have_been_made
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe '#provisioning_profiles_via_xcode_api' do
|
217
|
+
it 'makes a call to the developer portal API' do
|
218
|
+
profiles = subject.provisioning_profiles_via_xcode_api
|
219
|
+
expect(profiles).to be_instance_of(Array)
|
220
|
+
expect(profiles.sample.keys).to include("provisioningProfileId",
|
221
|
+
"name",
|
222
|
+
"status",
|
223
|
+
"type",
|
224
|
+
"distributionMethod",
|
225
|
+
"proProPlatform",
|
226
|
+
"version",
|
227
|
+
"dateExpire",
|
228
|
+
# "managingApp", not all profiles have it
|
229
|
+
"deviceIds",
|
230
|
+
"appId",
|
231
|
+
"certificateIds")
|
232
|
+
expect(a_request(:post, /developerservices2.apple.com/)).to have_been_made
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
describe "#create_provisioning_profile" do
|
237
|
+
it "works when the name is free" do
|
238
|
+
response = subject.create_provisioning_profile!("net.sunapps.106 limited", "limited", 'R9YNDTPLJX', ['C8DL7464RQ'], ['C8DLAAAARQ'])
|
239
|
+
expect(response.keys).to include('name', 'status', 'type', 'appId', 'deviceIds')
|
240
|
+
expect(response['distributionMethod']).to eq('limited')
|
241
|
+
end
|
242
|
+
|
243
|
+
it "works when the name is already taken" do
|
244
|
+
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
|
245
|
+
expect do
|
246
|
+
response = subject.create_provisioning_profile!("taken", "limited", 'R9YNDTPLJX', ['C8DL7464RQ'], ['C8DLAAAARQ'])
|
247
|
+
end.to raise_error(Spaceship::Client::UnexpectedResponse, error_text)
|
248
|
+
end
|
249
|
+
|
250
|
+
it "works when subplatform is null and mac is false" do
|
251
|
+
response = subject.create_provisioning_profile!("net.sunapps.106 limited", "limited", 'R9YNDTPLJX', ['C8DL7464RQ'], ['C8DLAAAARQ'], mac: false, sub_platform: nil)
|
252
|
+
expect(response.keys).to include('name', 'status', 'type', 'appId', 'deviceIds')
|
253
|
+
expect(response['distributionMethod']).to eq('limited')
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe '#delete_provisioning_profile!' do
|
258
|
+
it 'makes a requeset to delete a provisioning profile' do
|
259
|
+
response = subject.delete_provisioning_profile!('2MAY7NPHRU')
|
260
|
+
expect(response['resultCode']).to eq(0)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
describe '#create_certificate' do
|
265
|
+
let(:csr) { PortalStubbing.adp_read_fixture_file('certificateSigningRequest.certSigningRequest') }
|
266
|
+
it 'makes a request to create a certificate' do
|
267
|
+
response = subject.create_certificate!('BKLRAVXMGM', csr, '2HNR359G63')
|
268
|
+
expect(response.keys).to include('certificateId', 'certificateType', 'statusString', 'expirationDate', 'certificate')
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe '#revoke_certificate' do
|
273
|
+
it 'makes a revoke request and returns the revoked certificate' do
|
274
|
+
response = subject.revoke_certificate!('XC5PH8DAAA', 'R58UK2EAAA')
|
275
|
+
expect(response.first.keys).to include('certificateId', 'certificateType', 'certificate')
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
describe Spaceship::Portal do
|
2
|
+
describe "InsufficientPermissions" do
|
3
|
+
before { Spaceship::Portal.login }
|
4
|
+
let(:certificate) { Spaceship::Certificate.all.first }
|
5
|
+
|
6
|
+
it "raises an appropriate Developer Portal error when user doesn't have enough permission to do something" do
|
7
|
+
stub_request(:get, "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/downloadCertificateContent.action?certificateId=XC5PH8DAAA&teamId=XXXXXXXXXX&type=R58UK2EAAA").
|
8
|
+
to_return(status: 200, body: '{
|
9
|
+
"responseId": "d069deba-8d07-4aab-844f-72523bcb71a5",
|
10
|
+
"resultCode": 1200,
|
11
|
+
"resultString": "webservice.certificate.downloadNotAllowed",
|
12
|
+
"userString": "You are not permitted to download this certificate.",
|
13
|
+
"creationTimestamp": "2017-01-26T23:13:00Z",
|
14
|
+
"requestUrl": "https://developer.apple.com/services-account/QH65B2/account/ios/certificate/downloadCertificateContent.action",
|
15
|
+
"httpCode": 200
|
16
|
+
}', headers: { 'Content-Type' => 'application/json' })
|
17
|
+
|
18
|
+
expected_error_message = "User spaceship@krausefx.com (Team ID XXXXXXXXXX) doesn't have enough permission for the following action: download_certificate (You are not permitted to download this certificate.)"
|
19
|
+
|
20
|
+
cert = Spaceship::Certificate.all.first
|
21
|
+
expect do
|
22
|
+
cert.download
|
23
|
+
end.to raise_exception(Spaceship::Client::InsufficientPermissions, expected_error_message)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|