-
-
Notifications
You must be signed in to change notification settings - Fork 678
Fix notary keys requests for all keys #3296
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3296 +/- ##
==========================================
- Coverage 65.74% 65.71% -0.04%
==========================================
Files 509 509
Lines 57464 57471 +7
==========================================
- Hits 37780 37767 -13
- Misses 15855 15871 +16
- Partials 3829 3833 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This reverts commit 955f949.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add additional testing for the null
vs []
edge case.
federationapi/federationapi_test.go
Outdated
validateFunc: func(t *testing.T, resp util.JSONResponse) { | ||
want := util.JSONResponse{ | ||
Code: http.StatusBadRequest, | ||
JSON: spec.BadJSON("The request body could not be decoded into valid JSON. unexpected end of JSON input"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nicer to assert the error code and not the entire error message, as that is pretty brittle.
@@ -43,6 +43,15 @@ func (a *FederationInternalAPI) fetchServerKeysFromCache( | |||
ctx context.Context, req *api.QueryServerKeysRequest, | |||
) ([]gomatrixserverlib.ServerKeys, error) { | |||
var results []gomatrixserverlib.ServerKeys | |||
|
|||
// We got a request for _all_ server keys, return them. | |||
if len(req.KeyIDToCriteria) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically {"server_keys":{"servera":null}}
will then be treated as getting all keys.
var response struct { | ||
ServerKeys []json.RawMessage `json:"server_keys"` | ||
} | ||
response.ServerKeys = []json.RawMessage{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad refactor. You forgot to do this, so no keys will be server_keys: null
not server_keys: []
.
This should be more spec compliant: