From 079a2e0061773a93f747f2c5a3bb6e2373b7d32f Mon Sep 17 00:00:00 2001 From: Leon Stringer Date: Fri, 24 Feb 2023 17:28:05 +0000 Subject: [PATCH] MDL-77322 oauth2: Fix basicauth checkbox Following MDL-61880 you could turn on "Authenticate token requests via HTTP headers" but not turn this off again. This change fixes this and adds a Behat scenario to test toggling this checkbox is saved correctly. --- admin/tool/oauth2/classes/form/issuer.php | 2 +- .../oauth2/tests/behat/basic_settings.feature | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/admin/tool/oauth2/classes/form/issuer.php b/admin/tool/oauth2/classes/form/issuer.php index 902210bc8ae..2a8dd4e08ea 100644 --- a/admin/tool/oauth2/classes/form/issuer.php +++ b/admin/tool/oauth2/classes/form/issuer.php @@ -108,7 +108,7 @@ class issuer extends persistent { $mform->addHelpButton('clientsecret', 'issuerclientsecret', 'tool_oauth2'); // Use basic authentication. - $mform->addElement('checkbox', 'basicauth', get_string('usebasicauth', 'tool_oauth2')); + $mform->addElement('advcheckbox', 'basicauth', get_string('usebasicauth', 'tool_oauth2')); $mform->addHelpButton('basicauth', 'usebasicauth', 'tool_oauth2'); // Base Url. diff --git a/admin/tool/oauth2/tests/behat/basic_settings.feature b/admin/tool/oauth2/tests/behat/basic_settings.feature index 8b4ea4f23c0..53e6ec12b63 100644 --- a/admin/tool/oauth2/tests/behat/basic_settings.feature +++ b/admin/tool/oauth2/tests/behat/basic_settings.feature @@ -362,3 +362,21 @@ Feature: Basic OAuth2 functionality And I navigate to "Server > OAuth 2 services" in site administration And "Allow login" "icon" should exist in the "Empty custom service" "table_row" And "Do not allow services" "icon" should exist in the "Empty custom service" "table_row" + + @javascript + Scenario: Changes to "Authenticate token requests via HTTP headers" are saved + Given I press "Custom" + And I set the following fields to these values: + | Name | Custom service | + | Client ID | thisistheclientid | + | Client secret | supersecret | + And I press "Save changes" + When I click on "Edit" "link" in the "Custom service" "table_row" + And I click on "Authenticate token requests via HTTP headers" "checkbox" + And I press "Save changes" + And I click on "Edit" "link" in the "Custom service" "table_row" + And the field "Authenticate token requests via HTTP headers" matches value "1" + And I click on "Authenticate token requests via HTTP headers" "checkbox" + And I press "Save changes" + And I click on "Edit" "link" in the "Custom service" "table_row" + Then the field "Authenticate token requests via HTTP headers" matches value ""