Fix the bug of py27

Change-Id: I7f8dce7dd86bb64cda4b161825636aaf709bdd27
This commit is contained in:
pengyuesheng 2019-04-19 11:28:47 +08:00
parent ff824514c2
commit 0540951901
2 changed files with 22 additions and 17 deletions

View File

@ -26,7 +26,7 @@ from castellan.common.objects import x_509
from castellan import key_manager as key_manager_api
from horizon import exceptions
from horizon.utils.memoized import memoized_with_request
from horizon.utils.memoized import memoized
LOG = logging.getLogger(__name__)
@ -50,9 +50,9 @@ def get_auth_params_from_request(request):
)
@memoized_with_request(get_auth_params_from_request)
def get_context(request_auth_params):
token_id, tenant_id = request_auth_params
@memoized
def get_context(request):
token_id, tenant_id = get_auth_params_from_request(request)
return context.RequestContext(auth_token=token_id,
tenant=tenant_id)

View File

@ -10,22 +10,27 @@
# License for the specific language governing permissions and limitations
# under the License.
from castellan.common import objects
from castellan.common.objects import opaque_data as op_data
from castellan.common.objects import passphrase as passp
from castellan.common.objects import private_key as pri_key
from castellan.common.objects import public_key as pub_key
from castellan.common.objects import symmetric_key as sym_key
from castellan.common.objects import x_509
from castellan.tests import utils as castellan_utils
x509_cert = objects.x_509.X509(
x509_cert = x_509.X509(
data=castellan_utils.get_certificate_der(),
name='test cert',
created=1448088699,
id=u'00000000-0000-0000-0000-000000000000')
nameless_x509_cert = objects.x_509.X509(
nameless_x509_cert = x_509.X509(
data=castellan_utils.get_certificate_der(),
name=None,
created=1448088699,
id=u'11111111-1111-1111-1111-111111111111')
private_key = objects.private_key.PrivateKey(
private_key = pri_key.PrivateKey(
key=castellan_utils.get_private_key_der(),
algorithm="RSA",
bit_length=2048,
@ -33,7 +38,7 @@ private_key = objects.private_key.PrivateKey(
created=1448088699,
id=u'00000000-0000-0000-0000-000000000000')
nameless_private_key = objects.private_key.PrivateKey(
nameless_private_key = pri_key.PrivateKey(
key=castellan_utils.get_private_key_der(),
algorithm="RSA",
bit_length=2048,
@ -41,7 +46,7 @@ nameless_private_key = objects.private_key.PrivateKey(
created=1448088699,
id=u'11111111-1111-1111-1111-111111111111')
public_key = objects.public_key.PublicKey(
public_key = pub_key.PublicKey(
key=castellan_utils.get_public_key_der(),
algorithm="RSA",
bit_length=2048,
@ -49,7 +54,7 @@ public_key = objects.public_key.PublicKey(
created=1448088699,
id=u'00000000-0000-0000-0000-000000000000')
nameless_public_key = objects.public_key.PublicKey(
nameless_public_key = pub_key.PublicKey(
key=castellan_utils.get_public_key_der(),
algorithm="RSA",
bit_length=2048,
@ -57,7 +62,7 @@ nameless_public_key = objects.public_key.PublicKey(
created=1448088699,
id=u'11111111-1111-1111-1111-111111111111')
symmetric_key = objects.symmetric_key.SymmetricKey(
symmetric_key = sym_key.SymmetricKey(
key=castellan_utils.get_symmetric_key(),
algorithm="AES",
bit_length=128,
@ -65,7 +70,7 @@ symmetric_key = objects.symmetric_key.SymmetricKey(
created=1448088699,
id=u'00000000-0000-0000-0000-000000000000')
nameless_symmetric_key = objects.symmetric_key.SymmetricKey(
nameless_symmetric_key = sym_key.SymmetricKey(
key=castellan_utils.get_symmetric_key(),
algorithm="AES",
bit_length=128,
@ -73,25 +78,25 @@ nameless_symmetric_key = objects.symmetric_key.SymmetricKey(
created=1448088699,
id=u'11111111-1111-1111-1111-111111111111')
opaque_data = objects.opaque_data.OpaqueData(
opaque_data = op_data.OpaqueData(
data=b'\xde\xad\xbe\xef',
name=u'test opaque data',
created=1448088699,
id=u'00000000-0000-0000-0000-000000000000')
nameless_opaque_data = objects.opaque_data.OpaqueData(
nameless_opaque_data = op_data.OpaqueData(
data=b'\xde\xad\xbe\xef',
name=None,
created=1448088699,
id=u'11111111-1111-1111-1111-111111111111')
passphrase = objects.passphrase.Passphrase(
passphrase = passp.Passphrase(
passphrase=u'P@ssw0rd',
name=u'test passphrase',
created=1448088699,
id=u'00000000-0000-0000-0000-000000000000')
nameless_passphrase = objects.passphrase.Passphrase(
nameless_passphrase = passp.Passphrase(
passphrase=u'P@ssw0rd',
name=None,
created=1448088699,