Use jsonutils instead of ast for loading the service catalog
AST! Never AST! The service catalog set from auth_token middleware is a json blob not a python blob and should be decoded as such. This brings up the problem that the service catalog specified in the tests is not actually valid JSON. In future I'll attempt to change this over to using the auth_token fixture instead of a custom environment dictionary. Change-Id: Ic9ab68f7d41d19d3595a3ddbbb2e233f57ef52c8
This commit is contained in:
parent
29709a4aaf
commit
0d1fc6c81f
|
@ -10,11 +10,11 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import ast
|
||||
import collections
|
||||
import logging
|
||||
import re
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from pycadf import cadftaxonomy as taxonomy
|
||||
from pycadf import cadftype
|
||||
from pycadf import credential
|
||||
|
@ -251,8 +251,7 @@ class OpenStackAuditApi(object):
|
|||
|
||||
catalog = {}
|
||||
try:
|
||||
catalog = ast.literal_eval(
|
||||
req.environ['HTTP_X_SERVICE_CATALOG'])
|
||||
catalog = jsonutils.loads(req.environ['HTTP_X_SERVICE_CATALOG'])
|
||||
except KeyError:
|
||||
msg = _LW('Unable to discover target information because '
|
||||
'service catalog is missing. Either the incoming '
|
||||
|
|
|
@ -82,8 +82,8 @@ class BaseAuditMiddlewareTest(utils.BaseTestCase):
|
|||
"internalURL":
|
||||
"http://internal_host:8774",
|
||||
"id": "resource_id"}],
|
||||
"type": "compute",
|
||||
"name": "nova"},]''',
|
||||
"type": "compute",
|
||||
"name": "nova"}]''',
|
||||
'HTTP_X_USER_ID': 'user_id',
|
||||
'HTTP_X_USER_NAME': 'user_name',
|
||||
'HTTP_X_AUTH_TOKEN': 'token',
|
||||
|
|
|
@ -225,8 +225,8 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
|
|||
"http://public_host:8774",
|
||||
"internalURL":
|
||||
"http://internal_host:8774"}],
|
||||
"type": "compute",
|
||||
"name": "nova"},]''',
|
||||
"type": "compute",
|
||||
"name": "nova"}]''',
|
||||
'HTTP_X_USER_ID': 'user_id',
|
||||
'HTTP_X_USER_NAME': 'user_name',
|
||||
'HTTP_X_AUTH_TOKEN': 'token',
|
||||
|
@ -246,8 +246,8 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
|
|||
"region": "RegionOne",
|
||||
"publicURL":
|
||||
"http://public_host:8774"}],
|
||||
"type": "compute",
|
||||
"name": "nova"},]''',
|
||||
"type": "compute",
|
||||
"name": "nova"}]''',
|
||||
'HTTP_X_USER_ID': 'user_id',
|
||||
'HTTP_X_USER_NAME': 'user_name',
|
||||
'HTTP_X_AUTH_TOKEN': 'token',
|
||||
|
@ -267,8 +267,8 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
|
|||
"region": "RegionOne",
|
||||
"internalURL":
|
||||
"http://internal_host:8774"}],
|
||||
"type": "compute",
|
||||
"name": "nova"},]''',
|
||||
"type": "compute",
|
||||
"name": "nova"}]''',
|
||||
'HTTP_X_USER_ID': 'user_id',
|
||||
'HTTP_X_USER_NAME': 'user_name',
|
||||
'HTTP_X_AUTH_TOKEN': 'token',
|
||||
|
@ -288,8 +288,8 @@ class AuditApiLogicTest(base.BaseAuditMiddlewareTest):
|
|||
"http://public_host:8774",
|
||||
"internalURL":
|
||||
"http://internal_host:8774"}],
|
||||
"type": "compute",
|
||||
"name": "nova"},]''',
|
||||
"type": "compute",
|
||||
"name": "nova"}]''',
|
||||
'HTTP_X_USER_ID': 'user_id',
|
||||
'HTTP_X_USER_NAME': 'user_name',
|
||||
'HTTP_X_AUTH_TOKEN': 'token',
|
||||
|
|
Loading…
Reference in New Issue