summaryrefslogtreecommitdiff
path: root/service/http/config_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'service/http/config_test.go')
-rw-r--r--service/http/config_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/service/http/config_test.go b/service/http/config_test.go
index d8b92247..800c87ce 100644
--- a/service/http/config_test.go
+++ b/service/http/config_test.go
@@ -83,6 +83,43 @@ func Test_Trusted_Subnets(t *testing.T) {
assert.False(t, cfg.IsTrusted("127.0.0.0.1"))
}
+func TestConfig_IsValid(t *testing.T) {
+
+ cfg := &Config{
+ Address: ":8080",
+ MaxRequestSize: 1024,
+ Uploads: &UploadsConfig{
+ Dir: os.TempDir(),
+ Forbid: []string{".go"},
+ },
+ HTTP2: &HTTP2Config{
+ Enabled: true,
+ },
+ TrustedSubnets: []string{"200.1.0.0/16"},
+ Workers: &roadrunner.ServerConfig{
+ Command: "php tests/client.php echo pipes",
+ Relay: "pipes",
+ Pool: &roadrunner.Config{
+ NumWorkers: 1,
+ AllocateTimeout: time.Second,
+ DestroyTimeout: time.Second,
+ },
+ },
+ }
+
+ ip6 := "FE80::0202:B3FF:FE1E:8329"
+ ip4 := "127.0.0.1"
+
+ assert.True(t, cfg.IsValid(ip4))
+ assert.True(t, cfg.IsValid(ip6))
+
+ ip4Invalid := "127.0.0.0.1"
+ ip6Invalid := "FE80::0202::B3FF:FE1E:8329" // Can only use :: once in an address
+
+ assert.False(t, cfg.IsValid(ip4Invalid))
+ assert.False(t, cfg.IsValid(ip6Invalid))
+}
+
func Test_Trusted_Subnets_Err(t *testing.T) {
cfg := &Config{
Address: ":8080",