Merge "Fix typo of ANS1 to ASN1"

This commit is contained in:
Jenkins 2014-04-15 19:40:39 +00:00 committed by Gerrit Code Review
commit ca88561b09
3 changed files with 17 additions and 10 deletions
keystoneclient
common
middleware
tests

@ -29,7 +29,7 @@ from keystoneclient import exceptions
subprocess = None
LOG = logging.getLogger(__name__)
PKI_ANS1_PREFIX = 'MII'
PKI_ASN1_PREFIX = 'MII'
def _ensure_subprocess():
@ -166,7 +166,7 @@ def verify_token(token, signing_cert_file_name, ca_file_name):
ca_file_name)
def is_ans1_token(token):
def is_asn1_token(token):
"""Determine if a token appears to be PKI-based.
thx to ayoung for sorting this out.
@ -213,7 +213,14 @@ def is_ans1_token(token):
It's not practical to support a token of this length or greater in http
therefore, we will check for MII only and ignore the case of larger tokens
"""
return token[:3] == PKI_ANS1_PREFIX
return token[:3] == PKI_ASN1_PREFIX
def is_ans1_token(token):
"""Deprecated. Use is_asn1_token() instead."""
LOG.warning("The function is_ans1_token() is deprecated, "
"use is_asn1_token() instead.")
return is_asn1_token(token)
def cms_sign_text(text, signing_cert_file_name, signing_key_file_name):
@ -264,12 +271,12 @@ def cms_to_token(cms_text):
def cms_hash_token(token_id, mode='md5'):
"""Hash PKI tokens.
return: for ans1_token, returns the hash of the passed in token
return: for asn1_token, returns the hash of the passed in token
otherwise, returns what it was passed in.
"""
if token_id is None:
return None
if is_ans1_token(token_id):
if is_asn1_token(token_id):
hasher = hashlib.new(mode)
if isinstance(token_id, six.text_type):
token_id = token_id.encode('utf-8')

@ -847,7 +847,7 @@ class AuthProtocol(object):
cached = self._cache_get(token_id)
if cached:
return cached
if cms.is_ans1_token(user_token):
if cms.is_asn1_token(user_token):
verified = self.verify_signed_token(user_token)
data = jsonutils.loads(verified)
else:

@ -48,9 +48,9 @@ class CMSTest(utils.TestCase, testresources.ResourcedTestCase):
self.examples.SIGNED_TOKEN_SCOPED))
self.assertEqual(tok, self.examples.SIGNED_TOKEN_SCOPED)
def test_ans1_token(self):
self.assertTrue(cms.is_ans1_token(self.examples.SIGNED_TOKEN_SCOPED))
self.assertFalse(cms.is_ans1_token('FOOBAR'))
def test_asn1_token(self):
self.assertTrue(cms.is_asn1_token(self.examples.SIGNED_TOKEN_SCOPED))
self.assertFalse(cms.is_asn1_token('FOOBAR'))
def test_cms_sign_token_no_files(self):
self.assertRaises(subprocess.CalledProcessError,
@ -119,7 +119,7 @@ class CMSTest(utils.TestCase, testresources.ResourcedTestCase):
def test_cms_hash_token_not_pki(self):
"""If the token_id is not a PKI token then it returns the token_id."""
token = 'something'
self.assertFalse(cms.is_ans1_token(token))
self.assertFalse(cms.is_asn1_token(token))
self.assertThat(cms.cms_hash_token(token), matchers.Is(token))
def test_cms_hash_token_default_md5(self):