diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 8605a1b..7fbf19e 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -134,8 +134,9 @@ func (app *application) snippetCreatePost(w http.ResponseWriter, r *http.Request func (app *application) userSignupPost(w http.ResponseWriter, r *http.Request) { var form userSignupForm err := app.decodePostForm(r, &form) + if err != nil { - app.clientError(w, http.StatusBadRequest) + app.notFound(w) return } diff --git a/cmd/web/handlers_test.go b/cmd/web/handlers_test.go index c3dc007..42574e7 100644 --- a/cmd/web/handlers_test.go +++ b/cmd/web/handlers_test.go @@ -2,6 +2,7 @@ package main import ( "net/http" + "net/url" "testing" "gitea.local.lab/Lbenedar/snippetbox/internal/assert" @@ -76,3 +77,118 @@ func TestSnippetView(t *testing.T) { }) } } + +func TestUserSignup(t *testing.T) { + app := newTestApplication(t) + ts := newTestServer(t, app.routes()) + defer ts.Close() + + _, _, body := ts.get(t, "/user/signup") + validCsrfToken := extractCSRFToken(t, body) + t.Logf("CsrfToken: %s", validCsrfToken) + + const ( + validName = "Bob" + validPassword = "validPa$$word" + validEmail = "bob@example.com" + formTag = "