@revopush/code-push-cli 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.
- package/.eslintrc.json +17 -0
- package/.idea/cli.iml +9 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +774 -0
- package/bin/script/acquisition-sdk.js +178 -0
- package/bin/script/cli.js +23 -0
- package/bin/script/command-executor.js +1290 -0
- package/bin/script/command-parser.js +1097 -0
- package/bin/script/commands/debug.js +125 -0
- package/bin/script/hash-utils.js +203 -0
- package/bin/script/index.js +5 -0
- package/bin/script/management-sdk.js +419 -0
- package/bin/script/react-native-utils.js +249 -0
- package/bin/script/sign.js +69 -0
- package/bin/script/types/cli.js +40 -0
- package/bin/script/types/rest-definitions.js +19 -0
- package/bin/script/types.js +4 -0
- package/bin/script/utils/file-utils.js +50 -0
- package/bin/test/acquisition-rest-mock.js +108 -0
- package/bin/test/acquisition-sdk.js +188 -0
- package/bin/test/cli.js +1342 -0
- package/bin/test/hash-utils.js +149 -0
- package/bin/test/management-sdk.js +338 -0
- package/package.json +68 -0
- package/prettier.config.js +7 -0
- package/script/acquisition-sdk.ts +273 -0
- package/script/cli.ts +27 -0
- package/script/command-executor.ts +1610 -0
- package/script/command-parser.ts +1310 -0
- package/script/commands/debug.ts +148 -0
- package/script/hash-utils.ts +241 -0
- package/script/index.ts +5 -0
- package/script/management-sdk.ts +575 -0
- package/script/react-native-utils.ts +283 -0
- package/script/sign.ts +80 -0
- package/script/types/cli.ts +232 -0
- package/script/types/rest-definitions.ts +152 -0
- package/script/types.ts +35 -0
- package/script/utils/file-utils.ts +46 -0
- package/test/acquisition-rest-mock.ts +125 -0
- package/test/acquisition-sdk.ts +272 -0
- package/test/cli.ts +1692 -0
- package/test/hash-utils.ts +170 -0
- package/test/management-sdk.ts +438 -0
- package/test/resources/TestApp/android/app/build.gradle +56 -0
- package/test/resources/TestApp/iOS/TestApp/Info.plist +49 -0
- package/test/resources/TestApp/index.android.js +2 -0
- package/test/resources/TestApp/index.ios.js +2 -0
- package/test/resources/TestApp/index.windows.js +2 -0
- package/test/resources/TestApp/package.json +6 -0
- package/test/resources/TestApp/windows/TestApp/Package.appxmanifest +46 -0
- package/test/resources/ignoredMetadata.zip +0 -0
- package/test/resources/test.zip +0 -0
- package/test/superagent-mock-config.js +58 -0
- package/tsconfig.json +13 -0
package/bin/test/cli.js
ADDED
|
@@ -0,0 +1,1342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.SdkStub = void 0;
|
|
6
|
+
const assert = require("assert");
|
|
7
|
+
const sinon = require("sinon");
|
|
8
|
+
const Q = require("q");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const cli = require("../script/types/cli");
|
|
11
|
+
const cmdexec = require("../script/command-executor");
|
|
12
|
+
const os = require("os");
|
|
13
|
+
function assertJsonDescribesObject(json, object) {
|
|
14
|
+
// Make sure JSON is indented correctly
|
|
15
|
+
assert.equal(json, JSON.stringify(object, /*replacer=*/ null, /*spacing=*/ 2));
|
|
16
|
+
}
|
|
17
|
+
function clone(obj) {
|
|
18
|
+
return JSON.parse(JSON.stringify(obj));
|
|
19
|
+
}
|
|
20
|
+
function ensureInTestAppDirectory() {
|
|
21
|
+
if (!~__dirname.indexOf("/resources/TestApp")) {
|
|
22
|
+
process.chdir(__dirname + "/resources/TestApp");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function isDefined(object) {
|
|
26
|
+
return object !== undefined && object !== null;
|
|
27
|
+
}
|
|
28
|
+
const NOW = 1471460856191;
|
|
29
|
+
const DEFAULT_ACCESS_KEY_MAX_AGE = 1000 * 60 * 60 * 24 * 60; // 60 days
|
|
30
|
+
const TEST_MACHINE_NAME = "Test machine";
|
|
31
|
+
class SdkStub {
|
|
32
|
+
productionDeployment = {
|
|
33
|
+
name: "Production",
|
|
34
|
+
key: "6",
|
|
35
|
+
};
|
|
36
|
+
stagingDeployment = {
|
|
37
|
+
name: "Staging",
|
|
38
|
+
key: "6",
|
|
39
|
+
package: {
|
|
40
|
+
appVersion: "1.0.0",
|
|
41
|
+
description: "fgh",
|
|
42
|
+
label: "v2",
|
|
43
|
+
packageHash: "jkl",
|
|
44
|
+
isMandatory: true,
|
|
45
|
+
size: 10,
|
|
46
|
+
blobUrl: "http://mno.pqr",
|
|
47
|
+
uploadTime: 1000,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
getAccountInfo() {
|
|
51
|
+
return Q({
|
|
52
|
+
email: "a@a.com",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
addAccessKey(name, ttl) {
|
|
56
|
+
return Q({
|
|
57
|
+
key: "key123",
|
|
58
|
+
createdTime: new Date().getTime(),
|
|
59
|
+
name,
|
|
60
|
+
expires: NOW + (isDefined(ttl) ? ttl : DEFAULT_ACCESS_KEY_MAX_AGE),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
patchAccessKey(newName, newTtl) {
|
|
64
|
+
return Q({
|
|
65
|
+
createdTime: new Date().getTime(),
|
|
66
|
+
name: newName,
|
|
67
|
+
expires: NOW + (isDefined(newTtl) ? newTtl : DEFAULT_ACCESS_KEY_MAX_AGE),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
addApp(name) {
|
|
71
|
+
return Q({
|
|
72
|
+
name: name,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
addCollaborator() {
|
|
76
|
+
return Q(null);
|
|
77
|
+
}
|
|
78
|
+
addDeployment(deploymentName) {
|
|
79
|
+
return Q({
|
|
80
|
+
name: deploymentName,
|
|
81
|
+
key: "6",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
clearDeploymentHistory() {
|
|
85
|
+
return Q(null);
|
|
86
|
+
}
|
|
87
|
+
getAccessKeys() {
|
|
88
|
+
return Q([
|
|
89
|
+
{
|
|
90
|
+
createdTime: 0,
|
|
91
|
+
name: "Test name",
|
|
92
|
+
expires: NOW + DEFAULT_ACCESS_KEY_MAX_AGE,
|
|
93
|
+
},
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
getSessions() {
|
|
97
|
+
return Q([
|
|
98
|
+
{
|
|
99
|
+
loggedInTime: 0,
|
|
100
|
+
machineName: TEST_MACHINE_NAME,
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
getApps() {
|
|
105
|
+
return Q([
|
|
106
|
+
{
|
|
107
|
+
name: "a",
|
|
108
|
+
collaborators: {
|
|
109
|
+
"a@a.com": { permission: "Owner", isCurrentAccount: true },
|
|
110
|
+
},
|
|
111
|
+
deployments: ["Production", "Staging"],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "b",
|
|
115
|
+
collaborators: {
|
|
116
|
+
"a@a.com": { permission: "Owner", isCurrentAccount: true },
|
|
117
|
+
},
|
|
118
|
+
deployments: ["Production", "Staging"],
|
|
119
|
+
},
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
getDeployments(appName) {
|
|
123
|
+
if (appName === "a") {
|
|
124
|
+
return Q([this.productionDeployment, this.stagingDeployment]);
|
|
125
|
+
}
|
|
126
|
+
return Q.reject();
|
|
127
|
+
}
|
|
128
|
+
getDeployment(appName, deploymentName) {
|
|
129
|
+
if (appName === "a") {
|
|
130
|
+
if (deploymentName === "Production") {
|
|
131
|
+
return Q(this.productionDeployment);
|
|
132
|
+
}
|
|
133
|
+
else if (deploymentName === "Staging") {
|
|
134
|
+
return Q(this.stagingDeployment);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return Q.reject();
|
|
138
|
+
}
|
|
139
|
+
getDeploymentHistory() {
|
|
140
|
+
return Q([
|
|
141
|
+
{
|
|
142
|
+
description: null,
|
|
143
|
+
appVersion: "1.0.0",
|
|
144
|
+
isMandatory: false,
|
|
145
|
+
packageHash: "463acc7d06adc9c46233481d87d9e8264b3e9ffe60fe98d721e6974209dc71a0",
|
|
146
|
+
blobUrl: "https://fakeblobstorage.net/storagev2/blobid1",
|
|
147
|
+
uploadTime: 1447113596270,
|
|
148
|
+
size: 1,
|
|
149
|
+
label: "v1",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
description: "New update - this update does a whole bunch of things, including testing linewrapping",
|
|
153
|
+
appVersion: "1.0.1",
|
|
154
|
+
isMandatory: false,
|
|
155
|
+
packageHash: "463acc7d06adc9c46233481d87d9e8264b3e9ffe60fe98d721e6974209dc71a0",
|
|
156
|
+
blobUrl: "https://fakeblobstorage.net/storagev2/blobid2",
|
|
157
|
+
uploadTime: 1447118476669,
|
|
158
|
+
size: 2,
|
|
159
|
+
label: "v2",
|
|
160
|
+
},
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
getDeploymentMetrics() {
|
|
164
|
+
return Q({
|
|
165
|
+
"1.0.0": {
|
|
166
|
+
active: 123,
|
|
167
|
+
},
|
|
168
|
+
v1: {
|
|
169
|
+
active: 789,
|
|
170
|
+
downloaded: 456,
|
|
171
|
+
failed: 654,
|
|
172
|
+
installed: 987,
|
|
173
|
+
},
|
|
174
|
+
v2: {
|
|
175
|
+
active: 123,
|
|
176
|
+
downloaded: 321,
|
|
177
|
+
failed: 789,
|
|
178
|
+
installed: 456,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
getCollaborators() {
|
|
183
|
+
return Q({
|
|
184
|
+
"a@a.com": {
|
|
185
|
+
permission: "Owner",
|
|
186
|
+
isCurrentAccount: true,
|
|
187
|
+
},
|
|
188
|
+
"b@b.com": {
|
|
189
|
+
permission: "Collaborator",
|
|
190
|
+
isCurrentAccount: false,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
patchRelease() {
|
|
195
|
+
return Q(null);
|
|
196
|
+
}
|
|
197
|
+
promote() {
|
|
198
|
+
return Q(null);
|
|
199
|
+
}
|
|
200
|
+
release() {
|
|
201
|
+
return Q("Successfully released");
|
|
202
|
+
}
|
|
203
|
+
removeAccessKey() {
|
|
204
|
+
return Q(null);
|
|
205
|
+
}
|
|
206
|
+
removeApp() {
|
|
207
|
+
return Q(null);
|
|
208
|
+
}
|
|
209
|
+
removeCollaborator() {
|
|
210
|
+
return Q(null);
|
|
211
|
+
}
|
|
212
|
+
removeDeployment() {
|
|
213
|
+
return Q(null);
|
|
214
|
+
}
|
|
215
|
+
removeSession() {
|
|
216
|
+
return Q(null);
|
|
217
|
+
}
|
|
218
|
+
renameApp() {
|
|
219
|
+
return Q(null);
|
|
220
|
+
}
|
|
221
|
+
rollback() {
|
|
222
|
+
return Q(null);
|
|
223
|
+
}
|
|
224
|
+
transferApp() {
|
|
225
|
+
return Q(null);
|
|
226
|
+
}
|
|
227
|
+
renameDeployment() {
|
|
228
|
+
return Q(null);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exports.SdkStub = SdkStub;
|
|
232
|
+
describe("CLI", () => {
|
|
233
|
+
var log;
|
|
234
|
+
var sandbox;
|
|
235
|
+
var spawn;
|
|
236
|
+
var wasConfirmed = true;
|
|
237
|
+
const INVALID_RELEASE_FILE_ERROR_MESSAGE = "It is unnecessary to package releases in a .zip or binary file. Please specify the direct path to the update content's directory (e.g. /platforms/ios/www) or file (e.g. main.jsbundle).";
|
|
238
|
+
beforeEach(() => {
|
|
239
|
+
wasConfirmed = true;
|
|
240
|
+
sandbox = sinon.createSandbox();
|
|
241
|
+
sandbox.stub(cmdexec, "confirm").returns(Q.Promise((resolve) => {
|
|
242
|
+
resolve(wasConfirmed);
|
|
243
|
+
}));
|
|
244
|
+
sandbox.stub(cmdexec, "createEmptyTempReleaseFolder").callsFake(() => Q.Promise((resolve) => resolve()));
|
|
245
|
+
log = sandbox.stub(cmdexec, "log").callsFake(() => { });
|
|
246
|
+
spawn = sandbox.stub(cmdexec, "spawn").callsFake(() => {
|
|
247
|
+
return {
|
|
248
|
+
stdout: { on: () => { } },
|
|
249
|
+
stderr: { on: () => { } },
|
|
250
|
+
on: (event, callback) => {
|
|
251
|
+
callback();
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
afterEach(() => {
|
|
257
|
+
sandbox.restore();
|
|
258
|
+
});
|
|
259
|
+
it("accessKeyAdd creates access key with name and default ttl", (done) => {
|
|
260
|
+
var command = {
|
|
261
|
+
type: cli.CommandType.accessKeyAdd,
|
|
262
|
+
name: "Test name",
|
|
263
|
+
};
|
|
264
|
+
cmdexec.execute(command).done(() => {
|
|
265
|
+
sinon.assert.calledTwice(log);
|
|
266
|
+
assert.equal(log.args[0].length, 1);
|
|
267
|
+
var actual = log.args[0][0];
|
|
268
|
+
var expected = `Successfully created the "Test name" access key: key123`;
|
|
269
|
+
assert.equal(actual, expected);
|
|
270
|
+
actual = log.args[1][0];
|
|
271
|
+
expected = "Make sure to save this key value somewhere safe, since you won't be able to view it from the CLI again!";
|
|
272
|
+
assert.equal(actual, expected);
|
|
273
|
+
done();
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
it("accessKeyAdd creates access key with name and specified ttl", (done) => {
|
|
277
|
+
var ttl = 10000;
|
|
278
|
+
var command = {
|
|
279
|
+
type: cli.CommandType.accessKeyAdd,
|
|
280
|
+
name: "Test name",
|
|
281
|
+
ttl,
|
|
282
|
+
};
|
|
283
|
+
cmdexec.execute(command).done(() => {
|
|
284
|
+
sinon.assert.calledTwice(log);
|
|
285
|
+
assert.equal(log.args[0].length, 1);
|
|
286
|
+
var actual = log.args[0][0];
|
|
287
|
+
var expected = `Successfully created the "Test name" access key: key123`;
|
|
288
|
+
assert.equal(actual, expected);
|
|
289
|
+
actual = log.args[1][0];
|
|
290
|
+
expected = "Make sure to save this key value somewhere safe, since you won't be able to view it from the CLI again!";
|
|
291
|
+
assert.equal(actual, expected);
|
|
292
|
+
done();
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
it("accessKeyPatch updates access key with new name", (done) => {
|
|
296
|
+
var command = {
|
|
297
|
+
type: cli.CommandType.accessKeyPatch,
|
|
298
|
+
oldName: "Test name",
|
|
299
|
+
newName: "Updated name",
|
|
300
|
+
};
|
|
301
|
+
cmdexec.execute(command).done(() => {
|
|
302
|
+
sinon.assert.calledOnce(log);
|
|
303
|
+
assert.equal(log.args[0].length, 1);
|
|
304
|
+
var actual = log.args[0][0];
|
|
305
|
+
var expected = `Successfully renamed the access key "Test name" to "Updated name".`;
|
|
306
|
+
assert.equal(actual, expected);
|
|
307
|
+
done();
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
it("accessKeyPatch updates access key with new ttl", (done) => {
|
|
311
|
+
var ttl = 10000;
|
|
312
|
+
var command = {
|
|
313
|
+
type: cli.CommandType.accessKeyPatch,
|
|
314
|
+
oldName: "Test name",
|
|
315
|
+
ttl,
|
|
316
|
+
};
|
|
317
|
+
cmdexec.execute(command).done(() => {
|
|
318
|
+
sinon.assert.calledOnce(log);
|
|
319
|
+
assert.equal(log.args[0].length, 1);
|
|
320
|
+
var actual = log.args[0][0];
|
|
321
|
+
var expected = `Successfully changed the expiration date of the "Test name" access key to Wednesday, August 17, 2016 12:07 PM.`;
|
|
322
|
+
assert.equal(actual, expected);
|
|
323
|
+
done();
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
it("accessKeyPatch updates access key with new name and ttl", (done) => {
|
|
327
|
+
var ttl = 10000;
|
|
328
|
+
var command = {
|
|
329
|
+
type: cli.CommandType.accessKeyPatch,
|
|
330
|
+
oldName: "Test name",
|
|
331
|
+
newName: "Updated name",
|
|
332
|
+
ttl,
|
|
333
|
+
};
|
|
334
|
+
cmdexec.execute(command).done(() => {
|
|
335
|
+
sinon.assert.calledOnce(log);
|
|
336
|
+
assert.equal(log.args[0].length, 1);
|
|
337
|
+
var actual = log.args[0][0];
|
|
338
|
+
var expected = `Successfully renamed the access key "Test name" to "Updated name" and changed its expiration date to Wednesday, August 17, 2016 12:07 PM.`;
|
|
339
|
+
assert.equal(actual, expected);
|
|
340
|
+
done();
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
it("accessKeyList lists access key name and expires fields", (done) => {
|
|
344
|
+
var command = {
|
|
345
|
+
type: cli.CommandType.accessKeyList,
|
|
346
|
+
format: "json",
|
|
347
|
+
};
|
|
348
|
+
cmdexec.execute(command).done(() => {
|
|
349
|
+
sinon.assert.calledOnce(log);
|
|
350
|
+
assert.equal(log.args[0].length, 1);
|
|
351
|
+
var actual = log.args[0][0];
|
|
352
|
+
var expected = [
|
|
353
|
+
{
|
|
354
|
+
createdTime: 0,
|
|
355
|
+
name: "Test name",
|
|
356
|
+
expires: NOW + DEFAULT_ACCESS_KEY_MAX_AGE,
|
|
357
|
+
},
|
|
358
|
+
];
|
|
359
|
+
assertJsonDescribesObject(actual, expected);
|
|
360
|
+
done();
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
it("accessKeyRemove removes access key", (done) => {
|
|
364
|
+
var command = {
|
|
365
|
+
type: cli.CommandType.accessKeyRemove,
|
|
366
|
+
accessKey: "8",
|
|
367
|
+
};
|
|
368
|
+
var removeAccessKey = sandbox.spy(cmdexec.sdk, "removeAccessKey");
|
|
369
|
+
cmdexec.execute(command).done(() => {
|
|
370
|
+
sinon.assert.calledOnce(removeAccessKey);
|
|
371
|
+
sinon.assert.calledWithExactly(removeAccessKey, "8");
|
|
372
|
+
sinon.assert.calledOnce(log);
|
|
373
|
+
sinon.assert.calledWithExactly(log, 'Successfully removed the "8" access key.');
|
|
374
|
+
done();
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
it("accessKeyRemove does not remove access key if cancelled", (done) => {
|
|
378
|
+
var command = {
|
|
379
|
+
type: cli.CommandType.accessKeyRemove,
|
|
380
|
+
accessKey: "8",
|
|
381
|
+
};
|
|
382
|
+
var removeAccessKey = sandbox.spy(cmdexec.sdk, "removeAccessKey");
|
|
383
|
+
wasConfirmed = false;
|
|
384
|
+
cmdexec.execute(command).done(() => {
|
|
385
|
+
sinon.assert.notCalled(removeAccessKey);
|
|
386
|
+
sinon.assert.calledOnce(log);
|
|
387
|
+
sinon.assert.calledWithExactly(log, "Access key removal cancelled.");
|
|
388
|
+
done();
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
it("appAdd reports new app name and ID", (done) => {
|
|
392
|
+
var command = {
|
|
393
|
+
type: cli.CommandType.appAdd,
|
|
394
|
+
appName: "a",
|
|
395
|
+
os: "",
|
|
396
|
+
platform: "",
|
|
397
|
+
};
|
|
398
|
+
var addApp = sandbox.spy(cmdexec.sdk, "addApp");
|
|
399
|
+
var deploymentList = sandbox.spy(cmdexec, "deploymentList");
|
|
400
|
+
cmdexec.execute(command).done(() => {
|
|
401
|
+
sinon.assert.calledOnce(addApp);
|
|
402
|
+
sinon.assert.calledTwice(log);
|
|
403
|
+
sinon.assert.calledWithExactly(log, 'Successfully added the "a" app, along with the following default deployments:');
|
|
404
|
+
sinon.assert.calledOnce(deploymentList);
|
|
405
|
+
done();
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
it("appList lists app names and ID's", (done) => {
|
|
409
|
+
var command = {
|
|
410
|
+
type: cli.CommandType.appList,
|
|
411
|
+
format: "json",
|
|
412
|
+
};
|
|
413
|
+
cmdexec.execute(command).done(() => {
|
|
414
|
+
sinon.assert.calledOnce(log);
|
|
415
|
+
assert.equal(log.args[0].length, 1);
|
|
416
|
+
var actual = log.args[0][0];
|
|
417
|
+
var expected = [
|
|
418
|
+
{
|
|
419
|
+
name: "a",
|
|
420
|
+
collaborators: {
|
|
421
|
+
"a@a.com": {
|
|
422
|
+
permission: "Owner",
|
|
423
|
+
isCurrentAccount: true,
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
deployments: ["Production", "Staging"],
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: "b",
|
|
430
|
+
collaborators: {
|
|
431
|
+
"a@a.com": {
|
|
432
|
+
permission: "Owner",
|
|
433
|
+
isCurrentAccount: true,
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
deployments: ["Production", "Staging"],
|
|
437
|
+
},
|
|
438
|
+
];
|
|
439
|
+
assertJsonDescribesObject(actual, expected);
|
|
440
|
+
done();
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
it("appRemove removes app", (done) => {
|
|
444
|
+
var command = {
|
|
445
|
+
type: cli.CommandType.appRemove,
|
|
446
|
+
appName: "a",
|
|
447
|
+
};
|
|
448
|
+
var removeApp = sandbox.spy(cmdexec.sdk, "removeApp");
|
|
449
|
+
cmdexec.execute(command).done(() => {
|
|
450
|
+
sinon.assert.calledOnce(removeApp);
|
|
451
|
+
sinon.assert.calledWithExactly(removeApp, "a");
|
|
452
|
+
sinon.assert.calledOnce(log);
|
|
453
|
+
sinon.assert.calledWithExactly(log, 'Successfully removed the "a" app.');
|
|
454
|
+
done();
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
it("appRemove does not remove app if cancelled", (done) => {
|
|
458
|
+
var command = {
|
|
459
|
+
type: cli.CommandType.appRemove,
|
|
460
|
+
appName: "a",
|
|
461
|
+
};
|
|
462
|
+
var removeApp = sandbox.spy(cmdexec.sdk, "removeApp");
|
|
463
|
+
wasConfirmed = false;
|
|
464
|
+
cmdexec.execute(command).done(() => {
|
|
465
|
+
sinon.assert.notCalled(removeApp);
|
|
466
|
+
sinon.assert.calledOnce(log);
|
|
467
|
+
sinon.assert.calledWithExactly(log, "App removal cancelled.");
|
|
468
|
+
done();
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
it("appRename renames app", (done) => {
|
|
472
|
+
var command = {
|
|
473
|
+
type: cli.CommandType.appRename,
|
|
474
|
+
currentAppName: "a",
|
|
475
|
+
newAppName: "c",
|
|
476
|
+
};
|
|
477
|
+
var renameApp = sandbox.spy(cmdexec.sdk, "renameApp");
|
|
478
|
+
cmdexec.execute(command).done(() => {
|
|
479
|
+
sinon.assert.calledOnce(renameApp);
|
|
480
|
+
sinon.assert.calledOnce(log);
|
|
481
|
+
sinon.assert.calledWithExactly(log, 'Successfully renamed the "a" app to "c".');
|
|
482
|
+
done();
|
|
483
|
+
});
|
|
484
|
+
});
|
|
485
|
+
it("appTransfer transfers app", (done) => {
|
|
486
|
+
var command = {
|
|
487
|
+
type: cli.CommandType.appTransfer,
|
|
488
|
+
appName: "a",
|
|
489
|
+
email: "b@b.com",
|
|
490
|
+
};
|
|
491
|
+
var transferApp = sandbox.spy(cmdexec.sdk, "transferApp");
|
|
492
|
+
cmdexec.execute(command).done(() => {
|
|
493
|
+
sinon.assert.calledOnce(transferApp);
|
|
494
|
+
sinon.assert.calledOnce(log);
|
|
495
|
+
sinon.assert.calledWithExactly(log, 'Successfully transferred the ownership of app "a" to the account with email "b@b.com".');
|
|
496
|
+
done();
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
it("collaboratorAdd adds collaborator", (done) => {
|
|
500
|
+
var command = {
|
|
501
|
+
type: cli.CommandType.collaboratorAdd,
|
|
502
|
+
appName: "a",
|
|
503
|
+
email: "b@b.com",
|
|
504
|
+
};
|
|
505
|
+
var addCollaborator = sandbox.spy(cmdexec.sdk, "addCollaborator");
|
|
506
|
+
cmdexec.execute(command).done(() => {
|
|
507
|
+
sinon.assert.calledOnce(addCollaborator);
|
|
508
|
+
sinon.assert.calledOnce(log);
|
|
509
|
+
sinon.assert.calledWithExactly(log, 'Successfully added "b@b.com" as a collaborator to the app "a".');
|
|
510
|
+
done();
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
it("collaboratorList lists collaborators email and properties", (done) => {
|
|
514
|
+
var command = {
|
|
515
|
+
type: cli.CommandType.collaboratorList,
|
|
516
|
+
appName: "a",
|
|
517
|
+
format: "json",
|
|
518
|
+
};
|
|
519
|
+
cmdexec.execute(command).done(() => {
|
|
520
|
+
sinon.assert.calledOnce(log);
|
|
521
|
+
assert.equal(log.args[0].length, 1);
|
|
522
|
+
var actual = log.args[0][0];
|
|
523
|
+
var expected = {
|
|
524
|
+
collaborators: {
|
|
525
|
+
"a@a.com": { permission: "Owner", isCurrentAccount: true },
|
|
526
|
+
"b@b.com": { permission: "Collaborator", isCurrentAccount: false },
|
|
527
|
+
},
|
|
528
|
+
};
|
|
529
|
+
assertJsonDescribesObject(actual, expected);
|
|
530
|
+
done();
|
|
531
|
+
});
|
|
532
|
+
});
|
|
533
|
+
it("collaboratorRemove removes collaborator", (done) => {
|
|
534
|
+
var command = {
|
|
535
|
+
type: cli.CommandType.collaboratorRemove,
|
|
536
|
+
appName: "a",
|
|
537
|
+
email: "b@b.com",
|
|
538
|
+
};
|
|
539
|
+
var removeCollaborator = sandbox.spy(cmdexec.sdk, "removeCollaborator");
|
|
540
|
+
cmdexec.execute(command).done(() => {
|
|
541
|
+
sinon.assert.calledOnce(removeCollaborator);
|
|
542
|
+
sinon.assert.calledOnce(log);
|
|
543
|
+
sinon.assert.calledWithExactly(log, 'Successfully removed "b@b.com" as a collaborator from the app "a".');
|
|
544
|
+
done();
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
it("deploymentAdd reports new app name and ID", (done) => {
|
|
548
|
+
var command = {
|
|
549
|
+
type: cli.CommandType.deploymentAdd,
|
|
550
|
+
appName: "a",
|
|
551
|
+
deploymentName: "b",
|
|
552
|
+
default: false,
|
|
553
|
+
};
|
|
554
|
+
var addDeployment = sandbox.spy(cmdexec.sdk, "addDeployment");
|
|
555
|
+
cmdexec.execute(command).done(() => {
|
|
556
|
+
sinon.assert.calledOnce(addDeployment);
|
|
557
|
+
sinon.assert.calledOnce(log);
|
|
558
|
+
sinon.assert.calledWithExactly(log, 'Successfully added the "b" deployment with key "6" to the "a" app.');
|
|
559
|
+
done();
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
it("deploymentHistoryClear clears deployment", (done) => {
|
|
563
|
+
var command = {
|
|
564
|
+
type: cli.CommandType.deploymentHistoryClear,
|
|
565
|
+
appName: "a",
|
|
566
|
+
deploymentName: "Staging",
|
|
567
|
+
};
|
|
568
|
+
var clearDeployment = sandbox.spy(cmdexec.sdk, "clearDeploymentHistory");
|
|
569
|
+
cmdexec.execute(command).done(() => {
|
|
570
|
+
sinon.assert.calledOnce(clearDeployment);
|
|
571
|
+
sinon.assert.calledWithExactly(clearDeployment, "a", "Staging");
|
|
572
|
+
sinon.assert.calledOnce(log);
|
|
573
|
+
sinon.assert.calledWithExactly(log, 'Successfully cleared the release history associated with the "Staging" deployment from the "a" app.');
|
|
574
|
+
done();
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
it("deploymentHistoryClear does not clear deployment if cancelled", (done) => {
|
|
578
|
+
var command = {
|
|
579
|
+
type: cli.CommandType.deploymentHistoryClear,
|
|
580
|
+
appName: "a",
|
|
581
|
+
deploymentName: "Staging",
|
|
582
|
+
};
|
|
583
|
+
var clearDeployment = sandbox.spy(cmdexec.sdk, "clearDeploymentHistory");
|
|
584
|
+
wasConfirmed = false;
|
|
585
|
+
cmdexec.execute(command).done(() => {
|
|
586
|
+
sinon.assert.notCalled(clearDeployment);
|
|
587
|
+
sinon.assert.calledOnce(log);
|
|
588
|
+
sinon.assert.calledWithExactly(log, "Clear deployment cancelled.");
|
|
589
|
+
done();
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
it("deploymentList lists deployment names, deployment keys, and package information", (done) => {
|
|
593
|
+
var command = {
|
|
594
|
+
type: cli.CommandType.deploymentList,
|
|
595
|
+
appName: "a",
|
|
596
|
+
format: "json",
|
|
597
|
+
displayKeys: true,
|
|
598
|
+
};
|
|
599
|
+
cmdexec.execute(command).done(() => {
|
|
600
|
+
sinon.assert.calledOnce(log);
|
|
601
|
+
assert.equal(log.args[0].length, 1);
|
|
602
|
+
var actual = log.args[0][0];
|
|
603
|
+
var expected = [
|
|
604
|
+
{
|
|
605
|
+
name: "Production",
|
|
606
|
+
key: "6",
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
name: "Staging",
|
|
610
|
+
key: "6",
|
|
611
|
+
package: {
|
|
612
|
+
appVersion: "1.0.0",
|
|
613
|
+
description: "fgh",
|
|
614
|
+
label: "v2",
|
|
615
|
+
packageHash: "jkl",
|
|
616
|
+
isMandatory: true,
|
|
617
|
+
size: 10,
|
|
618
|
+
blobUrl: "http://mno.pqr",
|
|
619
|
+
uploadTime: 1000,
|
|
620
|
+
metrics: {
|
|
621
|
+
active: 123,
|
|
622
|
+
downloaded: 321,
|
|
623
|
+
failed: 789,
|
|
624
|
+
installed: 456,
|
|
625
|
+
totalActive: 1035,
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
];
|
|
630
|
+
assertJsonDescribesObject(actual, expected);
|
|
631
|
+
done();
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
it("deploymentRemove removes deployment", (done) => {
|
|
635
|
+
var command = {
|
|
636
|
+
type: cli.CommandType.deploymentRemove,
|
|
637
|
+
appName: "a",
|
|
638
|
+
deploymentName: "Staging",
|
|
639
|
+
};
|
|
640
|
+
var removeDeployment = sandbox.spy(cmdexec.sdk, "removeDeployment");
|
|
641
|
+
cmdexec.execute(command).done(() => {
|
|
642
|
+
sinon.assert.calledOnce(removeDeployment);
|
|
643
|
+
sinon.assert.calledWithExactly(removeDeployment, "a", "Staging");
|
|
644
|
+
sinon.assert.calledOnce(log);
|
|
645
|
+
sinon.assert.calledWithExactly(log, 'Successfully removed the "Staging" deployment from the "a" app.');
|
|
646
|
+
done();
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
it("deploymentRemove does not remove deployment if cancelled", (done) => {
|
|
650
|
+
var command = {
|
|
651
|
+
type: cli.CommandType.deploymentRemove,
|
|
652
|
+
appName: "a",
|
|
653
|
+
deploymentName: "Staging",
|
|
654
|
+
};
|
|
655
|
+
var removeDeployment = sandbox.spy(cmdexec.sdk, "removeDeployment");
|
|
656
|
+
wasConfirmed = false;
|
|
657
|
+
cmdexec.execute(command).done(() => {
|
|
658
|
+
sinon.assert.notCalled(removeDeployment);
|
|
659
|
+
sinon.assert.calledOnce(log);
|
|
660
|
+
sinon.assert.calledWithExactly(log, "Deployment removal cancelled.");
|
|
661
|
+
done();
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
it("deploymentRename renames deployment", (done) => {
|
|
665
|
+
var command = {
|
|
666
|
+
type: cli.CommandType.deploymentRename,
|
|
667
|
+
appName: "a",
|
|
668
|
+
currentDeploymentName: "Staging",
|
|
669
|
+
newDeploymentName: "c",
|
|
670
|
+
};
|
|
671
|
+
var renameDeployment = sandbox.spy(cmdexec.sdk, "renameDeployment");
|
|
672
|
+
cmdexec.execute(command).done(() => {
|
|
673
|
+
sinon.assert.calledOnce(renameDeployment);
|
|
674
|
+
sinon.assert.calledOnce(log);
|
|
675
|
+
sinon.assert.calledWithExactly(log, 'Successfully renamed the "Staging" deployment to "c" for the "a" app.');
|
|
676
|
+
done();
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
it("deploymentHistory lists package history information", (done) => {
|
|
680
|
+
var command = {
|
|
681
|
+
type: cli.CommandType.deploymentHistory,
|
|
682
|
+
appName: "a",
|
|
683
|
+
deploymentName: "Staging",
|
|
684
|
+
format: "json",
|
|
685
|
+
displayAuthor: false,
|
|
686
|
+
};
|
|
687
|
+
var getDeploymentHistory = sandbox.spy(cmdexec.sdk, "getDeploymentHistory");
|
|
688
|
+
cmdexec.execute(command).done(() => {
|
|
689
|
+
sinon.assert.calledOnce(getDeploymentHistory);
|
|
690
|
+
sinon.assert.calledOnce(log);
|
|
691
|
+
assert.equal(log.args[0].length, 1);
|
|
692
|
+
var actual = log.args[0][0];
|
|
693
|
+
var expected = [
|
|
694
|
+
{
|
|
695
|
+
description: null,
|
|
696
|
+
appVersion: "1.0.0",
|
|
697
|
+
isMandatory: false,
|
|
698
|
+
packageHash: "463acc7d06adc9c46233481d87d9e8264b3e9ffe60fe98d721e6974209dc71a0",
|
|
699
|
+
blobUrl: "https://fakeblobstorage.net/storagev2/blobid1",
|
|
700
|
+
uploadTime: 1447113596270,
|
|
701
|
+
size: 1,
|
|
702
|
+
label: "v1",
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
description: "New update - this update does a whole bunch of things, including testing linewrapping",
|
|
706
|
+
appVersion: "1.0.1",
|
|
707
|
+
isMandatory: false,
|
|
708
|
+
packageHash: "463acc7d06adc9c46233481d87d9e8264b3e9ffe60fe98d721e6974209dc71a0",
|
|
709
|
+
blobUrl: "https://fakeblobstorage.net/storagev2/blobid2",
|
|
710
|
+
uploadTime: 1447118476669,
|
|
711
|
+
size: 2,
|
|
712
|
+
label: "v2",
|
|
713
|
+
},
|
|
714
|
+
];
|
|
715
|
+
assertJsonDescribesObject(actual, expected);
|
|
716
|
+
done();
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
it("patch command successfully updates specific label", (done) => {
|
|
720
|
+
var command = {
|
|
721
|
+
type: cli.CommandType.patch,
|
|
722
|
+
appName: "a",
|
|
723
|
+
deploymentName: "Staging",
|
|
724
|
+
label: "v1",
|
|
725
|
+
disabled: false,
|
|
726
|
+
description: "Patched",
|
|
727
|
+
mandatory: true,
|
|
728
|
+
rollout: 25,
|
|
729
|
+
appStoreVersion: "1.0.1",
|
|
730
|
+
};
|
|
731
|
+
var patch = sandbox.spy(cmdexec.sdk, "patchRelease");
|
|
732
|
+
cmdexec.execute(command).done(() => {
|
|
733
|
+
sinon.assert.calledOnce(patch);
|
|
734
|
+
sinon.assert.calledOnce(log);
|
|
735
|
+
sinon.assert.calledWithExactly(log, `Successfully updated the "v1" release of "a" app's "Staging" deployment.`);
|
|
736
|
+
done();
|
|
737
|
+
});
|
|
738
|
+
});
|
|
739
|
+
it("patch command successfully updates latest release", (done) => {
|
|
740
|
+
var command = {
|
|
741
|
+
type: cli.CommandType.patch,
|
|
742
|
+
appName: "a",
|
|
743
|
+
deploymentName: "Staging",
|
|
744
|
+
label: null,
|
|
745
|
+
disabled: false,
|
|
746
|
+
description: "Patched",
|
|
747
|
+
mandatory: true,
|
|
748
|
+
rollout: 25,
|
|
749
|
+
appStoreVersion: "1.0.1",
|
|
750
|
+
};
|
|
751
|
+
var patch = sandbox.spy(cmdexec.sdk, "patchRelease");
|
|
752
|
+
cmdexec.execute(command).done(() => {
|
|
753
|
+
sinon.assert.calledOnce(patch);
|
|
754
|
+
sinon.assert.calledOnce(log);
|
|
755
|
+
sinon.assert.calledWithExactly(log, `Successfully updated the "latest" release of "a" app's "Staging" deployment.`);
|
|
756
|
+
done();
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
it("patch command successfully updates without appStoreVersion", (done) => {
|
|
760
|
+
var command = {
|
|
761
|
+
type: cli.CommandType.patch,
|
|
762
|
+
appName: "a",
|
|
763
|
+
deploymentName: "Staging",
|
|
764
|
+
label: null,
|
|
765
|
+
disabled: false,
|
|
766
|
+
description: "Patched",
|
|
767
|
+
mandatory: true,
|
|
768
|
+
rollout: 25,
|
|
769
|
+
appStoreVersion: null,
|
|
770
|
+
};
|
|
771
|
+
var patch = sandbox.spy(cmdexec.sdk, "patchRelease");
|
|
772
|
+
cmdexec.execute(command).done(() => {
|
|
773
|
+
sinon.assert.calledOnce(patch);
|
|
774
|
+
sinon.assert.calledOnce(log);
|
|
775
|
+
sinon.assert.calledWithExactly(log, `Successfully updated the "latest" release of "a" app's "Staging" deployment.`);
|
|
776
|
+
done();
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
it("patch command fails if no properties were specified for update", (done) => {
|
|
780
|
+
var command = {
|
|
781
|
+
type: cli.CommandType.patch,
|
|
782
|
+
appName: "a",
|
|
783
|
+
deploymentName: "Staging",
|
|
784
|
+
label: null,
|
|
785
|
+
disabled: null,
|
|
786
|
+
description: null,
|
|
787
|
+
mandatory: null,
|
|
788
|
+
rollout: null,
|
|
789
|
+
appStoreVersion: null,
|
|
790
|
+
};
|
|
791
|
+
var patch = sandbox.spy(cmdexec.sdk, "patchRelease");
|
|
792
|
+
cmdexec
|
|
793
|
+
.execute(command)
|
|
794
|
+
.then(() => {
|
|
795
|
+
done(new Error("Did not throw error."));
|
|
796
|
+
})
|
|
797
|
+
.catch((err) => {
|
|
798
|
+
assert.equal(err.message, "At least one property must be specified to patch a release.");
|
|
799
|
+
sinon.assert.notCalled(patch);
|
|
800
|
+
done();
|
|
801
|
+
})
|
|
802
|
+
.done();
|
|
803
|
+
});
|
|
804
|
+
it("promote works successfully", (done) => {
|
|
805
|
+
var command = {
|
|
806
|
+
type: cli.CommandType.promote,
|
|
807
|
+
appName: "a",
|
|
808
|
+
sourceDeploymentName: "Staging",
|
|
809
|
+
destDeploymentName: "Production",
|
|
810
|
+
description: "Promoted",
|
|
811
|
+
mandatory: true,
|
|
812
|
+
rollout: 25,
|
|
813
|
+
appStoreVersion: "1.0.1",
|
|
814
|
+
};
|
|
815
|
+
var promote = sandbox.spy(cmdexec.sdk, "promote");
|
|
816
|
+
cmdexec.execute(command).done(() => {
|
|
817
|
+
sinon.assert.calledOnce(promote);
|
|
818
|
+
sinon.assert.calledOnce(log);
|
|
819
|
+
sinon.assert.calledWithExactly(log, `Successfully promoted the "Staging" deployment of the "a" app to the "Production" deployment.`);
|
|
820
|
+
done();
|
|
821
|
+
});
|
|
822
|
+
});
|
|
823
|
+
it("promote works successfully without appStoreVersion", (done) => {
|
|
824
|
+
var command = {
|
|
825
|
+
type: cli.CommandType.promote,
|
|
826
|
+
appName: "a",
|
|
827
|
+
sourceDeploymentName: "Staging",
|
|
828
|
+
destDeploymentName: "Production",
|
|
829
|
+
description: "Promoted",
|
|
830
|
+
mandatory: true,
|
|
831
|
+
rollout: 25,
|
|
832
|
+
appStoreVersion: null,
|
|
833
|
+
};
|
|
834
|
+
var promote = sandbox.spy(cmdexec.sdk, "promote");
|
|
835
|
+
cmdexec.execute(command).done(() => {
|
|
836
|
+
sinon.assert.calledOnce(promote);
|
|
837
|
+
sinon.assert.calledOnce(log);
|
|
838
|
+
sinon.assert.calledWithExactly(log, `Successfully promoted the "Staging" deployment of the "a" app to the "Production" deployment.`);
|
|
839
|
+
done();
|
|
840
|
+
});
|
|
841
|
+
});
|
|
842
|
+
it("rollback works successfully", (done) => {
|
|
843
|
+
var command = {
|
|
844
|
+
type: cli.CommandType.rollback,
|
|
845
|
+
appName: "a",
|
|
846
|
+
deploymentName: "Staging",
|
|
847
|
+
targetRelease: "v2",
|
|
848
|
+
};
|
|
849
|
+
var rollback = sandbox.spy(cmdexec.sdk, "rollback");
|
|
850
|
+
cmdexec.execute(command).done(() => {
|
|
851
|
+
sinon.assert.calledOnce(rollback);
|
|
852
|
+
sinon.assert.calledOnce(log);
|
|
853
|
+
sinon.assert.calledWithExactly(log, `Successfully performed a rollback on the "Staging" deployment of the "a" app.`);
|
|
854
|
+
done();
|
|
855
|
+
});
|
|
856
|
+
});
|
|
857
|
+
it("release doesn't allow non valid semver ranges", (done) => {
|
|
858
|
+
var command = {
|
|
859
|
+
type: cli.CommandType.release,
|
|
860
|
+
appName: "a",
|
|
861
|
+
deploymentName: "Staging",
|
|
862
|
+
description: "test releasing zip file",
|
|
863
|
+
mandatory: false,
|
|
864
|
+
rollout: null,
|
|
865
|
+
appStoreVersion: "not semver",
|
|
866
|
+
package: "./resources",
|
|
867
|
+
};
|
|
868
|
+
releaseHelperFunction(command, done, 'Please use a semver-compliant target binary version range, for example "1.0.0", "*" or "^1.2.3".');
|
|
869
|
+
});
|
|
870
|
+
it("release doesn't allow releasing .zip file", (done) => {
|
|
871
|
+
var command = {
|
|
872
|
+
type: cli.CommandType.release,
|
|
873
|
+
appName: "a",
|
|
874
|
+
deploymentName: "Staging",
|
|
875
|
+
description: "test releasing zip file",
|
|
876
|
+
mandatory: false,
|
|
877
|
+
rollout: null,
|
|
878
|
+
appStoreVersion: "1.0.0",
|
|
879
|
+
package: "/fake/path/test/file.zip",
|
|
880
|
+
};
|
|
881
|
+
releaseHelperFunction(command, done, INVALID_RELEASE_FILE_ERROR_MESSAGE);
|
|
882
|
+
});
|
|
883
|
+
it("release doesn't allow releasing .ipa file", (done) => {
|
|
884
|
+
var command = {
|
|
885
|
+
type: cli.CommandType.release,
|
|
886
|
+
appName: "a",
|
|
887
|
+
deploymentName: "Staging",
|
|
888
|
+
description: "test releasing ipa file",
|
|
889
|
+
mandatory: false,
|
|
890
|
+
rollout: null,
|
|
891
|
+
appStoreVersion: "1.0.0",
|
|
892
|
+
package: "/fake/path/test/file.ipa",
|
|
893
|
+
};
|
|
894
|
+
releaseHelperFunction(command, done, INVALID_RELEASE_FILE_ERROR_MESSAGE);
|
|
895
|
+
});
|
|
896
|
+
it("release doesn't allow releasing .apk file", (done) => {
|
|
897
|
+
var command = {
|
|
898
|
+
type: cli.CommandType.release,
|
|
899
|
+
appName: "a",
|
|
900
|
+
deploymentName: "Staging",
|
|
901
|
+
description: "test releasing apk file",
|
|
902
|
+
mandatory: false,
|
|
903
|
+
rollout: null,
|
|
904
|
+
appStoreVersion: "1.0.0",
|
|
905
|
+
package: "/fake/path/test/file.apk",
|
|
906
|
+
};
|
|
907
|
+
releaseHelperFunction(command, done, INVALID_RELEASE_FILE_ERROR_MESSAGE);
|
|
908
|
+
});
|
|
909
|
+
it("release-react fails if CWD does not contain package.json", (done) => {
|
|
910
|
+
var command = {
|
|
911
|
+
type: cli.CommandType.releaseReact,
|
|
912
|
+
appName: "a",
|
|
913
|
+
appStoreVersion: null,
|
|
914
|
+
deploymentName: "Staging",
|
|
915
|
+
description: "Test invalid folder",
|
|
916
|
+
mandatory: false,
|
|
917
|
+
rollout: null,
|
|
918
|
+
platform: "ios",
|
|
919
|
+
};
|
|
920
|
+
var release = sandbox.spy(cmdexec, "release");
|
|
921
|
+
cmdexec
|
|
922
|
+
.execute(command)
|
|
923
|
+
.then(() => {
|
|
924
|
+
done(new Error("Did not throw error."));
|
|
925
|
+
})
|
|
926
|
+
.catch((err) => {
|
|
927
|
+
assert.equal(err.message, 'Unable to find or read "package.json" in the CWD. The "release-react" command must be executed in a React Native project folder.');
|
|
928
|
+
sinon.assert.notCalled(release);
|
|
929
|
+
sinon.assert.notCalled(spawn);
|
|
930
|
+
done();
|
|
931
|
+
})
|
|
932
|
+
.done();
|
|
933
|
+
});
|
|
934
|
+
it("release-react fails if entryFile does not exist", (done) => {
|
|
935
|
+
var command = {
|
|
936
|
+
type: cli.CommandType.releaseReact,
|
|
937
|
+
appName: "a",
|
|
938
|
+
appStoreVersion: null,
|
|
939
|
+
deploymentName: "Staging",
|
|
940
|
+
description: "Test invalid entryFile",
|
|
941
|
+
entryFile: "doesntexist.js",
|
|
942
|
+
mandatory: false,
|
|
943
|
+
rollout: null,
|
|
944
|
+
platform: "ios",
|
|
945
|
+
};
|
|
946
|
+
ensureInTestAppDirectory();
|
|
947
|
+
var release = sandbox.spy(cmdexec, "release");
|
|
948
|
+
cmdexec
|
|
949
|
+
.execute(command)
|
|
950
|
+
.then(() => {
|
|
951
|
+
done(new Error("Did not throw error."));
|
|
952
|
+
})
|
|
953
|
+
.catch((err) => {
|
|
954
|
+
assert.equal(err.message, 'Entry file "doesntexist.js" does not exist.');
|
|
955
|
+
sinon.assert.notCalled(release);
|
|
956
|
+
sinon.assert.notCalled(spawn);
|
|
957
|
+
done();
|
|
958
|
+
})
|
|
959
|
+
.done();
|
|
960
|
+
});
|
|
961
|
+
it("release-react fails if platform is invalid", (done) => {
|
|
962
|
+
var command = {
|
|
963
|
+
type: cli.CommandType.releaseReact,
|
|
964
|
+
appName: "a",
|
|
965
|
+
appStoreVersion: null,
|
|
966
|
+
deploymentName: "Staging",
|
|
967
|
+
description: "Test invalid platform",
|
|
968
|
+
mandatory: false,
|
|
969
|
+
rollout: null,
|
|
970
|
+
platform: "blackberry",
|
|
971
|
+
};
|
|
972
|
+
ensureInTestAppDirectory();
|
|
973
|
+
var release = sandbox.spy(cmdexec, "release");
|
|
974
|
+
cmdexec
|
|
975
|
+
.execute(command)
|
|
976
|
+
.then(() => {
|
|
977
|
+
done(new Error("Did not throw error."));
|
|
978
|
+
})
|
|
979
|
+
.catch((err) => {
|
|
980
|
+
assert.equal(err.message, 'Platform must be either "android", "ios" or "windows".');
|
|
981
|
+
sinon.assert.notCalled(release);
|
|
982
|
+
sinon.assert.notCalled(spawn);
|
|
983
|
+
done();
|
|
984
|
+
})
|
|
985
|
+
.done();
|
|
986
|
+
});
|
|
987
|
+
it("release-react fails if targetBinaryRange is not a valid semver range expression", (done) => {
|
|
988
|
+
var bundleName = "bundle.js";
|
|
989
|
+
var command = {
|
|
990
|
+
type: cli.CommandType.releaseReact,
|
|
991
|
+
appName: "a",
|
|
992
|
+
appStoreVersion: "notsemver",
|
|
993
|
+
bundleName: bundleName,
|
|
994
|
+
deploymentName: "Staging",
|
|
995
|
+
description: "Test uses targetBinaryRange",
|
|
996
|
+
mandatory: false,
|
|
997
|
+
rollout: null,
|
|
998
|
+
platform: "android",
|
|
999
|
+
sourcemapOutput: "index.android.js.map",
|
|
1000
|
+
};
|
|
1001
|
+
ensureInTestAppDirectory();
|
|
1002
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1003
|
+
cmdexec
|
|
1004
|
+
.execute(command)
|
|
1005
|
+
.then(() => {
|
|
1006
|
+
done(new Error("Did not throw error."));
|
|
1007
|
+
})
|
|
1008
|
+
.catch((err) => {
|
|
1009
|
+
assert.equal(err.message, 'Please use a semver-compliant target binary version range, for example "1.0.0", "*" or "^1.2.3".');
|
|
1010
|
+
sinon.assert.notCalled(release);
|
|
1011
|
+
sinon.assert.notCalled(spawn);
|
|
1012
|
+
done();
|
|
1013
|
+
})
|
|
1014
|
+
.done();
|
|
1015
|
+
});
|
|
1016
|
+
it("release-react defaults entry file to index.{platform}.js if not provided", (done) => {
|
|
1017
|
+
var bundleName = "bundle.js";
|
|
1018
|
+
var command = {
|
|
1019
|
+
type: cli.CommandType.releaseReact,
|
|
1020
|
+
appName: "a",
|
|
1021
|
+
appStoreVersion: null,
|
|
1022
|
+
bundleName: bundleName,
|
|
1023
|
+
deploymentName: "Staging",
|
|
1024
|
+
description: "Test default entry file",
|
|
1025
|
+
mandatory: false,
|
|
1026
|
+
rollout: null,
|
|
1027
|
+
platform: "ios",
|
|
1028
|
+
};
|
|
1029
|
+
ensureInTestAppDirectory();
|
|
1030
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1031
|
+
cmdexec
|
|
1032
|
+
.execute(command)
|
|
1033
|
+
.then(() => {
|
|
1034
|
+
var releaseCommand = command;
|
|
1035
|
+
releaseCommand.package = path.join(os.tmpdir(), "CodePush");
|
|
1036
|
+
releaseCommand.appStoreVersion = "1.2.3";
|
|
1037
|
+
sinon.assert.calledOnce(spawn);
|
|
1038
|
+
var spawnCommand = spawn.args[0][0];
|
|
1039
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1040
|
+
assert.equal(spawnCommand, "node");
|
|
1041
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${path.join(os.tmpdir(), "CodePush")} --bundle-output ${path.join(os.tmpdir(), "CodePush", bundleName)} --dev false --entry-file index.ios.js --platform ios`);
|
|
1042
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1043
|
+
done();
|
|
1044
|
+
})
|
|
1045
|
+
.done();
|
|
1046
|
+
});
|
|
1047
|
+
it('release-react defaults bundle name to "main.jsbundle" if not provided and platform is "ios"', (done) => {
|
|
1048
|
+
var command = {
|
|
1049
|
+
type: cli.CommandType.releaseReact,
|
|
1050
|
+
appName: "a",
|
|
1051
|
+
appStoreVersion: null,
|
|
1052
|
+
deploymentName: "Staging",
|
|
1053
|
+
description: "Test default entry file",
|
|
1054
|
+
mandatory: false,
|
|
1055
|
+
rollout: null,
|
|
1056
|
+
platform: "ios",
|
|
1057
|
+
};
|
|
1058
|
+
ensureInTestAppDirectory();
|
|
1059
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1060
|
+
cmdexec
|
|
1061
|
+
.execute(command)
|
|
1062
|
+
.then(() => {
|
|
1063
|
+
var releaseCommand = clone(command);
|
|
1064
|
+
var packagePath = path.join(os.tmpdir(), "CodePush");
|
|
1065
|
+
releaseCommand.package = packagePath;
|
|
1066
|
+
releaseCommand.appStoreVersion = "1.2.3";
|
|
1067
|
+
sinon.assert.calledOnce(spawn);
|
|
1068
|
+
var spawnCommand = spawn.args[0][0];
|
|
1069
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1070
|
+
assert.equal(spawnCommand, "node");
|
|
1071
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${packagePath} --bundle-output ${path.join(packagePath, "main.jsbundle")} --dev false --entry-file index.ios.js --platform ios`);
|
|
1072
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1073
|
+
done();
|
|
1074
|
+
})
|
|
1075
|
+
.done();
|
|
1076
|
+
});
|
|
1077
|
+
it('release-react defaults bundle name to "index.android.bundle" if not provided and platform is "android"', (done) => {
|
|
1078
|
+
var command = {
|
|
1079
|
+
type: cli.CommandType.releaseReact,
|
|
1080
|
+
appName: "a",
|
|
1081
|
+
appStoreVersion: null,
|
|
1082
|
+
deploymentName: "Staging",
|
|
1083
|
+
description: "Test default entry file",
|
|
1084
|
+
mandatory: false,
|
|
1085
|
+
rollout: null,
|
|
1086
|
+
platform: "android",
|
|
1087
|
+
};
|
|
1088
|
+
ensureInTestAppDirectory();
|
|
1089
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1090
|
+
cmdexec
|
|
1091
|
+
.execute(command)
|
|
1092
|
+
.then(() => {
|
|
1093
|
+
var releaseCommand = clone(command);
|
|
1094
|
+
var packagePath = path.join(os.tmpdir(), "CodePush");
|
|
1095
|
+
releaseCommand.package = packagePath;
|
|
1096
|
+
releaseCommand.appStoreVersion = "1.0.0";
|
|
1097
|
+
sinon.assert.calledOnce(spawn);
|
|
1098
|
+
var spawnCommand = spawn.args[0][0];
|
|
1099
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1100
|
+
assert.equal(spawnCommand, "node");
|
|
1101
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${packagePath} --bundle-output ${path.join(packagePath, "index.android.bundle")} --dev false --entry-file index.android.js --platform android`);
|
|
1102
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1103
|
+
done();
|
|
1104
|
+
})
|
|
1105
|
+
.done();
|
|
1106
|
+
});
|
|
1107
|
+
it('release-react defaults bundle name to "index.windows.bundle" if not provided and platform is "windows"', (done) => {
|
|
1108
|
+
var command = {
|
|
1109
|
+
type: cli.CommandType.releaseReact,
|
|
1110
|
+
appName: "a",
|
|
1111
|
+
appStoreVersion: null,
|
|
1112
|
+
deploymentName: "Staging",
|
|
1113
|
+
description: "Test default entry file",
|
|
1114
|
+
mandatory: false,
|
|
1115
|
+
rollout: null,
|
|
1116
|
+
platform: "windows",
|
|
1117
|
+
};
|
|
1118
|
+
ensureInTestAppDirectory();
|
|
1119
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1120
|
+
cmdexec
|
|
1121
|
+
.execute(command)
|
|
1122
|
+
.then(() => {
|
|
1123
|
+
var releaseCommand = clone(command);
|
|
1124
|
+
var packagePath = path.join(os.tmpdir(), "CodePush");
|
|
1125
|
+
releaseCommand.package = packagePath;
|
|
1126
|
+
releaseCommand.appStoreVersion = "1.0.0";
|
|
1127
|
+
sinon.assert.calledOnce(spawn);
|
|
1128
|
+
var spawnCommand = spawn.args[0][0];
|
|
1129
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1130
|
+
assert.equal(spawnCommand, "node");
|
|
1131
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${packagePath} --bundle-output ${path.join(packagePath, "index.windows.bundle")} --dev false --entry-file index.windows.js --platform windows`);
|
|
1132
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1133
|
+
done();
|
|
1134
|
+
})
|
|
1135
|
+
.done();
|
|
1136
|
+
});
|
|
1137
|
+
it("release-react generates dev bundle", (done) => {
|
|
1138
|
+
var bundleName = "bundle.js";
|
|
1139
|
+
var command = {
|
|
1140
|
+
type: cli.CommandType.releaseReact,
|
|
1141
|
+
appName: "a",
|
|
1142
|
+
appStoreVersion: null,
|
|
1143
|
+
bundleName: bundleName,
|
|
1144
|
+
deploymentName: "Staging",
|
|
1145
|
+
development: true,
|
|
1146
|
+
description: "Test generates dev bundle",
|
|
1147
|
+
mandatory: false,
|
|
1148
|
+
rollout: null,
|
|
1149
|
+
platform: "android",
|
|
1150
|
+
sourcemapOutput: "index.android.js.map",
|
|
1151
|
+
};
|
|
1152
|
+
ensureInTestAppDirectory();
|
|
1153
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1154
|
+
cmdexec
|
|
1155
|
+
.execute(command)
|
|
1156
|
+
.then(() => {
|
|
1157
|
+
var releaseCommand = command;
|
|
1158
|
+
releaseCommand.package = path.join(os.tmpdir(), "CodePush");
|
|
1159
|
+
releaseCommand.appStoreVersion = "1.2.3";
|
|
1160
|
+
sinon.assert.calledOnce(spawn);
|
|
1161
|
+
var spawnCommand = spawn.args[0][0];
|
|
1162
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1163
|
+
assert.equal(spawnCommand, "node");
|
|
1164
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${path.join(os.tmpdir(), "CodePush")} --bundle-output ${path.join(os.tmpdir(), "CodePush", bundleName)} --dev true --entry-file index.android.js --platform android --sourcemap-output index.android.js.map`);
|
|
1165
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1166
|
+
done();
|
|
1167
|
+
})
|
|
1168
|
+
.done();
|
|
1169
|
+
});
|
|
1170
|
+
it("release-react generates sourcemaps", (done) => {
|
|
1171
|
+
var bundleName = "bundle.js";
|
|
1172
|
+
var command = {
|
|
1173
|
+
type: cli.CommandType.releaseReact,
|
|
1174
|
+
appName: "a",
|
|
1175
|
+
appStoreVersion: null,
|
|
1176
|
+
bundleName: bundleName,
|
|
1177
|
+
deploymentName: "Staging",
|
|
1178
|
+
description: "Test generates sourcemaps",
|
|
1179
|
+
mandatory: false,
|
|
1180
|
+
rollout: null,
|
|
1181
|
+
platform: "android",
|
|
1182
|
+
sourcemapOutput: "index.android.js.map",
|
|
1183
|
+
};
|
|
1184
|
+
ensureInTestAppDirectory();
|
|
1185
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1186
|
+
cmdexec
|
|
1187
|
+
.execute(command)
|
|
1188
|
+
.then(() => {
|
|
1189
|
+
var releaseCommand = command;
|
|
1190
|
+
releaseCommand.package = path.join(os.tmpdir(), "CodePush");
|
|
1191
|
+
releaseCommand.appStoreVersion = "1.2.3";
|
|
1192
|
+
sinon.assert.calledOnce(spawn);
|
|
1193
|
+
var spawnCommand = spawn.args[0][0];
|
|
1194
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1195
|
+
assert.equal(spawnCommand, "node");
|
|
1196
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${path.join(os.tmpdir(), "CodePush")} --bundle-output ${path.join(os.tmpdir(), "CodePush", bundleName)} --dev false --entry-file index.android.js --platform android --sourcemap-output index.android.js.map`);
|
|
1197
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1198
|
+
done();
|
|
1199
|
+
})
|
|
1200
|
+
.done();
|
|
1201
|
+
});
|
|
1202
|
+
it("release-react uses specified targetBinaryRange option", (done) => {
|
|
1203
|
+
var bundleName = "bundle.js";
|
|
1204
|
+
var command = {
|
|
1205
|
+
type: cli.CommandType.releaseReact,
|
|
1206
|
+
appName: "a",
|
|
1207
|
+
appStoreVersion: ">=1.0.0 <1.0.5",
|
|
1208
|
+
bundleName: bundleName,
|
|
1209
|
+
deploymentName: "Staging",
|
|
1210
|
+
description: "Test uses targetBinaryRange",
|
|
1211
|
+
mandatory: false,
|
|
1212
|
+
rollout: null,
|
|
1213
|
+
platform: "android",
|
|
1214
|
+
sourcemapOutput: "index.android.js.map",
|
|
1215
|
+
};
|
|
1216
|
+
ensureInTestAppDirectory();
|
|
1217
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1218
|
+
cmdexec
|
|
1219
|
+
.execute(command)
|
|
1220
|
+
.then(() => {
|
|
1221
|
+
var releaseCommand = command;
|
|
1222
|
+
releaseCommand.package = path.join(os.tmpdir(), "CodePush");
|
|
1223
|
+
sinon.assert.calledOnce(spawn);
|
|
1224
|
+
var spawnCommand = spawn.args[0][0];
|
|
1225
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1226
|
+
assert.equal(spawnCommand, "node");
|
|
1227
|
+
assert.equal(spawnCommandArgs, `${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${path.join(os.tmpdir(), "CodePush")} --bundle-output ${path.join(os.tmpdir(), "CodePush", bundleName)} --dev false --entry-file index.android.js --platform android --sourcemap-output index.android.js.map`);
|
|
1228
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1229
|
+
done();
|
|
1230
|
+
})
|
|
1231
|
+
.done();
|
|
1232
|
+
});
|
|
1233
|
+
it("release-react applies arguments to node binary provided via the CODE_PUSH_NODE_ARGS env var", (done) => {
|
|
1234
|
+
var bundleName = "bundle.js";
|
|
1235
|
+
var command = {
|
|
1236
|
+
type: cli.CommandType.releaseReact,
|
|
1237
|
+
appName: "a",
|
|
1238
|
+
appStoreVersion: null,
|
|
1239
|
+
bundleName: bundleName,
|
|
1240
|
+
deploymentName: "Staging",
|
|
1241
|
+
description: "Test default entry file",
|
|
1242
|
+
mandatory: false,
|
|
1243
|
+
rollout: null,
|
|
1244
|
+
platform: "ios",
|
|
1245
|
+
};
|
|
1246
|
+
ensureInTestAppDirectory();
|
|
1247
|
+
var release = sandbox.stub(cmdexec, "release");
|
|
1248
|
+
var _CODE_PUSH_NODE_ARGS = process.env.CODE_PUSH_NODE_ARGS;
|
|
1249
|
+
process.env.CODE_PUSH_NODE_ARGS = " --foo=bar --baz ";
|
|
1250
|
+
cmdexec
|
|
1251
|
+
.execute(command)
|
|
1252
|
+
.then(() => {
|
|
1253
|
+
var releaseCommand = command;
|
|
1254
|
+
releaseCommand.package = path.join(os.tmpdir(), "CodePush");
|
|
1255
|
+
releaseCommand.appStoreVersion = "1.2.3";
|
|
1256
|
+
sinon.assert.calledOnce(spawn);
|
|
1257
|
+
var spawnCommand = spawn.args[0][0];
|
|
1258
|
+
var spawnCommandArgs = spawn.args[0][1].join(" ");
|
|
1259
|
+
assert.equal(spawnCommand, "node");
|
|
1260
|
+
assert.equal(spawnCommandArgs, `--foo=bar --baz ${path.join("node_modules", "react-native", "local-cli", "cli.js")} bundle --assets-dest ${path.join(os.tmpdir(), "CodePush")} --bundle-output ${path.join(os.tmpdir(), "CodePush", bundleName)} --dev false --entry-file index.ios.js --platform ios`);
|
|
1261
|
+
assertJsonDescribesObject(JSON.stringify(release.args[0][0], /*replacer=*/ null, /*spacing=*/ 2), releaseCommand);
|
|
1262
|
+
process.env.CODE_PUSH_NODE_ARGS = _CODE_PUSH_NODE_ARGS;
|
|
1263
|
+
done();
|
|
1264
|
+
})
|
|
1265
|
+
.done();
|
|
1266
|
+
});
|
|
1267
|
+
it("sessionList lists session name and expires fields", (done) => {
|
|
1268
|
+
var command = {
|
|
1269
|
+
type: cli.CommandType.sessionList,
|
|
1270
|
+
format: "json",
|
|
1271
|
+
};
|
|
1272
|
+
cmdexec.execute(command).done(() => {
|
|
1273
|
+
sinon.assert.calledOnce(log);
|
|
1274
|
+
assert.equal(log.args[0].length, 1);
|
|
1275
|
+
var actual = log.args[0][0];
|
|
1276
|
+
var expected = [
|
|
1277
|
+
{
|
|
1278
|
+
loggedInTime: 0,
|
|
1279
|
+
machineName: TEST_MACHINE_NAME,
|
|
1280
|
+
},
|
|
1281
|
+
];
|
|
1282
|
+
assertJsonDescribesObject(actual, expected);
|
|
1283
|
+
done();
|
|
1284
|
+
});
|
|
1285
|
+
});
|
|
1286
|
+
it("sessionRemove removes session", (done) => {
|
|
1287
|
+
var machineName = TEST_MACHINE_NAME;
|
|
1288
|
+
var command = {
|
|
1289
|
+
type: cli.CommandType.sessionRemove,
|
|
1290
|
+
machineName: machineName,
|
|
1291
|
+
};
|
|
1292
|
+
var removeSession = sandbox.spy(cmdexec.sdk, "removeSession");
|
|
1293
|
+
cmdexec.execute(command).done(() => {
|
|
1294
|
+
sinon.assert.calledOnce(removeSession);
|
|
1295
|
+
sinon.assert.calledWithExactly(removeSession, machineName);
|
|
1296
|
+
sinon.assert.calledOnce(log);
|
|
1297
|
+
sinon.assert.calledWithExactly(log, `Successfully removed the login session for "${machineName}".`);
|
|
1298
|
+
done();
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
it("sessionRemove does not remove session if cancelled", (done) => {
|
|
1302
|
+
var machineName = TEST_MACHINE_NAME;
|
|
1303
|
+
var command = {
|
|
1304
|
+
type: cli.CommandType.sessionRemove,
|
|
1305
|
+
machineName: machineName,
|
|
1306
|
+
};
|
|
1307
|
+
var removeSession = sandbox.spy(cmdexec.sdk, "removeSession");
|
|
1308
|
+
wasConfirmed = false;
|
|
1309
|
+
cmdexec.execute(command).done(() => {
|
|
1310
|
+
sinon.assert.notCalled(removeSession);
|
|
1311
|
+
sinon.assert.calledOnce(log);
|
|
1312
|
+
sinon.assert.calledWithExactly(log, "Session removal cancelled.");
|
|
1313
|
+
done();
|
|
1314
|
+
});
|
|
1315
|
+
});
|
|
1316
|
+
it("sessionRemove does not remove current session", (done) => {
|
|
1317
|
+
var machineName = os.hostname();
|
|
1318
|
+
var command = {
|
|
1319
|
+
type: cli.CommandType.sessionRemove,
|
|
1320
|
+
machineName: machineName,
|
|
1321
|
+
};
|
|
1322
|
+
wasConfirmed = false;
|
|
1323
|
+
cmdexec
|
|
1324
|
+
.execute(command)
|
|
1325
|
+
.then(() => {
|
|
1326
|
+
done(new Error("Did not throw error."));
|
|
1327
|
+
})
|
|
1328
|
+
.catch(() => {
|
|
1329
|
+
done();
|
|
1330
|
+
})
|
|
1331
|
+
.done();
|
|
1332
|
+
});
|
|
1333
|
+
function releaseHelperFunction(command, done, expectedError) {
|
|
1334
|
+
cmdexec.execute(command).done(() => {
|
|
1335
|
+
throw "Error Expected";
|
|
1336
|
+
}, (error) => {
|
|
1337
|
+
assert(!!error);
|
|
1338
|
+
assert.equal(error.message, expectedError);
|
|
1339
|
+
done();
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
});
|