API: Update endpoints to return HTTP 201 when a new resource was created

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-10-20 16:46:59 +02:00
parent ddc37e08ab
commit ce304abd2c
12 changed files with 194 additions and 30 deletions

View File

@@ -103,7 +103,8 @@ func TestCreateUserPasscode(t *testing.T) {
log.Fatal(err)
} else {
r := AuthenticatedRequestWithBody(app, "POST", "/api/v1/users/uqxetse3cy5eo9z2/passcode", string(pcStr), sessId)
assert.Equal(t, http.StatusOK, r.Code)
assert.Equal(t, http.StatusCreated, r.Code)
assert.Equal(t, "/api/v1/users/uqxetse3cy5eo9z2/passcode", r.Header().Get("Location"))
}
})
}
@@ -248,7 +249,7 @@ func TestUserPasscode(t *testing.T) {
}
r := AuthenticatedRequestWithBody(app, "POST", "/api/v1/users/uqxetse3cy5eo9z2/passcode", string(pcStr), sessId)
assert.Equal(t, http.StatusOK, r.Code)
assert.Equal(t, http.StatusCreated, r.Code)
secret := gjson.Get(r.Body.String(), "Secret").String()
activatedAt := gjson.Get(r.Body.String(), "ActivatedAt").String()