From a21b4211561b7b2da9e00451413d561299d1a433 Mon Sep 17 00:00:00 2001 From: Brian Meek Date: Tue, 7 Feb 2023 17:14:16 -0800 Subject: [PATCH] Revert "Set the test config server_name to localhost" This reverts commit 7fa8ee0d1af9cebe26b5d1aa0ddaa5de78a5f965. --- clientapi/auth/login_publickey_ethereum.go | 9 ++++++++- clientapi/auth/login_publickey_ethereum_test.go | 6 +----- clientapi/routing/register_publickey_test.go | 6 +----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/clientapi/auth/login_publickey_ethereum.go b/clientapi/auth/login_publickey_ethereum.go index fdc7cf9f4..8849388ef 100644 --- a/clientapi/auth/login_publickey_ethereum.go +++ b/clientapi/auth/login_publickey_ethereum.go @@ -25,6 +25,7 @@ import ( "github.com/matrix-org/dendrite/clientapi/userutil" "github.com/matrix-org/dendrite/setup/config" userapi "github.com/matrix-org/dendrite/userapi/api" + "github.com/matrix-org/gomatrixserverlib" "github.com/spruceid/siwe-go" ) @@ -116,7 +117,13 @@ func (pk LoginPublicKeyEthereum) ValidateLoginResponse() (bool, *jsonerror.Matri return false, jsonerror.InvalidParam("auth.message") } - serverName := pk.config.Matrix.ServerName + cfg := &config.Global{ + SigningIdentity: gomatrixserverlib.SigningIdentity{ + ServerName: gomatrixserverlib.ServerName("localhost"), + }, + } + + serverName := cfg.ServerName // Check signature to verify message was not tempered _, err = message.Verify(pk.Signature, (*string)(&serverName), nil, nil) diff --git a/clientapi/auth/login_publickey_ethereum_test.go b/clientapi/auth/login_publickey_ethereum_test.go index 5e7788416..d90cd5f49 100644 --- a/clientapi/auth/login_publickey_ethereum_test.go +++ b/clientapi/auth/login_publickey_ethereum_test.go @@ -27,7 +27,6 @@ import ( "github.com/matrix-org/dendrite/setup/config" testutil "github.com/matrix-org/dendrite/test" uapi "github.com/matrix-org/dendrite/userapi/api" - "github.com/matrix-org/gomatrixserverlib" "github.com/stretchr/testify/assert" ) @@ -38,10 +37,7 @@ type loginContext struct { func createLoginContext(_ *testing.T) *loginContext { cfg := &config.ClientAPI{ - Matrix: &config.Global{SigningIdentity: gomatrixserverlib.SigningIdentity{ - ServerName: gomatrixserverlib.ServerName("localhost"), - }, - }, + Matrix: &config.Global{}, Derived: &config.Derived{}, PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ diff --git a/clientapi/routing/register_publickey_test.go b/clientapi/routing/register_publickey_test.go index e58878ef7..19960ed22 100644 --- a/clientapi/routing/register_publickey_test.go +++ b/clientapi/routing/register_publickey_test.go @@ -29,7 +29,6 @@ import ( "github.com/matrix-org/dendrite/setup/config" testutil "github.com/matrix-org/dendrite/test" uapi "github.com/matrix-org/dendrite/userapi/api" - "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/stretchr/testify/assert" ) @@ -43,9 +42,7 @@ type registerContext struct { func createRegisterContext(_ *testing.T) *registerContext { cfg := &config.ClientAPI{ - Matrix: &config.Global{SigningIdentity: gomatrixserverlib.SigningIdentity{ - ServerName: gomatrixserverlib.ServerName("localhost"), - }}, + Matrix: &config.Global{}, Derived: &config.Derived{}, PasswordAuthenticationDisabled: true, PublicKeyAuthentication: config.PublicKeyAuthentication{ @@ -267,7 +264,6 @@ func TestRegisterEthereum(t *testing.T) { // Asserts assert := assert.New(t) assert.NotNil(response, "response actual: nil, expected: not nil") - fmt.Println(response.JSON) registerRes := response.JSON.(registerResponse) assert.Truef( registerRes.UserID == wallet.Eip155UserId,