| 1 |
# SPDX-License-Identifier: MPL-2.0 |
| 2 |
|
| 3 |
import unittest |
| 4 |
|
| 5 |
|
| 6 |
from cryptodatahub.common.algorithm import Authentication, MAC, Signature |
| 7 |
from cryptodatahub.common.exception import InvalidValue |
| 8 |
|
| 9 |
|
| 10 |
class TestAlgortihmOIDBase(unittest.TestCase): |
| 11 |
def test_error_not_found(self): |
| 12 |
with self.assertRaisesRegex(InvalidValue, '\'1.2.3.4.5.6.7.8\' is not a valid Authentication oid value'): |
| 13 |
Authentication.from_oid('1.2.3.4.5.6.7.8') |
| 14 |
|
| 15 |
def test_from_oid(self): |
| 16 |
self.assertEqual( |
| 17 |
Authentication.from_oid(Authentication.RSA.value.oid), |
| 18 |
Authentication.RSA |
| 19 |
) |
| 20 |
|
| 21 |
|
| 22 |
class TestAlgortihmParam(unittest.TestCase): |
| 23 |
def test_str(self): |
| 24 |
self.assertEqual(str(Signature.RSA_WITH_SHA2_224.value), 'SHA-224 with RSA Encryption') |
| 25 |
|
| 26 |
|
| 27 |
class TestMAC(unittest.TestCase): |
| 28 |
def test_digest_size(self): |
| 29 |
self.assertEqual(MAC.SHA2_256.value.digest_size, 256) |
| 30 |
self.assertEqual(MAC.POLY1305.value.digest_size, 128) |