@@ -747,11 +747,14 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsContentFrontEnd() {
747747 tmpl := s .TemplateContent
748748 expectedData := fmt .Sprintf (
749749 `%s
750- acl url_my-service-11111_0 path_beg /path-1 path_beg /path-2 port1111Acl
751- acl url_my-service-12222_1 path_beg /path-3 port2222Acl
750+ acl url_my-service-11111_0 path_beg /path-1 path_beg /path-2
751+ acl port1111Acl
752+ acl url_my-service-12222_1 path_beg /path-3
753+ acl port2222Acl
752754 use_backend my-service-1-be1111_0 if url_my-service-11111_0 my-src-port
753755 use_backend my-service-1-be2222_1 if url_my-service-12222_1
754- acl url_my-service-23333_0 path_beg /path-4 port3333Acl
756+ acl url_my-service-23333_0 path_beg /path-4
757+ acl port3333Acl
755758 use_backend my-service-2-be3333_0 if url_my-service-23333_0%s` ,
756759 tmpl ,
757760 s .ServicesContent ,
@@ -765,15 +768,15 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsContentFrontEnd() {
765768 ServiceName : "my-service-1" ,
766769 PathType : "path_beg" ,
767770 ServiceDest : []ServiceDest {
768- {Port : "1111" , ServicePath : []string {"/path-1" , "/path-2" }, SrcPortAcl : " port1111Acl" , SrcPortAclName : " my-src-port" , Index : 0 },
769- {Port : "2222" , ServicePath : []string {"/path-3" }, SrcPortAcl : " port2222Acl" , Index : 1 },
771+ {Port : "1111" , ServicePath : []string {"/path-1" , "/path-2" }, SrcPortAcl : "acl port1111Acl" , SrcPortAclName : " my-src-port" , IncludeSrcPortACL : true , Index : 0 },
772+ {Port : "2222" , ServicePath : []string {"/path-3" }, SrcPortAcl : "acl port2222Acl" , Index : 1 , IncludeSrcPortACL : true },
770773 },
771774 }
772775 service2 := Service {
773776 ServiceName : "my-service-2" ,
774777 PathType : "path_beg" ,
775778 ServiceDest : []ServiceDest {
776- {Port : "3333" , ServicePath : []string {"/path-4" }, SrcPortAcl : " port3333Acl" , Index : 0 },
779+ {Port : "3333" , ServicePath : []string {"/path-4" }, SrcPortAcl : "acl port3333Acl" , Index : 0 , IncludeSrcPortACL : true },
777780 },
778781 }
779782 p .AddService (service1 )
@@ -791,9 +794,9 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsServicePathExclude(
791794 `%s
792795 acl url_my-service-11111_0 path_beg /path-1
793796 acl url_exclude_my-service-11111_0 path_beg /path-2 path_beg /path-3
794- acl http_my -service-1_0 dst_port 80
797+ acl srcPort_my -service-180_0 dst_port 80
795798 acl https_my-service-1_0 dst_port 443
796- use_backend my-service-1-be1111_0 if url_my-service-11111_0 !url_exclude_my-service-11111_0 http_my -service-1_0
799+ use_backend my-service-1-be1111_0 if url_my-service-11111_0 !url_exclude_my-service-11111_0 srcPort_my -service-180_0
797800 use_backend https-my-service-1-be1111_0 if url_my-service-11111_0 !url_exclude_my-service-11111_0 https_my-service-1_0%s` ,
798801 tmpl ,
799802 s .ServicesContent ,
@@ -812,6 +815,7 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsServicePathExclude(
812815 }
813816 p .AddService (service )
814817
818+ FormatServiceForTemplates (& service )
815819 p .CreateConfigFromTemplates ()
816820
817821 s .Equal (expectedData , actualData )
@@ -1832,9 +1836,9 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsContentFrontEndWith
18321836 expectedData := fmt .Sprintf (
18331837 `%s
18341838 acl url_my-service1111_0 path_beg /path
1835- acl http_my-service_0 dst_port 80
1839+ acl srcPort_my-service80_0 dst_port 80
18361840 acl https_my-service_0 dst_port 443
1837- use_backend my-service-be1111_0 if url_my-service1111_0 http_my-service_0
1841+ use_backend my-service-be1111_0 if url_my-service1111_0 srcPort_my-service80_0
18381842 use_backend https-my-service-be1111_0 if url_my-service1111_0 https_my-service_0%s` ,
18391843 tmpl ,
18401844 s .ServicesContent ,
@@ -1854,6 +1858,7 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsContentFrontEndWith
18541858 }
18551859 p .AddService (service1 )
18561860
1861+ FormatServiceForTemplates (& service1 )
18571862 p .CreateConfigFromTemplates ()
18581863
18591864 s .Equal (expectedData , actualData )
@@ -1866,9 +1871,8 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsContentFrontEndWith
18661871 `%s
18671872 acl url_my-service1111_0 path_beg /path
18681873 acl srcPort_my-service8080_0 dst_port 8080
1869- acl http_my-service_0 dst_port 8080
18701874 acl https_my-service_0 dst_port 443
1871- use_backend my-service-be1111_0 if url_my-service1111_0 srcPort_my-service8080_0 http_my-service_0
1875+ use_backend my-service-be1111_0 if url_my-service1111_0 srcPort_my-service8080_0
18721876 use_backend https-my-service-be1111_0 if url_my-service1111_0 https_my-service_0%s` ,
18731877 tmpl ,
18741878 s .ServicesContent ,
0 commit comments