Replace old functional http.post call
The patch removes a leftover of the old http helper functions and moves the check of self.conf.auth to the setUp method. Change-Id: Ie5cf3c7cfbf5dc80e9a1faf6556588d3b2284bb7
This commit is contained in:
parent
496e6ddd70
commit
362b6ffc45
@ -54,13 +54,18 @@ class FunctionalTestBase(testing.TestBase):
|
||||
self.mconf = self.load_conf(self.cfg.marconi.config).conf
|
||||
self.limits = self.mconf['limits:transport']
|
||||
|
||||
self.header = helpers.create_marconi_headers(self.cfg)
|
||||
self.headers_response_with_body = set(['location',
|
||||
'content-type'])
|
||||
|
||||
# NOTE(flaper87): Create client
|
||||
# for this test unit.
|
||||
self.client = http.Client()
|
||||
self.header = helpers.create_marconi_headers(self.cfg)
|
||||
|
||||
if self.cfg.auth.auth_on:
|
||||
auth_token = helpers.get_keystone_token(self.cfg, self.client)
|
||||
self.headers["X-Auth-Token"] = auth_token
|
||||
|
||||
self.headers_response_with_body = set(['location',
|
||||
'content-type'])
|
||||
|
||||
self.client.set_headers(self.header)
|
||||
|
||||
@classmethod
|
||||
|
@ -13,17 +13,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import random
|
||||
import string
|
||||
import uuid
|
||||
|
||||
from marconi.tests.functional import http
|
||||
|
||||
|
||||
def get_keystone_token(conf):
|
||||
def get_keystone_token(conf, client):
|
||||
"""Gets Keystone Auth token."""
|
||||
req_json = {
|
||||
body = {
|
||||
'auth': {
|
||||
'passwordCredentials': {
|
||||
'username': conf.auth.username,
|
||||
@ -35,14 +32,12 @@ def get_keystone_token(conf):
|
||||
header = {"Content-Type": "application/json",
|
||||
"Accept": "application/json"}
|
||||
|
||||
url = conf.auth.url
|
||||
response = client.post(url=conf.auth.url,
|
||||
headers=header,
|
||||
data=body)
|
||||
|
||||
response = http.post(url=url, header=header, body=req_json)
|
||||
response_body = json.loads(response.text)
|
||||
|
||||
auth_token = response_body['access']['token']['id']
|
||||
|
||||
return auth_token
|
||||
response_body = response.json()
|
||||
return response_body['access']['token']['id']
|
||||
|
||||
|
||||
def create_marconi_headers(conf):
|
||||
@ -55,10 +50,6 @@ def create_marconi_headers(conf):
|
||||
"Client-ID": str(uuid.uuid1())
|
||||
}
|
||||
|
||||
if conf.auth.auth_on:
|
||||
auth_token = get_keystone_token(conf)
|
||||
headers["X-Auth-Token"] = auth_token
|
||||
|
||||
return headers
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user