aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Duval <thomas.duval@orange.com>2016-09-12 11:36:31 +0200
committerThomas Duval <thomas.duval@orange.com>2016-09-20 10:38:38 +0200
commitcdcd1fd6690b69af3a3cf4b430e51e4febec1c9a (patch)
treea099583efae80e9b2694f60df3beb903695e10f1 /tests
parent4fc038ee9c0a633a0c505d750818698331c19c69 (diff)
Modify the auth process for ODL.
Change-Id: I9e6b8545166a1f3c747298184461cb49f1c72684 (cherry picked from commit 42357cd33b44b22dbebec8cdecdb29b9d76e5f99)
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run_tests.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 80dce696..fbc43069 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -15,6 +15,8 @@ import time
import yaml
import subprocess
import json
+import requests
+from requests.auth import HTTPBasicAuth
try:
import http.client as client
except ImportError:
@@ -104,15 +106,18 @@ def test_federation():
# return False, "Not able to retrieve ODL token on {}:{} (error code: {}).".format(nhost, "8181", resp.status)
# Retrieve basic auth from ODL
- auth_handler = HTTPBasicAuthHandler()
- auth_handler.add_password(realm='Moon',
- uri='http://{host}:{port}/auth/v1/domains'.format(host=nhost, port=nport),
- user=username,
- passwd=password)
- opener = build_opener(auth_handler)
- install_opener(opener)
- url = urlopen('http://{host}:{port}/auth/v1/domains'.format(host=nhost, port=nport))
- code = url.getcode()
+ # auth_handler = HTTPBasicAuthHandler()
+ # auth_handler.add_password(realm='Moon',
+ # uri='http://{host}:{port}'.format(host=nhost, port=nport),
+ # user=username,
+ # passwd=password)
+ # opener = build_opener(auth_handler)
+ # install_opener(opener)
+ # url = urlopen('http://{host}:{port}/auth/v1/domains'.format(host=nhost, port=nport))
+ # code = url.getcode()
+ auth = HTTPBasicAuth(username, password)
+ req = requests.get(url='http://{host}:{port}/auth/v1/domains'.format(host=nhost, port=nport), auth=auth)
+ code = req.status_code
if code not in (200, 201, 202, 204):
return False, "Not able to authenticate to ODL (error code: {}).".format(code)
return True, ""