Skip to content

Commit ffdc3da

Browse files
committed
remove default basic auth from integration test
1 parent 01dde3a commit ffdc3da

File tree

1 file changed

+64
-46
lines changed

1 file changed

+64
-46
lines changed

test/test_integration.py

Lines changed: 64 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636

3737
# 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')
4040
customIp = None
4141
if "TESTENV_CUSTOMIP" in os.environ:
4242
customIp = os.environ["TESTENV_CUSTOMIP"]
@@ -103,22 +103,26 @@ class IntegrationTestMSBClientRestInterfaces(unittest.TestCase):
103103
def test_smartobjectmanagement_availability(self):
104104
logging.info("Smart Object URL: >" + so_url + "<")
105105

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)
111113
self.assertEqual(response.status_code, 201, "Can not reach smart-object-management")
112114

113115
@pytest.mark.run(order=2)
114116
def test_integrationflowmanagement_availability(self):
115117
logging.info("Flow URL: >" + str(flow_url) + "<")
116118

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)
122126
self.assertEqual(response.status_code, 200, "Can not reach integration-flow-management")
123127

124128

@@ -130,11 +134,13 @@ def test_getVerificationToken(self):
130134
logging.info("Broker URL: >" + str(broker_url) + "<")
131135

132136
# 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)
138144
self.assertEqual(
139145
response.status_code,
140146
201,
@@ -245,16 +251,18 @@ def test_communication(self):
245251
logging.debug(flow_json)
246252

247253
# create flow
248-
response = requests.post(
249-
flow_url + "/integrationFlow/create",
250-
headers={
254+
params = {
255+
"url": flow_url + "/integrationFlow/create",
256+
"headers": {
251257
"Accept": "application/json",
252258
"Content-Type": "application/json",
253259
},
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)
258266
response_dict = json.loads(response.text)
259267
self.assertEqual(
260268
response.status_code, 201, str("Creating integration flow failed: " + str(response))
@@ -274,11 +282,13 @@ def test_communication(self):
274282
# Test deploy integration flow
275283
#
276284
# 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)
282292
self.assertEqual(
283293
response.status_code, 200, str("Deploying integration flow failed: " + str(response))
284294
)
@@ -361,11 +371,13 @@ def test_communication(self):
361371
#
362372
# undeploy flow
363373
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)
369381
self.assertEqual(
370382
response.status_code,
371383
200,
@@ -379,15 +391,17 @@ def test_communication(self):
379391
#
380392
# delete flow
381393
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": {
385397
"Accept": "application/json",
386398
"Content-Type": "application/json",
387399
},
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)
391405
self.assertEqual(
392406
response.status_code, 200, str("Deleting integration flow failed")
393407
)
@@ -399,12 +413,16 @@ def test_communication(self):
399413
#
400414
# delete smart object
401415
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)
408426
self.assertEqual(response.status_code, 200, "Problem deleting smart object")
409427

410428
time.sleep(WAITING_TIME)

0 commit comments

Comments
 (0)