bind to localhost:0 for tests (#22839)
* bind to localhost:0 for tests Explicitly bind to `localhost:0` instead of just `:0` to avoid binding to all available interfaces and in turn avoid triggering firewall warnings on MacOS. * fix Playbooks to use dynamic port * TestMetrics: handle ipv4 localhost too * TestMetrics: linting
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7325c38c39
Коммит
4b7f6cb974
@@ -47,7 +47,7 @@ func newServerWithConfig(t *testing.T, f func(cfg *model.Config)) (*Server, erro
|
||||
|
||||
func TestStartServerSuccess(t *testing.T) {
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestStartServerPortUnavailable(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Listen on the next available port
|
||||
listener, err := net.Listen("tcp", ":0")
|
||||
listener, err := net.Listen("tcp", "localhost:0")
|
||||
require.NoError(t, err)
|
||||
|
||||
// Attempt to listen on the port used above.
|
||||
@@ -104,7 +104,7 @@ func TestStartServerNoS3Bucket(t *testing.T) {
|
||||
AmazonS3PathPrefix: model.NewString(""),
|
||||
AmazonS3SSL: model.NewBool(false),
|
||||
}
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
_, _, err := store.Set(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -131,7 +131,7 @@ func TestStartServerTLSSuccess(t *testing.T) {
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
testDir, _ := fileutils.FindDir("tests")
|
||||
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
|
||||
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
|
||||
*cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem")
|
||||
@@ -185,7 +185,7 @@ func TestStartServerTLSVersion(t *testing.T) {
|
||||
cfg := store.Get()
|
||||
testDir, _ := fileutils.FindDir("tests")
|
||||
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
|
||||
*cfg.ServiceSettings.TLSMinVer = "1.2"
|
||||
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
|
||||
@@ -229,7 +229,7 @@ func TestStartServerTLSOverwriteCipher(t *testing.T) {
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
testDir, _ := fileutils.FindDir("tests")
|
||||
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
|
||||
cfg.ServiceSettings.TLSOverwriteCiphers = []string{
|
||||
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
||||
@@ -328,7 +328,7 @@ func TestPanicLog(t *testing.T) {
|
||||
|
||||
testDir, _ := fileutils.FindDir("tests")
|
||||
s.platform.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
|
||||
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
|
||||
*cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem")
|
||||
@@ -404,7 +404,7 @@ func TestSentry(t *testing.T) {
|
||||
SentryDSN = dsn.String()
|
||||
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*cfg.LogSettings.EnableSentry = false
|
||||
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
|
||||
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
|
||||
@@ -448,7 +448,7 @@ func TestSentry(t *testing.T) {
|
||||
SentryDSN = dsn.String()
|
||||
|
||||
s, err := newServerWithConfig(t, func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ListenAddress = ":0"
|
||||
*cfg.ServiceSettings.ListenAddress = "localhost:0"
|
||||
*cfg.ServiceSettings.ConnectionSecurity = "TLS"
|
||||
*cfg.ServiceSettings.TLSKeyFile = path.Join(testDir, "tls_test_key.pem")
|
||||
*cfg.ServiceSettings.TLSCertFile = path.Join(testDir, "tls_test_cert.pem")
|
||||
|
||||
Ссылка в новой задаче
Block a user