Update json module to jsonutils
oslo project provide jsonutils, and keystoneclient use it in many place[1], this PS to update the remained json module to oslo jsonutils for consistency. [1]: https://github.com/openstack/python-keystoneclient/search?utf8=%E2%9C%93&q=jsonutils&type= Change-Id: Id5275b5e6b5bf8f6d54406dac7ab95a30828cf58
This commit is contained in:
@@ -12,9 +12,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from keystoneclient.common import cms
|
from keystoneclient.common import cms
|
||||||
from keystoneclient import utils
|
from keystoneclient import utils
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ def generate_revocation_list():
|
|||||||
'id': id,
|
'id': id,
|
||||||
"expires": "2112-08-14T17:58:48Z"
|
"expires": "2112-08-14T17:58:48Z"
|
||||||
})
|
})
|
||||||
revoked_json = json.dumps({"revoked": revoked_list})
|
revoked_json = jsonutils.dumps({"revoked": revoked_list})
|
||||||
with open(make_filename('cms', 'revocation_list.json'), 'w') as f:
|
with open(make_filename('cms', 'revocation_list.json'), 'w') as f:
|
||||||
f.write(revoked_json)
|
f.write(revoked_json)
|
||||||
encoded = cms.pkiz_sign(revoked_json,
|
encoded = cms.pkiz_sign(revoked_json,
|
||||||
@@ -91,12 +92,12 @@ for name in EXAMPLE_TOKENS:
|
|||||||
|
|
||||||
# validate the JSON
|
# validate the JSON
|
||||||
try:
|
try:
|
||||||
token_data = json.loads(string_data)
|
token_data = jsonutils.loads(string_data)
|
||||||
except ValueError as v:
|
except ValueError as v:
|
||||||
raise SystemExit('%s while processing token data from %s: %s' %
|
raise SystemExit('%s while processing token data from %s: %s' %
|
||||||
(v, json_file, string_data))
|
(v, json_file, string_data))
|
||||||
|
|
||||||
text = json.dumps(token_data).encode('utf-8')
|
text = jsonutils.dumps(token_data).encode('utf-8')
|
||||||
|
|
||||||
# Uncomment to record the token uncompressed,
|
# Uncomment to record the token uncompressed,
|
||||||
# useful for debugging
|
# useful for debugging
|
||||||
|
@@ -11,10 +11,10 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from keystoneclient import access
|
from keystoneclient import access
|
||||||
@@ -189,7 +189,7 @@ class Auth(BaseAuth):
|
|||||||
authenticated=False, log=False, **rkwargs)
|
authenticated=False, log=False, **rkwargs)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_logger.debug(json.dumps(resp.json()))
|
_logger.debug(jsonutils.dumps(resp.json()))
|
||||||
resp_data = resp.json()['token']
|
resp_data = resp.json()['token']
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
raise exceptions.InvalidResponse(response=resp)
|
raise exceptions.InvalidResponse(response=resp)
|
||||||
|
@@ -10,9 +10,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from keystoneauth1 import fixture
|
from keystoneauth1 import fixture
|
||||||
|
|
||||||
from keystoneauth1 import session as auth_session
|
from keystoneauth1 import session as auth_session
|
||||||
@@ -75,10 +76,10 @@ class KeystoneClientTest(utils.TestCase):
|
|||||||
password='password',
|
password='password',
|
||||||
project_name='exampleproject',
|
project_name='exampleproject',
|
||||||
auth_url=self.TEST_URL)
|
auth_url=self.TEST_URL)
|
||||||
cache = json.dumps(cl.auth_ref)
|
cache = jsonutils.dumps(cl.auth_ref)
|
||||||
# Creating a HTTPClient not using session is deprecated.
|
# Creating a HTTPClient not using session is deprecated.
|
||||||
with self.deprecations.expect_deprecations_here():
|
with self.deprecations.expect_deprecations_here():
|
||||||
new_client = client.Client(auth_ref=json.loads(cache))
|
new_client = client.Client(auth_ref=jsonutils.loads(cache))
|
||||||
self.assertIsNotNone(new_client.auth_ref)
|
self.assertIsNotNone(new_client.auth_ref)
|
||||||
with self.deprecations.expect_deprecations_here():
|
with self.deprecations.expect_deprecations_here():
|
||||||
self.assertTrue(new_client.auth_ref.scoped)
|
self.assertTrue(new_client.auth_ref.scoped)
|
||||||
@@ -100,11 +101,11 @@ class KeystoneClientTest(utils.TestCase):
|
|||||||
password='password',
|
password='password',
|
||||||
project_name='exampleproject',
|
project_name='exampleproject',
|
||||||
auth_url=self.TEST_URL)
|
auth_url=self.TEST_URL)
|
||||||
cache = json.dumps(cl.auth_ref)
|
cache = jsonutils.dumps(cl.auth_ref)
|
||||||
new_auth_url = "http://new-public:5000/v2.0"
|
new_auth_url = "http://new-public:5000/v2.0"
|
||||||
# Creating a HTTPClient not using session is deprecated.
|
# Creating a HTTPClient not using session is deprecated.
|
||||||
with self.deprecations.expect_deprecations_here():
|
with self.deprecations.expect_deprecations_here():
|
||||||
new_client = client.Client(auth_ref=json.loads(cache),
|
new_client = client.Client(auth_ref=jsonutils.loads(cache),
|
||||||
auth_url=new_auth_url)
|
auth_url=new_auth_url)
|
||||||
self.assertIsNotNone(new_client.auth_ref)
|
self.assertIsNotNone(new_client.auth_ref)
|
||||||
with self.deprecations.expect_deprecations_here():
|
with self.deprecations.expect_deprecations_here():
|
||||||
|
@@ -11,9 +11,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import json
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from keystoneauth1 import session as auth_session
|
from keystoneauth1 import session as auth_session
|
||||||
from keystoneclient.auth import token_endpoint
|
from keystoneclient.auth import token_endpoint
|
||||||
@@ -90,10 +90,10 @@ class KeystoneClientTest(utils.TestCase):
|
|||||||
password='password',
|
password='password',
|
||||||
project_id=token.project_id,
|
project_id=token.project_id,
|
||||||
auth_url=self.TEST_URL)
|
auth_url=self.TEST_URL)
|
||||||
cache = json.dumps(c.auth_ref)
|
cache = jsonutils.dumps(c.auth_ref)
|
||||||
# Creating a HTTPClient not using session is deprecated.
|
# Creating a HTTPClient not using session is deprecated.
|
||||||
with self.deprecations.expect_deprecations_here():
|
with self.deprecations.expect_deprecations_here():
|
||||||
new_client = client.Client(auth_ref=json.loads(cache))
|
new_client = client.Client(auth_ref=jsonutils.loads(cache))
|
||||||
self.assertIsNotNone(new_client.auth_ref)
|
self.assertIsNotNone(new_client.auth_ref)
|
||||||
self.assertFalse(new_client.auth_ref.domain_scoped)
|
self.assertFalse(new_client.auth_ref.domain_scoped)
|
||||||
self.assertTrue(new_client.auth_ref.project_scoped)
|
self.assertTrue(new_client.auth_ref.project_scoped)
|
||||||
@@ -124,10 +124,10 @@ class KeystoneClientTest(utils.TestCase):
|
|||||||
password='password',
|
password='password',
|
||||||
project_id=project_id,
|
project_id=project_id,
|
||||||
auth_url=self.TEST_URL)
|
auth_url=self.TEST_URL)
|
||||||
cache = json.dumps(c.auth_ref)
|
cache = jsonutils.dumps(c.auth_ref)
|
||||||
# Creating a HTTPClient not using session is deprecated.
|
# Creating a HTTPClient not using session is deprecated.
|
||||||
with self.deprecations.expect_deprecations_here():
|
with self.deprecations.expect_deprecations_here():
|
||||||
new_client = client.Client(auth_ref=json.loads(cache),
|
new_client = client.Client(auth_ref=jsonutils.loads(cache),
|
||||||
auth_url=new_auth_url)
|
auth_url=new_auth_url)
|
||||||
self.assertIsNotNone(new_client.auth_ref)
|
self.assertIsNotNone(new_client.auth_ref)
|
||||||
self.assertFalse(new_client.auth_ref.domain_scoped)
|
self.assertFalse(new_client.auth_ref.domain_scoped)
|
||||||
|
Reference in New Issue
Block a user