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.
This commit is contained in:
Leon Stringer 2023-02-24 17:27:05 +00:00
parent a31f5830bd
commit 76b8862518
2 changed files with 19 additions and 1 deletions

View File

@ -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.

View File

@ -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 ""