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:
parent
139484a2d5
commit
0a6b76643e
|
@ -9,16 +9,17 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestOverrideApiConfig(t *testing.T) {
|
||||
func setupConfigs() (*params.NodeConfig, *requests.APIConfig) {
|
||||
newNodeConfig := ¶ms.NodeConfig{
|
||||
APIModules: "test, eth, wakuv2",
|
||||
ConnectorConfig: params.ConnectorConfig{Enabled: true},
|
||||
HTTPEnabled: true,
|
||||
HTTPHost: "0.0.0.0",
|
||||
HTTPPort: 8545,
|
||||
WSEnabled: false,
|
||||
WSHost: "127.0.0.1",
|
||||
WSPort: 8586,
|
||||
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,
|
||||
}
|
||||
|
||||
apiConfig := &requests.APIConfig{
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"HTTPEnabled": true,
|
||||
"HTTPHost": "0.0.0.0",
|
||||
"HTTPPort": 3333,
|
||||
"HTTPVirtualHosts": ["*", "status-go"],
|
||||
"APIModules": "eth,admin,wallet",
|
||||
"WalletConfig": {
|
||||
"Enabled": true
|
||||
|
|
|
@ -21,14 +21,15 @@ type ImageCropRectangle struct {
|
|||
}
|
||||
|
||||
type APIConfig struct {
|
||||
APIModules string `json:"apiModules"`
|
||||
ConnectorEnabled bool `json:"connectorEnabled"`
|
||||
HTTPEnabled bool `json:"httpEnabled"`
|
||||
HTTPHost string `json:"httpHost"`
|
||||
HTTPPort int `json:"httpPort"`
|
||||
WSEnabled bool `json:"wsEnabled"`
|
||||
WSHost string `json:"wsHost"`
|
||||
WSPort int `json:"wsPort"`
|
||||
APIModules string `json:"apiModules"`
|
||||
ConnectorEnabled bool `json:"connectorEnabled"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type CreateAccount struct {
|
||||
|
|
Loading…
Reference in New Issue