-
Notifications
You must be signed in to change notification settings - Fork 10
"view as user" test, rework uses of die()
#212
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Apr 29, 2025
simonLeary42
added a commit
that referenced
this pull request
Apr 30, 2025
* replace die with exception * use if/then instead of die * set unique session cache location for each phpunit run * viewAsUser test * UnitySite not static * remove pointless file * ajax php don't initialize entire stack * every switchUser has a fresh session by default * get post always discard output * Revert "UnitySite not static" This reverts commit 01e7581. * add UnitySite::die * Revert "replace die with exception" This reverts commit fa5d021. * add functions errorLog, badRequest * update ViewAsUserTest * get test working * add exceptions * delete comments * unused import * rename post to http_post, get to http_get * fix die * add pre commit check for usage of die * no color in die checker * dont print to stderr * ignore phpunit result cache * don't allow exit() either * refactor * show both die and exit * get -> http_get * revert conditional * revert conditional 2 * add message * remove unused exception class * exclude UnitySite from die check * use unauthorized function, don't print anything to use * allow empty die(), rename unauthorized to forbidden * don't explode trace * remove broken magic response code reason * httpResponseCode private * more tests * allow undefined server protocol * more tests * clear view before redirect nonexistent user * remove comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
die
: does the same thing unless phpunit is running in which case it throws a special exceptionerrorLog
: writes to error log including logged in user, IP address, and backtracebadRequest
: sends HTTP header 400, writes to error log, and diesforbidden
: sends HTTP header 403, writes to error log, and diesdie()
in authorization checks withUnitySite::forbidden
die()
in bad request checks withUnitySite::badRequest
admin/user-mgmt.php -> panel/ -> panel/index.php -> panel/account.php
with a direct linkadmin/user-mgmt.php
->panel/account.php
clearView
logic inheader.php
up to the top before nonexistent users are redirected tonew_account.php
, this allows an admin toviewUser
a nonexistent user and not get stucktesting:
switchUser
to prevent tests from polluting each other's sessionspost
tohttp_post
, addedhttp_get
die
/exit
are replaced withUnitySite::die
http_post
so that it always discards outputexpectException
, and hasn't come in handypre-commit hook tested:
exit()
,die()
,exit
,die
,die ()
die ()
intodie()
$ git diff --staged | cat
UnitySite::forbidden
tested:firefox:
chrome:
this page only shows when absolutely nothing was returned by the webserver. if I add
echo "<html></html>"
beforedie()
, I get a white screen in both chrome and firefox.and in error log:
header.php
viewUser
/clearUser
refactor, silly redirect chain tested:Screen.Recording.2025-04-30.at.9.44.03.AM.mov