management.tests.test_models.test_pkcs11tokenΒΆ

Tests for PKCS11Token model methods.

ClassesΒΆ

PKCS11TokenTestCase

Similar to TransactionTestCase, but use transaction.atomic() to achieve

Module ContentsΒΆ

class management.tests.test_models.test_pkcs11token.PKCS11TokenTestCase(methodName='runTest')[source]ΒΆ

Bases: django.test.TestCase

Similar to TransactionTestCase, but use transaction.atomic() to achieve test isolation.

In most situations, TestCase should be preferred to TransactionTestCase as it allows faster execution. However, there are some situations where using TransactionTestCase might be necessary (e.g. testing some transactional behavior).

On database backends with no transaction support, TestCase behaves as TransactionTestCase.

setUp()[source]ΒΆ

Set up a PKCS11Token instance for testing.

tearDown()[source]ΒΆ

Clear the cache after each test.

test_generate_kek(mock_pkcs11_lib, mock_get_pin)[source]ΒΆ

Test KEK generation.

test_wrap_dek(mock_pkcs11_lib, mock_get_pin)[source]ΒΆ

Test wrapping a DEK.

test_get_dek_cache_hit(mock_pkcs11_lib)[source]ΒΆ

Test retrieving DEK from cache.

test_get_dek_cache_miss(mock_pkcs11_lib, mock_get_pin)[source]ΒΆ

Test retrieving DEK when cache is empty.

test_get_pin_from_env()[source]ΒΆ

Test retrieving PIN from environment variable.

test_get_pin_from_file(mock_open, mock_access, mock_exists)[source]ΒΆ

Test retrieving PIN from a file.

test_get_pin_no_pin()[source]ΒΆ

Test error when no PIN is configured.

test_set_backup_password(mock_encrypt, mock_derive, mock_unwrap, mock_generate)[source]ΒΆ

Test setting a backup password.

test_verify_backup_password()[source]ΒΆ

Test verifying a backup password.

test_remove_backup_encryption()[source]ΒΆ

Test removing backup encryption.

test_has_backup_encryption()[source]ΒΆ

Test checking if backup encryption exists.