| 1117 | } |
| 1118 | |
| 1119 | func TestSessionHandlerReset_worker(t *testing.T) { |
| 1120 | runTest(t, func(_ func(http.ResponseWriter, *http.Request), ts *httptest.Server, i int) { |
| 1121 | // Request 1: Set a custom session handler and start session |
| 1122 | resp1, err := http.Get(ts.URL + "/session-handler.php?action=set_handler_and_start&value=test1") |
| 1123 | assert.NoError(t, err) |
| 1124 | body1, _ := io.ReadAll(resp1.Body) |
| 1125 | _ = resp1.Body.Close() |
| 1126 | |
| 1127 | body1Str := string(body1) |
| 1128 | assert.Contains(t, body1Str, "HANDLER_SET_AND_STARTED") |
| 1129 | assert.Contains(t, body1Str, "session.save_handler=user") |
| 1130 | |
| 1131 | // Request 2: Start session without setting a custom handler |
| 1132 | // The user handler from request 1 is preserved (mod_user_names persist), |
| 1133 | // so session_start() should work without crashing. |
| 1134 | resp2, err := http.Get(ts.URL + "/session-handler.php?action=start_without_handler") |
| 1135 | assert.NoError(t, err) |
| 1136 | body2, _ := io.ReadAll(resp2.Body) |
| 1137 | _ = resp2.Body.Close() |
| 1138 | |
| 1139 | body2Str := string(body2) |
| 1140 | |
| 1141 | // session_start() should succeed (handlers are preserved) |
| 1142 | assert.Contains(t, body2Str, "SESSION_START_RESULT=true", |
| 1143 | "session_start() should succeed.\nResponse: %s", body2Str) |
| 1144 | |
| 1145 | // No errors or exceptions should occur |
| 1146 | assert.NotContains(t, body2Str, "ERROR:", |
| 1147 | "No errors expected.\nResponse: %s", body2Str) |
| 1148 | assert.NotContains(t, body2Str, "EXCEPTION:", |
| 1149 | "No exceptions expected.\nResponse: %s", body2Str) |
| 1150 | |
| 1151 | }, &testOptions{ |
| 1152 | workerScript: "session-handler.php", |
| 1153 | nbWorkers: 1, |
| 1154 | nbParallelRequests: 1, |
| 1155 | realServer: true, |
| 1156 | }) |
| 1157 | } |
| 1158 | |
| 1159 | func TestSessionHandlerPreLoopPreserved_worker(t *testing.T) { |
| 1160 | runTest(t, func(_ func(http.ResponseWriter, *http.Request), ts *httptest.Server, i int) { |