fix(integration-tests)_: add missing HTTPVirtualHosts

And set it to `*` for tests to avoid RPC access issues.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2024-07-04 12:48:40 +02:00 committed by Anton Danchenko
parent 139484a2d5
commit 0a6b76643e
6 changed files with 54 additions and 18 deletions

View File

@ -9,13 +9,14 @@ import (
"github.com/stretchr/testify/require"
)
func TestOverrideApiConfig(t *testing.T) {
func setupConfigs() (*params.NodeConfig, *requests.APIConfig) {
newNodeConfig := &params.NodeConfig{
APIModules: "test, eth, wakuv2",
ConnectorConfig: params.ConnectorConfig{Enabled: true},
HTTPEnabled: true,
HTTPHost: "0.0.0.0",
HTTPPort: 8545,
HTTPVirtualHosts: []string{"status-go"},
WSEnabled: false,
WSHost: "127.0.0.1",
WSPort: 8586,
@ -27,11 +28,17 @@ func TestOverrideApiConfig(t *testing.T) {
HTTPEnabled: false,
HTTPHost: "127.0.0.1",
HTTPPort: 8080,
HTTPVirtualHosts: []string{"*"},
WSEnabled: true,
WSHost: "192.168.0.1",
WSPort: 7777,
}
return newNodeConfig, apiConfig
}
func TestOverrideApiConfig(t *testing.T) {
newNodeConfig, apiConfig := setupConfigs()
overrideApiConfig(newNodeConfig, apiConfig)
require.Equal(t, apiConfig.APIModules, newNodeConfig.APIModules)
@ -39,7 +46,17 @@ func TestOverrideApiConfig(t *testing.T) {
require.Equal(t, apiConfig.HTTPEnabled, newNodeConfig.HTTPEnabled)
require.Equal(t, apiConfig.HTTPHost, newNodeConfig.HTTPHost)
require.Equal(t, apiConfig.HTTPPort, newNodeConfig.HTTPPort)
require.Equal(t, apiConfig.HTTPVirtualHosts, newNodeConfig.HTTPVirtualHosts)
require.Equal(t, apiConfig.WSEnabled, newNodeConfig.WSEnabled)
require.Equal(t, apiConfig.WSHost, newNodeConfig.WSHost)
require.Equal(t, apiConfig.WSPort, newNodeConfig.WSPort)
}
func TestOverrideApiConfigTest(t *testing.T) {
newNodeConfig, apiConfig := setupConfigs()
newNodeConfig.HTTPVirtualHosts = []string{"status-go"}
apiConfig.HTTPVirtualHosts = []string{"*"}
overrideApiConfigTest(newNodeConfig, apiConfig)
require.Equal(t, apiConfig.HTTPVirtualHosts, newNodeConfig.HTTPVirtualHosts)
}

View File

@ -43,6 +43,8 @@ var paths = []string{pathWalletRoot, pathEIP1581, pathDefaultChat, pathDefaultWa
var DefaultFleet = params.FleetShardsTest
var overrideApiConfig = overrideApiConfigProd
func defaultSettings(keyUID string, address string, derivedAddresses map[string]generator.AccountInfo) (*settings.Settings, error) {
chatKeyString := derivedAddresses[pathDefaultChat].PublicKey
@ -215,13 +217,14 @@ func buildWalletConfig(request *requests.WalletSecretsConfig) params.WalletConfi
return walletConfig
}
func overrideApiConfig(nodeConfig *params.NodeConfig, config *requests.APIConfig) {
func overrideApiConfigProd(nodeConfig *params.NodeConfig, config *requests.APIConfig) {
nodeConfig.APIModules = config.APIModules
nodeConfig.ConnectorConfig.Enabled = config.ConnectorEnabled
nodeConfig.HTTPEnabled = config.HTTPEnabled
nodeConfig.HTTPHost = config.HTTPHost
nodeConfig.HTTPPort = config.HTTPPort
nodeConfig.HTTPVirtualHosts = config.HTTPVirtualHosts
nodeConfig.WSEnabled = config.WSEnabled
nodeConfig.WSHost = config.WSHost

View File

@ -10,6 +10,7 @@ import (
"github.com/status-im/status-go/multiaccounts/accounts"
"github.com/status-im/status-go/multiaccounts/settings"
"github.com/status-im/status-go/params"
"github.com/status-im/status-go/protocol/requests"
"github.com/stretchr/testify/require"
)
@ -99,3 +100,13 @@ func setupWalletTest(t *testing.T, password string) (backend *GethStatusBackend,
return
}
// Only for tests
func overrideApiConfigTest(nodeConfig *params.NodeConfig, config *requests.APIConfig) {
overrideApiConfigProd(nodeConfig, config)
nodeConfig.HTTPVirtualHosts = config.HTTPVirtualHosts
}
func OverrideApiConfigTest() {
overrideApiConfig = overrideApiConfigTest
}

View File

@ -215,6 +215,7 @@ func main() {
HTTPEnabled: config.HTTPEnabled,
HTTPHost: config.HTTPHost,
HTTPPort: config.HTTPPort,
HTTPVirtualHosts: config.HTTPVirtualHosts,
WSEnabled: config.WSEnabled,
WSHost: config.WSHost,
WSPort: config.WSPort,
@ -225,6 +226,8 @@ func main() {
},
}
api.OverrideApiConfigTest()
_, err := backend.RestoreAccountAndLogin(&request)
if err != nil {
logger.Error("failed to import account", "error", err)

View File

@ -7,6 +7,7 @@
"HTTPEnabled": true,
"HTTPHost": "0.0.0.0",
"HTTPPort": 3333,
"HTTPVirtualHosts": ["*", "status-go"],
"APIModules": "eth,admin,wallet",
"WalletConfig": {
"Enabled": true

View File

@ -26,6 +26,7 @@ type APIConfig struct {
HTTPEnabled bool `json:"httpEnabled"`
HTTPHost string `json:"httpHost"`
HTTPPort int `json:"httpPort"`
HTTPVirtualHosts []string `json:"httpVirtualHosts"`
WSEnabled bool `json:"wsEnabled"`
WSHost string `json:"wsHost"`
WSPort int `json:"wsPort"`