@@ -696,31 +696,44 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsServices() {
696
696
ServicePath : []string {"my-path-11" , "my-path-12" },
697
697
SrcPort : 1112 ,
698
698
ReqMode : "my-ReqMode" ,
699
+ AllowedMethods : []string {"GET" , "POST" },
700
+ DeniedMethods : []string {"OPTION" , "TRACE" },
701
+ RedirectFromDomain : []string {"proxy.dockerflow.com" , "dockerflow.com" },
702
+ ServicePathExclude : []string {"some-path" , "some-path2" },
703
+ VerifyClientSsl : true ,
704
+ DenyHttp : true ,
705
+ IgnoreAuthorization : true ,
699
706
},
700
707
},
701
708
}
702
709
os .Setenv ("DFP_SERVICE_ACL_NAME" , service .AclName )
703
710
os .Setenv ("DFP_SERVICE_ADD_REQ_HEADER" , strings .Join (service .AddReqHeader , "," ))
704
711
os .Setenv ("DFP_SERVICE_ADD_RES_HEADER" , strings .Join (service .AddResHeader , "," ))
712
+ os .Setenv ("DFP_SERVICE_ALLOWED_METHODS" , strings .Join (service .ServiceDest [0 ].AllowedMethods , "," ))
705
713
os .Setenv ("DFP_SERVICE_COMPRESSION_ALGO" , service .CompressionAlgo )
706
714
os .Setenv ("DFP_SERVICE_COMPRESSION_TYPE" , service .CompressionType )
707
715
os .Setenv ("DFP_SERVICE_CONNECTION_MODE" , service .ConnectionMode )
708
716
os .Setenv ("DFP_SERVICE_DEL_REQ_HEADER" , strings .Join (service .DelReqHeader , "," ))
709
717
os .Setenv ("DFP_SERVICE_DEL_RES_HEADER" , strings .Join (service .DelResHeader , "," ))
718
+ os .Setenv ("DFP_SERVICE_DENIED_METHODS" , strings .Join (service .ServiceDest [0 ].DeniedMethods , "," ))
719
+ os .Setenv ("DFP_SERVICE_DENY_HTTP" , strconv .FormatBool (service .ServiceDest [0 ].DenyHttp ))
710
720
os .Setenv ("DFP_SERVICE_DISTRIBUTE" , strconv .FormatBool (service .Distribute ))
711
721
os .Setenv ("DFP_SERVICE_HTTPS_ONLY" , strconv .FormatBool (service .ServiceDest [0 ].HttpsOnly ))
712
722
os .Setenv ("DFP_SERVICE_HTTPS_REDIRECT_CODE" , service .ServiceDest [0 ].HttpsRedirectCode )
713
723
os .Setenv ("DFP_SERVICE_HTTPS_PORT" , strconv .Itoa (service .HttpsPort ))
724
+ os .Setenv ("DFP_SERVICE_IGNORE_AUTHORIZATION" , strconv .FormatBool (service .ServiceDest [0 ].IgnoreAuthorization ))
714
725
os .Setenv ("DFP_SERVICE_IS_DEFAULT_BACKEND" , strconv .FormatBool (service .IsDefaultBackend ))
715
726
os .Setenv ("DFP_SERVICE_OUTBOUND_HOSTNAME" , service .ServiceDest [0 ].OutboundHostname )
716
727
os .Setenv ("DFP_SERVICE_PATH_TYPE" , service .PathType )
728
+ os .Setenv ("DFP_SERVICE_REDIRECT_FROM_DOMAIN" , strings .Join (service .ServiceDest [0 ].RedirectFromDomain , "," ))
717
729
os .Setenv ("DFP_SERVICE_REDIRECT_WHEN_HTTP_PROTO" , strconv .FormatBool (service .RedirectWhenHttpProto ))
718
730
os .Setenv ("DFP_SERVICE_REQ_MODE" , service .ServiceDest [0 ].ReqMode )
719
731
os .Setenv ("DFP_SERVICE_REQ_PATH_SEARCH_REPLACE" , service .ServiceDest [0 ].ReqPathSearchReplace )
720
732
os .Setenv ("DFP_SERVICE_SERVICE_CERT" , service .ServiceCert )
721
733
os .Setenv ("DFP_SERVICE_SERVICE_DOMAIN" , strings .Join (service .ServiceDest [0 ].ServiceDomain , "," ))
722
734
os .Setenv ("DFP_SERVICE_SERVICE_DOMAIN_ALGO" , service .ServiceDomainAlgo )
723
735
os .Setenv ("DFP_SERVICE_SERVICE_NAME" , service .ServiceName )
736
+ os .Setenv ("DFP_SERVICE_SERVICE_PATH_EXCLUDE" , strings .Join (service .ServiceDest [0 ].ServicePathExclude , "," ))
724
737
os .Setenv ("DFP_SERVICE_SSL_VERIFY_NONE" , strconv .FormatBool (service .SslVerifyNone ))
725
738
os .Setenv ("DFP_SERVICE_TEMPLATE_BE_PATH" , service .TemplateBePath )
726
739
os .Setenv ("DFP_SERVICE_TEMPLATE_FE_PATH" , service .TemplateFePath )
@@ -731,24 +744,30 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsServices() {
731
744
os .Setenv ("DFP_SERVICE_SET_REQ_HEADER" , strings .Join (service .SetReqHeader , "," ))
732
745
os .Setenv ("DFP_SERVICE_SET_RES_HEADER" , strings .Join (service .SetResHeader , "," ))
733
746
os .Setenv ("DFP_SERVICE_SRC_PORT" , strconv .Itoa (service .ServiceDest [0 ].SrcPort ))
747
+ os .Setenv ("DFP_SERVICE_SSL_VERIFY_NONE" , strconv .FormatBool (service .ServiceDest [0 ].VerifyClientSsl ))
734
748
735
749
defer func () {
736
750
os .Unsetenv ("DFP_SERVICE_ACL_NAME" )
737
751
os .Unsetenv ("DFP_SERVICE_ADD_REQ_HEADER" )
738
752
os .Unsetenv ("DFP_SERVICE_ADD_RES_HEADER" )
753
+ os .Unsetenv ("DFP_SERVICE_ALLOWED_METHODS" )
739
754
os .Unsetenv ("DFP_SERVICE_COMPRESSION_ALGO" )
740
755
os .Unsetenv ("DFP_SERVICE_COMPRESSION_TYPE" )
741
756
os .Unsetenv ("DFP_SERVICE_CONNECTION_MODE" )
742
757
os .Unsetenv ("DFP_SERVICE_DEL_REQ_HEADER" )
743
758
os .Unsetenv ("DFP_SERVICE_DEL_RES_HEADER" )
759
+ os .Unsetenv ("DFP_SERVICE_DENIED_METHODS" )
760
+ os .Unsetenv ("DFP_SERVICE_DENY_HTTP" )
744
761
os .Unsetenv ("DFP_SERVICE_DISTRIBUTE" )
745
762
os .Unsetenv ("DFP_SERVICE_HTTPS_ONLY" )
746
763
os .Unsetenv ("DFP_SERVICE_HTTPS_PORT" )
747
764
os .Unsetenv ("DFP_SERVICE_HTTPS_REDIRECT_CODE" )
765
+ os .Unsetenv ("DFP_SERVICE_IGNORE_AUTHORIZATION" )
748
766
os .Unsetenv ("DFP_SERVICE_IS_DEFAULT_BACKEND" )
749
767
os .Unsetenv ("DFP_SERVICE_OUTBOUND_HOSTNAME" )
750
768
os .Unsetenv ("DFP_SERVICE_PATH_TYPE" )
751
769
os .Unsetenv ("DFP_SERVICE_PORT" )
770
+ os .Unsetenv ("DFP_SERVICE_REDIRECT_FROM_DOMAIN" )
752
771
os .Unsetenv ("DFP_SERVICE_REDIRECT_WHEN_HTTP_PROTO" )
753
772
os .Unsetenv ("DFP_SERVICE_REQ_MODE" )
754
773
os .Unsetenv ("DFP_SERVICE_REQ_PATH_SEARCH_REPLACE" )
@@ -757,10 +776,12 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsServices() {
757
776
os .Unsetenv ("DFP_SERVICE_SERVICE_DOMAIN_ALGO" )
758
777
os .Unsetenv ("DFP_SERVICE_SERVICE_NAME" )
759
778
os .Unsetenv ("DFP_SERVICE_SERVICE_PATH" )
779
+ os .Unsetenv ("DFP_SERVICE_SERVICE_PATH_EXCLUDE" )
760
780
os .Unsetenv ("DFP_SERVICE_SET_REQ_HEADER" )
761
781
os .Unsetenv ("DFP_SERVICE_SET_RES_HEADER" )
762
782
os .Unsetenv ("DFP_SERVICE_SRC_PORT" )
763
783
os .Unsetenv ("DFP_SERVICE_SSL_VERIFY_NONE" )
784
+ os .Unsetenv ("DFP_SERVICE_SSL_VERIFY_NONE" )
764
785
os .Unsetenv ("DFP_SERVICE_TEMPLATE_BE_PATH" )
765
786
os .Unsetenv ("DFP_SERVICE_TEMPLATE_FE_PATH" )
766
787
os .Unsetenv ("DFP_SERVICE_TIMEOUT_SERVER" )
@@ -784,6 +805,10 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_SetsServiceDomainAlgoToHdr
784
805
ReqPathSearchReplaceFormatted : []string {},
785
806
ServiceDomain : []string {"my-domain-1.com" , "my-domain-2.com" },
786
807
ServicePath : []string {"my-path-11" , "my-path-12" },
808
+ AllowedMethods : []string {},
809
+ DeniedMethods : []string {},
810
+ RedirectFromDomain : []string {},
811
+ ServicePathExclude : []string {},
787
812
},
788
813
},
789
814
ServiceDomainAlgo : "hdr_dom(host)" ,
@@ -815,16 +840,29 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsServicesWithIndexed
815
840
ReqPathSearchReplace : "/this,/that" ,
816
841
ReqPathSearchReplaceFormatted : []string {"/this,/that" },
817
842
ServicePath : []string {"my-path-11" , "my-path-12" },
843
+ ServiceDomain : []string {"some-domain.com" , "some-domain2.com" },
844
+ AllowedMethods : []string {},
845
+ DeniedMethods : []string {},
846
+ RedirectFromDomain : []string {},
847
+ ServicePathExclude : []string {},
818
848
SrcPort : 1112 ,
819
849
HttpsOnly : true ,
820
850
}, {
821
851
Port : "2221" ,
822
852
ReqPathSearchReplace : "/something,/else" ,
823
853
ReqPathSearchReplaceFormatted : []string {"/something,/else" },
824
854
ServicePath : []string {"my-path-21" , "my-path-22" },
855
+ ServiceDomain : []string {},
825
856
SrcPort : 2222 ,
826
857
HttpsOnly : false ,
827
858
OutboundHostname : "my-outbound-domain.com" ,
859
+ AllowedMethods : []string {"GET" , "POST" },
860
+ DeniedMethods : []string {"OPTION" , "TRACE" },
861
+ RedirectFromDomain : []string {"proxy.dockerflow.com" , "dockerflow.com" },
862
+ ServicePathExclude : []string {"some-path" , "some-path2" },
863
+ VerifyClientSsl : true ,
864
+ DenyHttp : true ,
865
+ IgnoreAuthorization : true ,
828
866
},
829
867
},
830
868
}
@@ -833,13 +871,21 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsServicesWithIndexed
833
871
os .Setenv ("DFP_SERVICE_PORT_1" , expected .ServiceDest [0 ].Port )
834
872
os .Setenv ("DFP_SERVICE_REQ_PATH_SEARCH_REPLACE_1" , expected .ServiceDest [0 ].ReqPathSearchReplace )
835
873
os .Setenv ("DFP_SERVICE_SERVICE_PATH_1" , strings .Join (expected .ServiceDest [0 ].ServicePath , "," ))
874
+ os .Setenv ("DFP_SERVICE_SERVICE_DOMAIN_1" , strings .Join (expected .ServiceDest [0 ].ServiceDomain , "," ))
836
875
os .Setenv ("DFP_SERVICE_SRC_PORT_1" , strconv .Itoa (expected .ServiceDest [0 ].SrcPort ))
837
876
os .Setenv ("DFP_SERVICE_HTTPS_ONLY_2" , "false" )
838
877
os .Setenv ("DFP_SERVICE_PORT_2" , expected .ServiceDest [1 ].Port )
839
878
os .Setenv ("DFP_SERVICE_REQ_PATH_SEARCH_REPLACE_2" , expected .ServiceDest [1 ].ReqPathSearchReplace )
840
879
os .Setenv ("DFP_SERVICE_SERVICE_PATH_2" , strings .Join (expected .ServiceDest [1 ].ServicePath , "," ))
841
880
os .Setenv ("DFP_SERVICE_SRC_PORT_2" , strconv .Itoa (expected .ServiceDest [1 ].SrcPort ))
842
881
os .Setenv ("DFP_SERVICE_OUTBOUND_HOSTNAME_2" , expected .ServiceDest [1 ].OutboundHostname )
882
+ os .Setenv ("DFP_SERVICE_ALLOWED_METHODS_2" , strings .Join (expected .ServiceDest [1 ].AllowedMethods , "," ))
883
+ os .Setenv ("DFP_SERVICE_DENIED_METHODS_2" , strings .Join (expected .ServiceDest [1 ].DeniedMethods , "," ))
884
+ os .Setenv ("DFP_SERVICE_REDIRECT_FROM_DOMAIN_2" , strings .Join (expected .ServiceDest [1 ].RedirectFromDomain , "," ))
885
+ os .Setenv ("DFP_SERVICE_SERVICE_PATH_EXCLUDE_2" , strings .Join (expected .ServiceDest [1 ].ServicePathExclude , "," ))
886
+ os .Setenv ("DFP_SERVICE_SSL_VERIFY_NONE_2" , strconv .FormatBool (expected .ServiceDest [1 ].VerifyClientSsl ))
887
+ os .Setenv ("DFP_SERVICE_DENY_HTTP_2" , strconv .FormatBool (expected .ServiceDest [1 ].DenyHttp ))
888
+ os .Setenv ("DFP_SERVICE_IGNORE_AUTHORIZATION_2" , strconv .FormatBool (expected .ServiceDest [1 ].IgnoreAuthorization ))
843
889
844
890
defer func () {
845
891
os .Unsetenv ("DFP_SERVICE_SERVICE_NAME" )
@@ -854,6 +900,14 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsServicesWithIndexed
854
900
os .Unsetenv ("DFP_SERVICE_SERVICE_PATH_2" )
855
901
os .Unsetenv ("DFP_SERVICE_SRC_PORT_2" )
856
902
os .Unsetenv ("DFP_SERVICE_OUTBOUND_HOSTNAME_2" )
903
+ os .Unsetenv ("DFP_SERVICE_ALLOWED_METHODS_2" )
904
+ os .Unsetenv ("DFP_SERVICE_DENIED_METHODS_2" )
905
+ os .Unsetenv ("DFP_SERVICE_REDIRECT_FROM_DOMAIN_2" )
906
+ os .Unsetenv ("DFP_SERVICE_SERVICE_PATH_EXCLUDE_2" )
907
+ os .Unsetenv ("DFP_SERVICE_SERVICE_DOMAIN_2" )
908
+ os .Unsetenv ("DFP_SERVICE_VERIFY_CLIENT_SSL_2" )
909
+ os .Unsetenv ("DFP_SERVICE_DENY_HTTP_2" )
910
+ os .Unsetenv ("DFP_SERVICE_IGNORE_AUTHORIZATION_2" )
857
911
}()
858
912
srv := serve {}
859
913
actual := srv .GetServicesFromEnvVars ()
@@ -882,6 +936,10 @@ func (s *ServerTestSuite) Test_GetServicesFromEnvVars_ReturnsMultipleServices()
882
936
ServicePath : []string {"my-path-11" , "my-path-12" },
883
937
SrcPort : 1112 ,
884
938
ReqMode : "http" ,
939
+ AllowedMethods : []string {},
940
+ DeniedMethods : []string {},
941
+ RedirectFromDomain : []string {},
942
+ ServicePathExclude : []string {},
885
943
},
886
944
},
887
945
}
0 commit comments