fix webfinger responses according to the specs (#2397)

* webfinger query with no resource should get 400

* check valid webfinger query

* test webfinger query

... without acct: or with wrong server

* add test for invalid user query from webfinger

* reorder the tests to decouple from state

cleanup
This commit is contained in:
Meisam
2022-12-08 01:26:06 +01:00
committed by GitHub
parent 96bde6dec0
commit 43560cc65b
2 changed files with 28 additions and 4 deletions

View File

@@ -30,6 +30,7 @@ func WebfingerHandler(w http.ResponseWriter, r *http.Request) {
userComponents := strings.Split(account, "@")
if len(userComponents) < 2 {
w.WriteHeader(http.StatusBadRequest)
return
}
host := userComponents[1]
@@ -46,7 +47,7 @@ func WebfingerHandler(w http.ResponseWriter, r *http.Request) {
// should be rejected.
instanceHostString := data.GetServerURL()
if instanceHostString == "" {
w.WriteHeader(http.StatusNotImplemented)
w.WriteHeader(http.StatusNotFound)
return
}