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.mconf = self.load_conf(self.cfg.marconi.config).conf
|
||||||
self.limits = self.mconf['limits:transport']
|
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
|
# NOTE(flaper87): Create client
|
||||||
# for this test unit.
|
# for this test unit.
|
||||||
self.client = http.Client()
|
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)
|
self.client.set_headers(self.header)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -13,17 +13,14 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from marconi.tests.functional import http
|
|
||||||
|
|
||||||
|
def get_keystone_token(conf, client):
|
||||||
def get_keystone_token(conf):
|
|
||||||
"""Gets Keystone Auth token."""
|
"""Gets Keystone Auth token."""
|
||||||
req_json = {
|
body = {
|
||||||
'auth': {
|
'auth': {
|
||||||
'passwordCredentials': {
|
'passwordCredentials': {
|
||||||
'username': conf.auth.username,
|
'username': conf.auth.username,
|
||||||
@ -35,14 +32,12 @@ def get_keystone_token(conf):
|
|||||||
header = {"Content-Type": "application/json",
|
header = {"Content-Type": "application/json",
|
||||||
"Accept": "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 = response.json()
|
||||||
response_body = json.loads(response.text)
|
return response_body['access']['token']['id']
|
||||||
|
|
||||||
auth_token = response_body['access']['token']['id']
|
|
||||||
|
|
||||||
return auth_token
|
|
||||||
|
|
||||||
|
|
||||||
def create_marconi_headers(conf):
|
def create_marconi_headers(conf):
|
||||||
@ -55,10 +50,6 @@ def create_marconi_headers(conf):
|
|||||||
"Client-ID": str(uuid.uuid1())
|
"Client-ID": str(uuid.uuid1())
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.auth.auth_on:
|
|
||||||
auth_token = get_keystone_token(conf)
|
|
||||||
headers["X-Auth-Token"] = auth_token
|
|
||||||
|
|
||||||
return headers
|
return headers
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user