Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 311 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

(no description)

File Size: 271 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 lib/tests/fixtures/testable_encryption.php

Defines 1 class


Class: encryption_test  - X-Ref

Test encryption.

tearDown()   X-Ref
Clear junk created by tests.


setUp()   X-Ref
No description

encryption_method_provider()   X-Ref
Many of the tests work with both encryption methods.

return: array[] Array of method options for test

test_create_key(string $method)   X-Ref
Tests the create_keys and get_key functions.

param: string $method Encryption method

test_create_key_openssl()   X-Ref
Test that we can create keys for legacy {@see encryption::METHOD_OPENSSL} content


test_encrypt_and_decrypt_empty()   X-Ref
Tests encryption and decryption with empty strings.


test_encrypt_nokeys(string $method)   X-Ref
Tests encryption when the keys weren't created yet.

param: string $method Encryption method

test_encrypt_openssl()   X-Ref
Test that attempting to encrypt with legacy {@see encryption::METHOD_OPENSSL} method falls back to Sodium


test_decrypt_wrongmethod()   X-Ref
Tests decryption when the data has a different encryption method


test_decrypt_tooshort(string $method)   X-Ref
Tests decryption when not enough data is supplied to get the IV and some data.

param: string $method Encryption method

test_decrypt_notbase64(string $method)   X-Ref
Tests decryption when data is not valid base64.

param: string $method Encryption method

test_decrypt_nokeys(string $method)   X-Ref
Tests decryption when the keys weren't created yet.

param: string $method Encryption method

test_decrypt_openssl()   X-Ref
Test that we can decrypt legacy {@see encryption::METHOD_OPENSSL} content


test_auto_key_generation(string $method)   X-Ref
Test automatic generation of keys when needed.

param: string $method Encryption method

test_invalid_key(string $method)   X-Ref
Checks that invalid key causes failures.

param: string $method Encryption method

test_modified_data(string $method)   X-Ref
Checks that modified data causes failures.

param: string $method Encryption method

test_encrypt_and_decrypt_realdata(string $method)   X-Ref
Tests encryption and decryption for real.

param: string $method Encryption method