Compare commits
2 Commits
4f687aab4d
...
c22a2877d5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c22a2877d5 | ||
|
|
43cde0eefd |
@@ -405,13 +405,12 @@ func TestHandleDashboard(t *testing.T) {
|
|||||||
assert.Contains(t, recorder.Body.String(), "Applications")
|
assert.Contains(t, recorder.Body.String(), "Applications")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("renders dashboard with apps without CSRFField error", func(t *testing.T) {
|
t.Run("renders dashboard with apps without crashing on CSRFField", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
testCtx := setupTestHandlers(t)
|
testCtx := setupTestHandlers(t)
|
||||||
|
|
||||||
// Create an app so the range loop in dashboard.html executes,
|
// Create an app so the template iterates over AppStats and hits .CSRFField
|
||||||
// which triggers .CSRFField access on each AppStats item.
|
|
||||||
createTestApp(t, testCtx, "csrf-test-app")
|
createTestApp(t, testCtx, "csrf-test-app")
|
||||||
|
|
||||||
request := httptest.NewRequest(http.MethodGet, "/", nil)
|
request := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||||
@@ -420,7 +419,8 @@ func TestHandleDashboard(t *testing.T) {
|
|||||||
handler := testCtx.handlers.HandleDashboard()
|
handler := testCtx.handlers.HandleDashboard()
|
||||||
handler.ServeHTTP(recorder, request)
|
handler.ServeHTTP(recorder, request)
|
||||||
|
|
||||||
assert.Equal(t, http.StatusOK, recorder.Code, "dashboard should render without template error")
|
assert.Equal(t, http.StatusOK, recorder.Code,
|
||||||
|
"dashboard should not 500 when apps exist (CSRFField must be accessible)")
|
||||||
assert.Contains(t, recorder.Body.String(), "csrf-test-app")
|
assert.Contains(t, recorder.Body.String(), "csrf-test-app")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user