@@ -1861,6 +1861,43 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsContentFrontEndWith
18611861 s .Equal (expectedData , actualData )
18621862}
18631863
1864+ func (s HaProxyTestSuite ) Test_CreateConfigFromTemplates_AddsContentFrontEndWithHttpsPort_WithSrcPort () {
1865+ var actualData string
1866+ tmpl := s .TemplateContent
1867+ expectedData := fmt .Sprintf (
1868+ `%s
1869+ acl url_my-service1111_0 path_beg /path
1870+ acl srcPort_my-service8080_0 dst_port 8080
1871+ acl http_my-service_0 dst_port 8080
1872+ acl https_my-service_0 dst_port 443
1873+ use_backend my-service-be1111_0 if url_my-service1111_0 srcPort_my-service8080_0 http_my-service_0
1874+ use_backend https-my-service-be1111_0 if url_my-service1111_0 https_my-service_0%s` ,
1875+ tmpl ,
1876+ s .ServicesContent ,
1877+ )
1878+ writeFile = func (filename string , data []byte , perm os.FileMode ) error {
1879+ actualData = string (data )
1880+ return nil
1881+ }
1882+ p := NewHaProxy (s .TemplatesPath , s .ConfigsPath )
1883+ service1 := Service {
1884+ ServiceName : "my-service" ,
1885+ PathType : "path_beg" ,
1886+ HttpsPort : 2222 ,
1887+ AclName : "my-service" ,
1888+ ServiceDest : []ServiceDest {
1889+ {Port : "1111" , ServicePath : []string {"/path" },
1890+ SrcPort : 8080 },
1891+ },
1892+ }
1893+ p .AddService (service1 )
1894+
1895+ FormatServiceForTemplates (& service1 )
1896+ p .CreateConfigFromTemplates ()
1897+
1898+ s .Equal (expectedData , actualData )
1899+ }
1900+
18641901func (s HaProxyTestSuite ) Test_CreateConfigFromTemplates_ForwardsToHttps_WhenRedirectWhenHttpProtoIsTrue () {
18651902 var actualData string
18661903 tmpl := s .TemplateContent
0 commit comments