Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 403]

Test encryption.

Copyright: 2020 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 265 lines (9 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

require_sodium(string $method)   X-Ref
Tests using Sodium need to check the extension is available.

param: string $method Encryption method

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_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_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_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