Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 588 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 mod/quiz/accessrule/seb/tests/test_helper_trait.php

Defines 1 class

access_manager_test:: (35 methods):
  setUp()
  test_access_manager_quizsettings_null()
  test_seb_required_false()
  test_seb_required_true()
  test_user_can_bypass_seb_check()
  test_admin_user_can_bypass_seb_check()
  test_user_cannot_bypass_seb_check()
  test_is_using_seb()
  test_access_keys_validate_with_config_key()
  test_access_keys_validate_with_provided_config_key()
  test_access_keys_fail_to_validate_with_config_key()
  test_config_key_not_checked_if_client_requirement_is_selected()
  test_no_browser_exam_keys_cause_check_to_be_successful()
  test_access_keys_fail_if_browser_exam_key_header_does_not_exist()
  test_access_keys_fail_if_browser_exam_key_header_does_not_match_provided_hash()
  test_browser_exam_keys_match_header_hash()
  test_browser_exam_keys_match_provided_browser_exam_key()
  test_get_received_config_key()
  get_received_browser_exam_key()
  test_get_seb_use_type()
  should_validate_basic_header_data_provider()
  test_should_validate_basic_header()
  should_validate_config_key_data_provider()
  test_should_validate_config_key()
  should_validate_browser_exam_key_data_provider()
  test_should_validate_browser_exam_key()
  test_access_manager_uses_cached_config_key()
  test_valid_config_key_is_null_if_no_settings()
  test_if_config_key_should_not_be_validated()
  test_if_browser_exam_key_should_not_be_validated()
  test_set_session_access()
  test_session_access_set_for_specific_course_module()
  test_validate_session_access()
  test_clear_session_access()
  test_should_redirect_to_seb_config_link()


Class: access_manager_test  - X-Ref

PHPUnit tests for the access manager.

setUp()   X-Ref
Called before every test.


test_access_manager_quizsettings_null()   X-Ref
Test access_manager private property quizsettings is null.


test_seb_required_false()   X-Ref
Test that SEB is not required.


test_seb_required_true()   X-Ref
Test that SEB is required.


test_user_can_bypass_seb_check()   X-Ref
Test that user has capability to bypass SEB check.


test_admin_user_can_bypass_seb_check()   X-Ref
Test that user has capability to bypass SEB check.


test_user_cannot_bypass_seb_check()   X-Ref
Test user does not have capability to bypass SEB check.


test_is_using_seb()   X-Ref
Test we can detect SEB usage.


test_access_keys_validate_with_config_key()   X-Ref
Test that the quiz Config Key matches the incoming request header.


test_access_keys_validate_with_provided_config_key()   X-Ref
Test that the quiz Config Key matches a provided config key with no incoming request header.


test_access_keys_fail_to_validate_with_config_key()   X-Ref
Test that the quiz Config Key does not match the incoming request header.


test_config_key_not_checked_if_client_requirement_is_selected()   X-Ref
Test that config key is not checked when using client configuration with SEB.


test_no_browser_exam_keys_cause_check_to_be_successful()   X-Ref
Test that if there are no browser exam keys for quiz, check is skipped.


test_access_keys_fail_if_browser_exam_key_header_does_not_exist()   X-Ref
Test that access fails if there is no hash in header.


test_access_keys_fail_if_browser_exam_key_header_does_not_match_provided_hash()   X-Ref
Test that access fails if browser exam key doesn't match hash in header.


test_browser_exam_keys_match_header_hash()   X-Ref
Test that browser exam key matches hash in header.


test_browser_exam_keys_match_provided_browser_exam_key()   X-Ref
Test that browser exam key matches a provided browser exam key.


test_get_received_config_key()   X-Ref
Test can get received config key.


get_received_browser_exam_key()   X-Ref
Test can get received browser key.


test_get_seb_use_type()   X-Ref
Test can correctly get type of SEB usage for the quiz.


should_validate_basic_header_data_provider()   X-Ref
Data provider for self::test_should_validate_basic_header.

return: array

test_should_validate_basic_header($type, $expected)   X-Ref
Test we know when we should validate basic header.

param: int $type Type of SEB usage.
param: bool $expected Expected result.

should_validate_config_key_data_provider()   X-Ref
Data provider for self::test_should_validate_config_key.

return: array

test_should_validate_config_key($type, $expected)   X-Ref
Test we know when we should validate config key.

param: int $type Type of SEB usage.
param: bool $expected Expected result.

should_validate_browser_exam_key_data_provider()   X-Ref
Data provider for self::test_should_validate_browser_exam_key.

return: array

test_should_validate_browser_exam_key($type, $expected)   X-Ref
Test we know when we should browser exam key.

param: int $type Type of SEB usage.
param: bool $expected Expected result.

test_access_manager_uses_cached_config_key()   X-Ref
Test that access manager uses cached Config Key.


test_valid_config_key_is_null_if_no_settings()   X-Ref
Check that valid SEB config key is null if quiz doesn't have SEB settings.


test_if_config_key_should_not_be_validated()   X-Ref
Test if config key should not be validated.


test_if_browser_exam_key_should_not_be_validated()   X-Ref
Test if browser exam key should not be validated.


test_set_session_access()   X-Ref
Test that access is set correctly in Moodle session.


test_session_access_set_for_specific_course_module()   X-Ref
Test that access is set in Moodle session for only course module associated with access manager.


test_validate_session_access()   X-Ref
Test that access state can be retrieved from Moodle session.


test_clear_session_access()   X-Ref
Test that access can be cleared from Moodle session.


test_should_redirect_to_seb_config_link()   X-Ref
Test we can decide if need to redirect to SEB config link.