10
10
*/
11
11
12
12
import { BundlePusher } from "../../../src/api/BundlePush/BundlePusher" ;
13
- import { IHandlerParameters , ImperativeError , IImperativeError } from "@zowe/imperative" ;
13
+ import { IHandlerParameters , ImperativeError , IImperativeError , IProfile } from "@zowe/imperative" ;
14
14
import * as cmci from "@zowe/cics" ;
15
15
import * as PushBundleDefinition from "../../../src/cli/push/bundle/PushBundle.definition" ;
16
16
import * as fse from "fs-extra" ;
@@ -111,7 +111,7 @@ describe("BundlePusher01", () => {
111
111
lstatSpy = jest . spyOn ( fs , "lstatSync" ) . mockImplementation ( ( ) => ( IS_NOT_DIRECTORY ) ) ;
112
112
cmciSpy = jest . spyOn ( cmci , "getResource" ) . mockImplementation ( ( ) => ( { response : { records : { } } } ) ) ;
113
113
consoleText = "" ;
114
- zosmfProfile = { host : "wibble" , user : "user" , password : "thisIsntReal" } ;
114
+ zosmfProfile = { host : "wibble" , user : "user" , password : "thisIsntReal" , port : 443 , rejectUnauthorized : true } ;
115
115
sshProfile = { host : "wibble" , user : "user" , password : "thisIsntReal" } ;
116
116
cicsProfile = undefined ;
117
117
} ) ;
@@ -199,6 +199,58 @@ describe("BundlePusher01", () => {
199
199
200
200
expect ( zosMFSpy ) . toHaveBeenCalledTimes ( 1 ) ;
201
201
} ) ;
202
+ it ( "should implement --zosmf-* overrides" , async ( ) => {
203
+ zosmfProfile = { host : "wibble" , user : "user" } ;
204
+ sshProfile = { host : "wibble" , user : "user" } ;
205
+ const parms = getCommonParmsForPushTests ( ) ;
206
+ parms . arguments . zh = "overrideHost" ;
207
+ parms . arguments . zp = 123 ;
208
+ parms . arguments . zu = "overrideUser" ;
209
+ parms . arguments . zpw = "overridePassword" ;
210
+ parms . arguments . zru = false ;
211
+ parms . arguments . zbp = "overrideBasePath" ;
212
+ zosMFSpy . mockImplementationOnce ( ( profile : IProfile ) => {
213
+ expect ( profile . host ) . toMatch ( "overrideHost" ) ;
214
+ expect ( profile . port ) . toEqual ( 123 ) ;
215
+ expect ( profile . user ) . toMatch ( "overrideUser" ) ;
216
+ expect ( profile . password ) . toMatch ( "overridePassword" ) ;
217
+ expect ( profile . rejectUnauthorized ) . toEqual ( false ) ;
218
+ expect ( profile . basePath ) . toMatch ( "overrideBasePath" ) ;
219
+ } ) ;
220
+
221
+ await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
222
+ "PUSH operation completed" , parms ) ;
223
+ } ) ;
224
+ it ( "should complain if zosmf-host notset" , async ( ) => {
225
+ zosmfProfile = undefined ;
226
+
227
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
228
+ "Required parameter --zosmf-host is not set." ) ;
229
+ } ) ;
230
+ it ( "should complain if zosmf-port notset" , async ( ) => {
231
+ zosmfProfile = { host : "wibble" } ;
232
+
233
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
234
+ "Required parameter --zosmf-port is not set." ) ;
235
+ } ) ;
236
+ it ( "should complain if zosmf-user notset" , async ( ) => {
237
+ zosmfProfile = { host : "wibble" , port : 443 } ;
238
+
239
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
240
+ "Required parameter --zosmf-user is not set." ) ;
241
+ } ) ;
242
+ it ( "should complain if zosmf-password notset" , async ( ) => {
243
+ zosmfProfile = { host : "wibble" , port : 443 , user : "user" } ;
244
+
245
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
246
+ "Required parameter --zosmf-password is not set." ) ;
247
+ } ) ;
248
+ it ( "should complain if zosmf-reject-unauthorized notset" , async ( ) => {
249
+ zosmfProfile = { host : "wibble" , port : 443 , user : "user" , password : "thisIsntReal" } ;
250
+
251
+ await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
252
+ "Required parameter --zosmf-reject-unauthorized is not set." ) ;
253
+ } ) ;
202
254
it ( "should complain with missing SSH profile for push" , async ( ) => {
203
255
sshSpy . mockImplementationOnce ( ( ) => { throw new Error ( "Injected SSH Create error" ) ; } ) ;
204
256
await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false , "Injected SSH Create error" ) ;
@@ -207,15 +259,13 @@ describe("BundlePusher01", () => {
207
259
expect ( sshSpy ) . toHaveBeenCalledTimes ( 1 ) ;
208
260
} ) ;
209
261
it ( "should complain with mismatching zOSMF and SSH profile host names" , async ( ) => {
210
- zosmfProfile = { host : "wibble" , user : "user" } ;
211
262
sshProfile = { host : "wobble" , user : "user" } ;
212
263
213
264
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
214
265
"PUSH operation completed" ) ;
215
266
expect ( consoleText ) . toContain ( "WARNING: ssh profile --host value 'wobble' does not match zosmf value 'wibble'." ) ;
216
267
} ) ;
217
268
it ( "should not complain with matching zOSMF and SSH profile host names" , async ( ) => {
218
- zosmfProfile = { host : "wibble" , user : "user" } ;
219
269
sshProfile = { host : "wibble" , user : "user" } ;
220
270
221
271
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
@@ -237,67 +287,59 @@ describe("BundlePusher01", () => {
237
287
expect ( consoleText ) . not . toContain ( "WARNING: cics profile" ) ;
238
288
} ) ;
239
289
it ( "should complain with mismatching zOSMF and SSH profile user names" , async ( ) => {
240
- zosmfProfile = { host : "wibble" , user : "fred" } ;
241
290
sshProfile = { host : "wibble" , user : "joe" } ;
242
291
243
292
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
244
293
"PUSH operation completed" ) ;
245
- expect ( consoleText ) . toContain ( "WARNING: ssh profile --user value 'joe' does not match zosmf value 'fred '." ) ;
294
+ expect ( consoleText ) . toContain ( "WARNING: ssh profile --user value 'joe' does not match zosmf value 'user '." ) ;
246
295
} ) ;
247
296
it ( "should not complain with matching zOSMF and SSH profile user names" , async ( ) => {
248
- zosmfProfile = { host : "wibble" , user : "fred" } ;
249
- sshProfile = { host : "wibble" , user : "fred" } ;
297
+ sshProfile = { host : "wibble" , user : "user" } ;
250
298
251
299
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
252
300
"PUSH operation completed" ) ;
253
301
expect ( consoleText ) . not . toContain ( "WARNING: ssh profile" ) ;
254
302
} ) ;
255
303
it ( "should not complain with matching zOSMF and SSH profile user names - case" , async ( ) => {
256
- zosmfProfile = { host : "wibble" , user : "fred" } ;
257
- sshProfile = { host : "wibble" , user : "FRED" } ;
304
+ sshProfile = { host : "wibble" , user : "USER" } ;
258
305
259
306
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
260
307
"PUSH operation completed" ) ;
261
308
expect ( consoleText ) . not . toContain ( "WARNING: ssh profile" ) ;
262
309
} ) ;
263
310
it ( "should complain with mismatching zOSMF and CICS profile user names" , async ( ) => {
264
- zosmfProfile = { host : "wibble" , user : "fred" } ;
265
311
sshProfile = { host : "wibble" , user : "fred" } ;
266
312
cicsProfile = { host : "wibble" , user : "joe" , password : "thisIsntReal" , cicsPlex : "12345678" } ;
267
313
268
314
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
269
315
"PUSH operation completed" ) ;
270
- expect ( consoleText ) . toContain ( "WARNING: cics profile --user value 'joe' does not match zosmf value 'fred '." ) ;
316
+ expect ( consoleText ) . toContain ( "WARNING: cics profile --user value 'joe' does not match zosmf value 'user '." ) ;
271
317
} ) ;
272
318
it ( "should complain with mismatching zOSMF and SSH profile passwords" , async ( ) => {
273
- zosmfProfile = { host : "wibble" , user : "fred" , password : "fakeZosmfPassword" } ;
274
- sshProfile = { host : "wibble" , user : "fred" , password : "fakeSshPassword" } ;
319
+ sshProfile = { host : "wibble" , user : "user" , password : "fakeSshPassword" } ;
275
320
276
321
await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
277
322
"Incompatible security credentials exist in the zosmf and ssh profiles." ) ;
278
323
279
- expect ( consoleText ) . not . toContain ( "fakeZosmfPassword " ) ;
324
+ expect ( consoleText ) . not . toContain ( "thisIsntReal " ) ;
280
325
expect ( consoleText ) . not . toContain ( "fakeSshPassword" ) ;
281
326
} ) ;
282
327
it ( "should tolerate mismatching zOSMF and SSH credentials if SSH keys are used" , async ( ) => {
283
- zosmfProfile = { host : "wibble" , user : "fred" , password : "fakeZosmfPassword" } ;
284
328
sshProfile = { host : "wibble" , user : "fred" , privateKey : "fakeSshKey" } ;
285
329
286
330
await runPushTest ( "__tests__/__resources__/ExampleBundle01" , true ,
287
331
"PUSH operation completed" ) ;
288
332
289
- expect ( consoleText ) . not . toContain ( "fakeZosmfPassword " ) ;
333
+ expect ( consoleText ) . not . toContain ( "thisIsntReal " ) ;
290
334
expect ( consoleText ) . not . toContain ( "fakeSshKey" ) ;
291
335
} ) ;
292
336
it ( "should complain with mismatching zOSMF and cics profile passwords" , async ( ) => {
293
- zosmfProfile = { host : "wibble" , user : "fred" , password : "fakePassword" } ;
294
- sshProfile = { host : "wibble" , user : "fred" , password : "fakePassword" } ;
295
- cicsProfile = { host : "wibble" , user : "fred" , password : "fakePassword2" , cicsPlex : "12345678" } ;
337
+ cicsProfile = { host : "wibble" , user : "user" , password : "fakePassword2" , cicsPlex : "12345678" } ;
296
338
297
339
await runPushTestWithError ( "__tests__/__resources__/ExampleBundle01" , false ,
298
340
"Incompatible security credentials exist in the zosmf and cics profiles." ) ;
299
341
300
- expect ( consoleText ) . not . toContain ( "fakePassword " ) ;
342
+ expect ( consoleText ) . not . toContain ( "thisIsntReal " ) ;
301
343
expect ( consoleText ) . not . toContain ( "fakePassword2" ) ;
302
344
} ) ;
303
345
it ( "should complain with mismatching cics-deploy and CICS plex names" , async ( ) => {
@@ -1552,5 +1594,11 @@ function getCommonParmsForPushTests(): IHandlerParameters {
1552
1594
parms . arguments . targetstate = "ENABLED" ;
1553
1595
parms . arguments . targetdir = "/u/ThisDoesNotExist" ;
1554
1596
parms . arguments . overwrite = undefined ;
1597
+ parms . arguments . zh = undefined ;
1598
+ parms . arguments . zp = undefined ;
1599
+ parms . arguments . zu = undefined ;
1600
+ parms . arguments . zpw = undefined ;
1601
+ parms . arguments . zru = undefined ;
1602
+ parms . arguments . zbp = undefined ;
1555
1603
return parms ;
1556
1604
}
0 commit comments