summaryrefslogtreecommitdiff
path: root/service/http/config_test.go
diff options
context:
space:
mode:
authorSmolyakov <[email protected]>2019-09-01 15:36:42 +0300
committerSmolyakov <[email protected]>2019-09-01 15:36:42 +0300
commit488a9774636ece92e730a41092403410910d566f (patch)
treeed1138e5f2af51089650f16fde471738ca06565e /service/http/config_test.go
parent49e002c11e5cc915d80efa58611f4c4a72de7bb2 (diff)
Use last IP address from X-Forwarded-For without validation of trusty
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",