mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -06:00
Review comments
This commit is contained in:
parent
9ac02e2e4b
commit
efe8094e98
|
|
@ -370,8 +370,6 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNotaryServer(t *testing.T) {
|
func TestNotaryServer(t *testing.T) {
|
||||||
|
|
||||||
// Start a server we are going to request keys from
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
httpBody string
|
httpBody string
|
||||||
|
|
@ -381,11 +379,10 @@ func TestNotaryServer(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "empty httpBody",
|
name: "empty httpBody",
|
||||||
validateFunc: func(t *testing.T, resp util.JSONResponse) {
|
validateFunc: func(t *testing.T, resp util.JSONResponse) {
|
||||||
want := util.JSONResponse{
|
assert.Equal(t, http.StatusBadRequest, resp.Code)
|
||||||
Code: http.StatusBadRequest,
|
nk, ok := resp.JSON.(spec.MatrixError)
|
||||||
JSON: spec.BadJSON("The request body could not be decoded into valid JSON. unexpected end of JSON input"),
|
assert.True(t, ok)
|
||||||
}
|
assert.Equal(t, spec.ErrorBadJSON, nk.ErrCode)
|
||||||
assert.Equal(t, want, resp)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -394,13 +391,13 @@ func TestNotaryServer(t *testing.T) {
|
||||||
validateFunc: func(t *testing.T, resp util.JSONResponse) {
|
validateFunc: func(t *testing.T, resp util.JSONResponse) {
|
||||||
want := util.JSONResponse{
|
want := util.JSONResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
JSON: routing.NotaryKeysResponse{},
|
JSON: routing.NotaryKeysResponse{ServerKeys: []json.RawMessage{}},
|
||||||
}
|
}
|
||||||
assert.Equal(t, want, resp)
|
assert.Equal(t, want, resp)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "request all keys",
|
name: "request all keys using an empty criteria",
|
||||||
httpBody: `{"server_keys":{"servera":{}}}`,
|
httpBody: `{"server_keys":{"servera":{}}}`,
|
||||||
validateFunc: func(t *testing.T, resp util.JSONResponse) {
|
validateFunc: func(t *testing.T, resp util.JSONResponse) {
|
||||||
assert.Equal(t, http.StatusOK, resp.Code)
|
assert.Equal(t, http.StatusOK, resp.Code)
|
||||||
|
|
@ -410,6 +407,17 @@ func TestNotaryServer(t *testing.T) {
|
||||||
assert.True(t, gjson.GetBytes(nk.ServerKeys[0], "verify_keys.ed25519:someID").Exists())
|
assert.True(t, gjson.GetBytes(nk.ServerKeys[0], "verify_keys.ed25519:someID").Exists())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "request all keys using null as the criteria",
|
||||||
|
httpBody: `{"server_keys":{"servera":null}}`,
|
||||||
|
validateFunc: func(t *testing.T, resp util.JSONResponse) {
|
||||||
|
assert.Equal(t, http.StatusOK, resp.Code)
|
||||||
|
nk, ok := resp.JSON.(routing.NotaryKeysResponse)
|
||||||
|
assert.True(t, ok)
|
||||||
|
assert.Equal(t, "servera", gjson.GetBytes(nk.ServerKeys[0], "server_name").Str)
|
||||||
|
assert.True(t, gjson.GetBytes(nk.ServerKeys[0], "verify_keys.ed25519:someID").Exists())
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "request specific key",
|
name: "request specific key",
|
||||||
httpBody: `{"server_keys":{"servera":{"ed25519:someID":{}}}}`,
|
httpBody: `{"server_keys":{"servera":{"ed25519:someID":{}}}}`,
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,9 @@ func NotaryKeys(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
response := NotaryKeysResponse{}
|
response := NotaryKeysResponse{
|
||||||
|
ServerKeys: []json.RawMessage{},
|
||||||
|
}
|
||||||
|
|
||||||
for serverName, kidToCriteria := range req.ServerKeys {
|
for serverName, kidToCriteria := range req.ServerKeys {
|
||||||
var keyList []gomatrixserverlib.ServerKeys
|
var keyList []gomatrixserverlib.ServerKeys
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue