aboutsummaryrefslogtreecommitdiffstats
path: root/keystone-moon/keystone/tests/unit/token
diff options
context:
space:
mode:
Diffstat (limited to 'keystone-moon/keystone/tests/unit/token')
-rw-r--r--keystone-moon/keystone/tests/unit/token/test_fernet_provider.py28
-rw-r--r--keystone-moon/keystone/tests/unit/token/test_pki_provider.py4
-rw-r--r--keystone-moon/keystone/tests/unit/token/test_pkiz_provider.py4
-rw-r--r--keystone-moon/keystone/tests/unit/token/test_token_data_helper.py4
-rw-r--r--keystone-moon/keystone/tests/unit/token/test_token_model.py1
-rw-r--r--keystone-moon/keystone/tests/unit/token/test_uuid_provider.py4
6 files changed, 31 insertions, 14 deletions
diff --git a/keystone-moon/keystone/tests/unit/token/test_fernet_provider.py b/keystone-moon/keystone/tests/unit/token/test_fernet_provider.py
index 4101369c..5f74b430 100644
--- a/keystone-moon/keystone/tests/unit/token/test_fernet_provider.py
+++ b/keystone-moon/keystone/tests/unit/token/test_fernet_provider.py
@@ -10,6 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import base64
import datetime
import hashlib
import os
@@ -20,7 +21,7 @@ from oslo_utils import timeutils
from keystone.common import config
from keystone.common import utils
from keystone import exception
-from keystone.tests import unit as tests
+from keystone.tests import unit
from keystone.tests.unit import ksfixtures
from keystone.token import provider
from keystone.token.providers import fernet
@@ -31,7 +32,7 @@ from keystone.token.providers.fernet import utils as fernet_utils
CONF = config.CONF
-class TestFernetTokenProvider(tests.TestCase):
+class TestFernetTokenProvider(unit.TestCase):
def setUp(self):
super(TestFernetTokenProvider, self).setUp()
self.useFixture(ksfixtures.KeyRepository(self.config_fixture))
@@ -56,7 +57,24 @@ class TestFernetTokenProvider(tests.TestCase):
uuid.uuid4().hex)
-class TestPayloads(tests.TestCase):
+class TestTokenFormatter(unit.TestCase):
+ def test_restore_padding(self):
+ # 'a' will result in '==' padding, 'aa' will result in '=' padding, and
+ # 'aaa' will result in no padding.
+ strings_to_test = ['a', 'aa', 'aaa']
+
+ for string in strings_to_test:
+ encoded_string = base64.urlsafe_b64encode(string)
+ encoded_str_without_padding = encoded_string.rstrip('=')
+ self.assertFalse(encoded_str_without_padding.endswith('='))
+ encoded_str_with_padding_restored = (
+ token_formatters.TokenFormatter.restore_padding(
+ encoded_str_without_padding)
+ )
+ self.assertEqual(encoded_string, encoded_str_with_padding_restored)
+
+
+class TestPayloads(unit.TestCase):
def test_uuid_hex_to_byte_conversions(self):
payload_cls = token_formatters.BasePayload
@@ -387,7 +405,7 @@ class TestPayloads(tests.TestCase):
self.assertDictEqual(exp_federated_info, federated_info)
-class TestFernetKeyRotation(tests.TestCase):
+class TestFernetKeyRotation(unit.TestCase):
def setUp(self):
super(TestFernetKeyRotation, self).setUp()
@@ -512,7 +530,7 @@ class TestFernetKeyRotation(tests.TestCase):
self.assertEqual(3, keys)
-class TestLoadKeys(tests.TestCase):
+class TestLoadKeys(unit.TestCase):
def test_non_numeric_files(self):
self.useFixture(ksfixtures.KeyRepository(self.config_fixture))
evil_file = os.path.join(CONF.fernet_tokens.key_repository, '~1')
diff --git a/keystone-moon/keystone/tests/unit/token/test_pki_provider.py b/keystone-moon/keystone/tests/unit/token/test_pki_provider.py
index dad31266..b3ad4c2b 100644
--- a/keystone-moon/keystone/tests/unit/token/test_pki_provider.py
+++ b/keystone-moon/keystone/tests/unit/token/test_pki_provider.py
@@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from keystone.tests import unit as tests
+from keystone.tests import unit
from keystone.token.providers import pki
-class TestPkiTokenProvider(tests.TestCase):
+class TestPkiTokenProvider(unit.TestCase):
def setUp(self):
super(TestPkiTokenProvider, self).setUp()
self.provider = pki.Provider()
diff --git a/keystone-moon/keystone/tests/unit/token/test_pkiz_provider.py b/keystone-moon/keystone/tests/unit/token/test_pkiz_provider.py
index 4a492bc1..1ffe7cfc 100644
--- a/keystone-moon/keystone/tests/unit/token/test_pkiz_provider.py
+++ b/keystone-moon/keystone/tests/unit/token/test_pkiz_provider.py
@@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from keystone.tests import unit as tests
+from keystone.tests import unit
from keystone.token.providers import pkiz
-class TestPkizTokenProvider(tests.TestCase):
+class TestPkizTokenProvider(unit.TestCase):
def setUp(self):
super(TestPkizTokenProvider, self).setUp()
self.provider = pkiz.Provider()
diff --git a/keystone-moon/keystone/tests/unit/token/test_token_data_helper.py b/keystone-moon/keystone/tests/unit/token/test_token_data_helper.py
index a12a22d4..6114b723 100644
--- a/keystone-moon/keystone/tests/unit/token/test_token_data_helper.py
+++ b/keystone-moon/keystone/tests/unit/token/test_token_data_helper.py
@@ -16,11 +16,11 @@ import uuid
from testtools import matchers
from keystone import exception
-from keystone.tests import unit as tests
+from keystone.tests import unit
from keystone.token.providers import common
-class TestTokenDataHelper(tests.TestCase):
+class TestTokenDataHelper(unit.TestCase):
def setUp(self):
super(TestTokenDataHelper, self).setUp()
self.load_backends()
diff --git a/keystone-moon/keystone/tests/unit/token/test_token_model.py b/keystone-moon/keystone/tests/unit/token/test_token_model.py
index 3959d901..f1398491 100644
--- a/keystone-moon/keystone/tests/unit/token/test_token_model.py
+++ b/keystone-moon/keystone/tests/unit/token/test_token_model.py
@@ -30,7 +30,6 @@ CONF = cfg.CONF
class TestKeystoneTokenModel(core.TestCase):
def setUp(self):
super(TestKeystoneTokenModel, self).setUp()
- self.load_backends()
self.v2_sample_token = copy.deepcopy(
test_token_provider.SAMPLE_V2_TOKEN)
self.v3_sample_token = copy.deepcopy(
diff --git a/keystone-moon/keystone/tests/unit/token/test_uuid_provider.py b/keystone-moon/keystone/tests/unit/token/test_uuid_provider.py
index b49427f0..5c364490 100644
--- a/keystone-moon/keystone/tests/unit/token/test_uuid_provider.py
+++ b/keystone-moon/keystone/tests/unit/token/test_uuid_provider.py
@@ -10,11 +10,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-from keystone.tests import unit as tests
+from keystone.tests import unit
from keystone.token.providers import uuid
-class TestUuidTokenProvider(tests.TestCase):
+class TestUuidTokenProvider(unit.TestCase):
def setUp(self):
super(TestUuidTokenProvider, self).setUp()
self.provider = uuid.Provider()