Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix php warning in AuthTokenMiddleware #506

Merged
merged 4 commits into from
Dec 14, 2023
Merged

Conversation

bshaffer
Copy link
Contributor

@bshaffer bshaffer commented Dec 13, 2023

A PHP warning was introduced in #492 where we didn't check if one of the values of the array was set.

$ vendor/bin/phpunit tests/Middleware/AuthTokenMiddlewareTest.php --filter testDoesNotAddAnAuthorizationHeaderOnNoAccessToken
PHPUnit 9.6.13 by Sebastian Bergmann and contributors.

PHP Warning:  Undefined array key "id_token" in src/Middleware/AuthTokenMiddleware.php on line 135
.                                                                   1 / 1 (100%)
Warning: Undefined array key "id_token" in src/Middleware/AuthTokenMiddleware.php on line 135


Time: 00:00.012, Memory: 8.00 MB

OK (1 test, 1 assertion)

This is not too concerning, since PHP will cast this to an empty string, but we should get rid of the warning by explicitly using an empty string when neither token types are set.

Also, we set convertWarningsToExceptions="true" and convertWarningsToExceptions="true", where they were previously false. This will ensure warnings like this fail our tests, so they don't happen again.

@bshaffer bshaffer requested a review from yash30201 December 13, 2023 19:53
@bshaffer bshaffer requested a review from a team as a code owner December 13, 2023 19:53
@bshaffer bshaffer changed the title fix: php warning in AuthTokenMiddleware chore: fix php warning in AuthTokenMiddleware Dec 14, 2023
Copy link
Contributor

@yash30201 yash30201 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm.

Thanks for fixing this warning Brent!

@bshaffer bshaffer enabled auto-merge (squash) December 14, 2023 16:10
@bshaffer bshaffer merged commit 0c563b5 into main Dec 14, 2023
12 checks passed
@bshaffer bshaffer deleted the fix-php-warning branch December 14, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants