Skip to content

Commit

Permalink
Fix Moodle plugin CI errors in auth_oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
patmr7 committed Oct 25, 2024
1 parent 03a0f85 commit a63ccef
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions auth/oidc/classes/form/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ protected function definition() {
/**
* Additional validate rules.
*
* @param $data
* @param $files
* @return array
* @param array $data Submitted data for validation.
* @param array $files Uploaded files for validation.
* @return array An array of validation errors, if any.
*/
public function validation($data, $files) {
$errors = parent::validation($data, $files);
Expand Down
2 changes: 1 addition & 1 deletion auth/oidc/classes/loginflow/authcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ protected function handlemigration($oidcuniqid, $authparams, $tokenparams, $idto
/**
* Determines whether the given Microsoft Entra ID UPN is already matched to a Moodle user (and has not been completed).
*
* @param $entraidupn
* @param string $entraidupn The Microsoft Entra ID UPN to check for a match.
* @return false|stdClass Either the matched Moodle user record, or false if not matched.
*/
protected function check_for_matched($entraidupn) {
Expand Down
18 changes: 9 additions & 9 deletions auth/oidc/classes/loginflow/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public function user_login($username, $password = null) {
/**
* Provides a hook into the login page.
*
* @param object &$frm Form object.
* @param object &$user User object.
* @return bool
* @param object $frm The form object containing login page data.
* @param object $user The user object related to the login attempt.
* @return bool True if the hook was processed successfully.
*/
public function loginpage_hook(&$frm, &$user) {
return true;
Expand Down Expand Up @@ -350,12 +350,12 @@ public function set_httpclient(\auth_oidc\httpclientinterface $httpclient) {
/**
* Handle OIDC disconnection from Moodle account.
*
* @param bool $justremovetokens If true, just remove the stored OIDC tokens for the user, otherwise revert login methods.
* @param bool $donotremovetokens If true, do not remove tokens when disconnecting. This migrates from a login account to a
* "linked" account.
* @param \moodle_url|null $redirect Where to redirect if successful.
* @param \moodle_url|null $selfurl The page this is accessed from. Used for some redirects.
* @param $userid
* @param bool $justremovetokens If true, just remove the stored OIDC tokens for the user; otherwise, revert login methods.
* @param bool $donotremovetokens If true, do not remove tokens when disconnecting. This migrates from a login account
* to a "linked" account.
* @param \moodle_url|null $redirect URL to redirect to if successful.
* @param \moodle_url|null $selfurl The page this is accessed from, used for some redirects.
* @param int|null $userid ID of the user to disconnect; uses the current user if not provided.
*/
public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\moodle_url $redirect = null,
?\moodle_url $selfurl = null, $userid = null) {
Expand Down
7 changes: 4 additions & 3 deletions auth/oidc/classes/oidcclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ public function setendpoints($endpoints) {
}

/**
* Validate the return the endpoint.
* @param $endpoint
* @return mixed|null
* Validate and return the specified endpoint.
*
* @param string $endpoint The endpoint key to retrieve.
* @return mixed|null The endpoint URL if available, otherwise null.
*/
public function get_endpoint($endpoint) {
return (isset($this->endpoints[$endpoint])) ? $this->endpoints[$endpoint] : null;
Expand Down
1 change: 1 addition & 0 deletions auth/oidc/classes/tests/mockoidcclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class mockoidcclient extends \auth_oidc\oidcclient {
* @param bool $promptlogin Whether to prompt for login or use existing session.
* @param array $stateparams Parameters to store as state.
* @param array $extraparams Additional parameters to send with the OIDC request.
* @param bool $selectaccount Whether to prompt the user to select an account.
* @return array Array of request parameters.
*/
public function getauthrequestparams(
Expand Down
3 changes: 2 additions & 1 deletion auth/oidc/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ function auth_oidc_get_all_user_fields() {
/**
* Determine the endpoint version of the given Microsoft Entra ID / Microsoft authorization or token endpoint.
*
* @return int
* @param string $endpoint The URL of the endpoint to be checked.
* @return int The version of the Microsoft endpoint (1 or 2) or unknown.
*/
function auth_oidc_determine_endpoint_version(string $endpoint) {
$endpointversion = AUTH_OIDC_MICROSOFT_ENDPOINT_VERSION_UNKNOWN;
Expand Down
5 changes: 5 additions & 0 deletions auth/oidc/tests/jwt_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public static function dataprovider_decode(): array {
*
* @dataProvider dataprovider_decode
* @covers \auth_oidc\jwt::decode
*
* @param string $encodedjwt The JWT token to be decoded.
* @param mixed $expectedresult The expected result after decoding.
* @param array $expectedexception The expected exception class and message if an error occurs.
* @return void
*/
public function test_decode($encodedjwt, $expectedresult, $expectedexception): void {
if (!empty($expectedexception)) {
Expand Down

0 comments on commit a63ccef

Please sign in to comment.