Skip to content

Commit

Permalink
Add comments to test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bnf committed Jan 30, 2024
1 parent d06a1ec commit 68be673
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .build/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,42 +48,62 @@ function login() {
rm -f $cookiefile

clear_cache
# (unauthorized) request misses both nginx and typo3 on first request
assert_raises "test_hit / MISS MISS"
# ..second request is the first one cached, therefore typo3 stays at MISS.
assert_raises "test_hit / HIT MISS"

clear_cache
# (unauthorized) request, fetching only header data which must not have been cached by nginx_cache
assert_raises "test_hit / MISS MISS -I"
# …as we do not want our cache to be flooded by HEAD requests, but TYPO3 actually did render the entire
# page in the first call and can therefore deliver a cached response
assert_raises "test_hit / MISS HIT"
# …which is then cached by nginx_cache and thus not returns HIT
assert_raises "test_hit / HIT HIT"

clear_cache
# (unauthorized) request
assert_raises "test_hit / MISS MISS"
# …requesting /index.php can not automatically deliver a cached response
assert_raises "test_hit /index.php MISS HIT"
# …but will then have been cached by nginx_cache for the /index.php route
# note: ideally index.php is set to be private in nginx.conf, so this would
# better return a 403…
assert_raises "test_hit /index.php HIT HIT"

clear_cache
# HEAD requests are not cached by themselves
assert_raises "test_hit / MISS MISS -I"
assert_raises "test_hit /index.php MISS HIT"
assert_raises "test_hit / MISS HIT -I"
assert_raises "test_hit / MISS HIT"
# …but will be answered cached,
# when there a corresponding GET requests has been cached before
assert_raises "test_hit / HIT HIT -I"

echo "UPDATE sys_template set config = REPLACE(config, 'config.admPanel = 1\n', '')" | mysql db
clear_cache
login
# authorized request without adminpanel enabled
assert_raises "test_hit / BYPASS MISS '-b $cookiefile -c $cookiefile'"
# …is cached and will therefore deliver a cached nginx response for following unauthorized requests
assert_raises "test_hit / HIT MISS"
# following authorized requests are bypassed but are served from the TYPO3 cache,
assert_raises "test_hit / BYPASS HIT '-b $cookiefile -c $cookiefile'"
#test_hit / MISS HIT
# …which will cause the nginx cache entry to be updated
# todo: ideally the update would only happen if the user pressed ctrl+shift+r(?)
assert_raises "test_hit / HIT HIT"

echo "UPDATE sys_template set config = REPLACE(config, 'page = PAGE', 'config.admPanel = 1\npage = PAGE')" | mysql db
clear_cache
login
assert_raises "test_hit / BYPASS MISS '-b $cookiefile -c $cookiefile'"
# Cache may not be filled if admin panel is enabled
# Cache may not have been filled if admin panel is enabled, but subsequent authorized requests…
assert_raises "test_hit / MISS HIT"
assert_raises "test_hit / BYPASS HIT '-b $cookiefile -c $cookiefile'"
# …will be served cached
assert_raises "test_hit / HIT HIT"

#echo "UPDATE sys_template set config = REPLACE(config, 'page = PAGE', 'config.admPanel = 1\npage = PAGE')" | mysql db
Expand Down

0 comments on commit 68be673

Please sign in to comment.