Merge pull request 'Fix dashboard CSRFField crash (closes #146)' (#147) from fix/dashboard-csrf-field into main
All checks were successful
Check / check (push) Successful in 2m24s
All checks were successful
Check / check (push) Successful in 2m24s
Reviewed-on: #147
This commit was merged in pull request #147.
This commit is contained in:
@@ -404,6 +404,25 @@ func TestHandleDashboard(t *testing.T) {
|
|||||||
assert.Equal(t, http.StatusOK, recorder.Code)
|
assert.Equal(t, http.StatusOK, recorder.Code)
|
||||||
assert.Contains(t, recorder.Body.String(), "Applications")
|
assert.Contains(t, recorder.Body.String(), "Applications")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("renders dashboard with apps without crashing on CSRFField", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
testCtx := setupTestHandlers(t)
|
||||||
|
|
||||||
|
// Create an app so the template iterates over AppStats and hits .CSRFField
|
||||||
|
createTestApp(t, testCtx, "csrf-test-app")
|
||||||
|
|
||||||
|
request := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
|
||||||
|
handler := testCtx.handlers.HandleDashboard()
|
||||||
|
handler.ServeHTTP(recorder, request)
|
||||||
|
|
||||||
|
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")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHandleAppNew(t *testing.T) {
|
func TestHandleAppNew(t *testing.T) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<a href="/apps/{{.App.ID}}" class="btn-text text-sm py-1 px-2">View</a>
|
<a href="/apps/{{.App.ID}}" class="btn-text text-sm py-1 px-2">View</a>
|
||||||
<a href="/apps/{{.App.ID}}/edit" class="btn-secondary text-sm py-1 px-2">Edit</a>
|
<a href="/apps/{{.App.ID}}/edit" class="btn-secondary text-sm py-1 px-2">Edit</a>
|
||||||
<form method="POST" action="/apps/{{.App.ID}}/deploy" class="inline">
|
<form method="POST" action="/apps/{{.App.ID}}/deploy" class="inline">
|
||||||
{{ .CSRFField }}
|
{{ $.CSRFField }}
|
||||||
<button type="submit" class="btn-success text-sm py-1 px-2">Deploy</button>
|
<button type="submit" class="btn-success text-sm py-1 px-2">Deploy</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user