35
35
36
36
37
37
# Check env variables
38
- api_username = os .getenv ('API_USERNAME' , 'admin' )
39
- api_password = os .getenv ('API_PASSWORD' , 'password' )
38
+ api_username = os .getenv ('API_USERNAME' )
39
+ api_password = os .getenv ('API_PASSWORD' )
40
40
customIp = None
41
41
if "TESTENV_CUSTOMIP" in os .environ :
42
42
customIp = os .environ ["TESTENV_CUSTOMIP" ]
@@ -103,22 +103,26 @@ class IntegrationTestMSBClientRestInterfaces(unittest.TestCase):
103
103
def test_smartobjectmanagement_availability (self ):
104
104
logging .info ("Smart Object URL: >" + so_url + "<" )
105
105
106
- response = requests .get (
107
- so_url + "/service/token/" + owner_uuid ,
108
- verify = False ,
109
- auth = HTTPBasicAuth (api_username , api_password )
110
- )
106
+ params = {
107
+ "url" : so_url + "/service/token/" + owner_uuid ,
108
+ "verify" : False ,
109
+ }
110
+ if api_username and api_password :
111
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
112
+ response = requests .get (** params )
111
113
self .assertEqual (response .status_code , 201 , "Can not reach smart-object-management" )
112
114
113
115
@pytest .mark .run (order = 2 )
114
116
def test_integrationflowmanagement_availability (self ):
115
117
logging .info ("Flow URL: >" + str (flow_url ) + "<" )
116
118
117
- response = requests .get (
118
- flow_url + "/integrationFlow/customer/" + owner_uuid ,
119
- verify = False ,
120
- auth = HTTPBasicAuth (api_username , api_password )
121
- )
119
+ params = {
120
+ "url" : flow_url + "/integrationFlow/customer/" + owner_uuid ,
121
+ "verify" : False ,
122
+ }
123
+ if api_username and api_password :
124
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
125
+ response = requests .get (** params )
122
126
self .assertEqual (response .status_code , 200 , "Can not reach integration-flow-management" )
123
127
124
128
@@ -130,11 +134,13 @@ def test_getVerificationToken(self):
130
134
logging .info ("Broker URL: >" + str (broker_url ) + "<" )
131
135
132
136
# get valid verification token
133
- response = requests .get (
134
- so_url + "/service/token/" + owner_uuid ,
135
- verify = False ,
136
- auth = HTTPBasicAuth (api_username , api_password )
137
- )
137
+ params = {
138
+ "url" : so_url + "/service/token/" + owner_uuid ,
139
+ "verify" : False ,
140
+ }
141
+ if api_username and api_password :
142
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
143
+ response = requests .get (** params )
138
144
self .assertEqual (
139
145
response .status_code ,
140
146
201 ,
@@ -245,16 +251,18 @@ def test_communication(self):
245
251
logging .debug (flow_json )
246
252
247
253
# create flow
248
- response = requests . post (
249
- flow_url + "/integrationFlow/create" ,
250
- headers = {
254
+ params = {
255
+ "url" : flow_url + "/integrationFlow/create" ,
256
+ " headers" : {
251
257
"Accept" : "application/json" ,
252
258
"Content-Type" : "application/json" ,
253
259
},
254
- data = str (flow_json ),
255
- verify = False ,
256
- auth = HTTPBasicAuth (api_username , api_password )
257
- )
260
+ "data" : str (flow_json ),
261
+ "verify" : False ,
262
+ }
263
+ if api_username and api_password :
264
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
265
+ response = requests .post (** params )
258
266
response_dict = json .loads (response .text )
259
267
self .assertEqual (
260
268
response .status_code , 201 , str ("Creating integration flow failed: " + str (response ))
@@ -274,11 +282,13 @@ def test_communication(self):
274
282
# Test deploy integration flow
275
283
#
276
284
# deploy flow
277
- response = requests .put (
278
- flow_url + "/integrationFlow/" + str (flow_id ) + "/deploy" ,
279
- verify = False ,
280
- auth = HTTPBasicAuth (api_username , api_password )
281
- )
285
+ params = {
286
+ "url" : flow_url + "/integrationFlow/" + str (flow_id ) + "/deploy" ,
287
+ "verify" : False ,
288
+ }
289
+ if api_username and api_password :
290
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
291
+ response = requests .put (** params )
282
292
self .assertEqual (
283
293
response .status_code , 200 , str ("Deploying integration flow failed: " + str (response ))
284
294
)
@@ -361,11 +371,13 @@ def test_communication(self):
361
371
#
362
372
# undeploy flow
363
373
if flowDeployed :
364
- response = requests .put (
365
- flow_url + "/integrationFlow/" + str (flow_id ) + "/undeploy" ,
366
- verify = False ,
367
- auth = HTTPBasicAuth (api_username , api_password )
368
- )
374
+ params = {
375
+ "url" : flow_url + "/integrationFlow/" + str (flow_id ) + "/undeploy" ,
376
+ "verify" : False ,
377
+ }
378
+ if api_username and api_password :
379
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
380
+ response = requests .put (** params )
369
381
self .assertEqual (
370
382
response .status_code ,
371
383
200 ,
@@ -379,15 +391,17 @@ def test_communication(self):
379
391
#
380
392
# delete flow
381
393
if flowCreated :
382
- response = requests . delete (
383
- flow_url + "/integrationFlow/" + str (flow_id ),
384
- headers = {
394
+ params = {
395
+ "url" : flow_url + "/integrationFlow/" + str (flow_id ),
396
+ " headers" : {
385
397
"Accept" : "application/json" ,
386
398
"Content-Type" : "application/json" ,
387
399
},
388
- verify = False ,
389
- auth = HTTPBasicAuth (api_username , api_password )
390
- )
400
+ "verify" : False ,
401
+ }
402
+ if api_username and api_password :
403
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
404
+ response = requests .delete (** params )
391
405
self .assertEqual (
392
406
response .status_code , 200 , str ("Deleting integration flow failed" )
393
407
)
@@ -399,12 +413,16 @@ def test_communication(self):
399
413
#
400
414
# delete smart object
401
415
if soCreated :
402
- response = requests .delete (
403
- so_url + "/smartobject/" + SO_UUID ,
404
- headers = {"Content-Type" : "application/json" },
405
- verify = False ,
406
- auth = HTTPBasicAuth (api_username , api_password )
407
- )
416
+ params = {
417
+ "url" : so_url + "/smartobject/" + SO_UUID ,
418
+ "headers" : {
419
+ "Content-Type" : "application/json" ,
420
+ },
421
+ "verify" : False ,
422
+ }
423
+ if api_username and api_password :
424
+ params ["auth" ] = HTTPBasicAuth (api_username , api_password )
425
+ response = requests .delete (** params )
408
426
self .assertEqual (response .status_code , 200 , "Problem deleting smart object" )
409
427
410
428
time .sleep (WAITING_TIME )
0 commit comments