@@ -1538,7 +1538,7 @@ func Test_BuildListenerRules(t *testing.T) {
15381538 },
15391539 },
15401540 {
1541- name : "redirect filter should result in redirect action" ,
1541+ name : "redirect filter should result in redirect action - https " ,
15421542 port : 80 ,
15431543 listenerProtocol : elbv2model .ProtocolHTTP ,
15441544 ipAddressType : elbv2model .IPAddressTypeIPV4 ,
@@ -1588,6 +1588,142 @@ func Test_BuildListenerRules(t *testing.T) {
15881588 Type : "redirect" ,
15891589 RedirectConfig : & elbv2model.RedirectActionConfig {
15901590 Protocol : awssdk .String ("HTTPS" ),
1591+ Port : awssdk .String ("443" ),
1592+ StatusCode : "HTTP_301" ,
1593+ },
1594+ },
1595+ },
1596+ Conditions : []elbv2model.RuleCondition {
1597+ {
1598+ Field : "path-pattern" ,
1599+ PathPatternConfig : & elbv2model.PathPatternConditionConfig {
1600+ Values : []string {"/*" },
1601+ },
1602+ },
1603+ },
1604+ },
1605+ },
1606+ },
1607+ {
1608+ name : "redirect filter should result in redirect action - http" ,
1609+ port : 80 ,
1610+ listenerProtocol : elbv2model .ProtocolHTTP ,
1611+ ipAddressType : elbv2model .IPAddressTypeIPV4 ,
1612+ routes : map [int32 ][]routeutils.RouteDescriptor {
1613+ 80 : {
1614+ & routeutils.MockRoute {
1615+ Kind : routeutils .HTTPRouteKind ,
1616+ Name : "my-route" ,
1617+ Namespace : "my-route-ns" ,
1618+ Rules : []routeutils.RouteRule {
1619+ & routeutils.MockRule {
1620+ RawRule : & gwv1.HTTPRouteRule {
1621+ Filters : []gwv1.HTTPRouteFilter {
1622+ {
1623+ Type : gwv1 .HTTPRouteFilterRequestRedirect ,
1624+ RequestRedirect : & gwv1.HTTPRequestRedirectFilter {
1625+ Scheme : awssdk .String ("HTTP" ),
1626+ StatusCode : awssdk .Int (301 ),
1627+ },
1628+ },
1629+ },
1630+ Matches : []gwv1.HTTPRouteMatch {
1631+ {
1632+ Path : & gwv1.HTTPPathMatch {
1633+ Type : (* gwv1 .PathMatchType )(awssdk .String ("PathPrefix" )),
1634+ Value : awssdk .String ("/" ),
1635+ },
1636+ },
1637+ },
1638+ },
1639+ BackendRefs : []routeutils.Backend {
1640+ {
1641+ ServiceBackend : & routeutils.ServiceBackendConfig {},
1642+ Weight : 1 ,
1643+ },
1644+ },
1645+ },
1646+ },
1647+ },
1648+ },
1649+ },
1650+ expectedRules : []* elbv2model.ListenerRuleSpec {
1651+ {
1652+ Priority : 1 ,
1653+ Actions : []elbv2model.Action {
1654+ {
1655+ Type : "redirect" ,
1656+ RedirectConfig : & elbv2model.RedirectActionConfig {
1657+ Protocol : awssdk .String ("HTTP" ),
1658+ Port : awssdk .String ("80" ),
1659+ StatusCode : "HTTP_301" ,
1660+ },
1661+ },
1662+ },
1663+ Conditions : []elbv2model.RuleCondition {
1664+ {
1665+ Field : "path-pattern" ,
1666+ PathPatternConfig : & elbv2model.PathPatternConditionConfig {
1667+ Values : []string {"/*" },
1668+ },
1669+ },
1670+ },
1671+ },
1672+ },
1673+ },
1674+ {
1675+ name : "redirect filter should result in redirect action - port specified" ,
1676+ port : 90 ,
1677+ listenerProtocol : elbv2model .ProtocolHTTP ,
1678+ ipAddressType : elbv2model .IPAddressTypeIPV4 ,
1679+ routes : map [int32 ][]routeutils.RouteDescriptor {
1680+ 90 : {
1681+ & routeutils.MockRoute {
1682+ Kind : routeutils .HTTPRouteKind ,
1683+ Name : "my-route" ,
1684+ Namespace : "my-route-ns" ,
1685+ Rules : []routeutils.RouteRule {
1686+ & routeutils.MockRule {
1687+ RawRule : & gwv1.HTTPRouteRule {
1688+ Filters : []gwv1.HTTPRouteFilter {
1689+ {
1690+ Type : gwv1 .HTTPRouteFilterRequestRedirect ,
1691+ RequestRedirect : & gwv1.HTTPRequestRedirectFilter {
1692+ Scheme : awssdk .String ("HTTP" ),
1693+ StatusCode : awssdk .Int (301 ),
1694+ Port : (* gwv1 .PortNumber )(awssdk .Int32 (900 )),
1695+ },
1696+ },
1697+ },
1698+ Matches : []gwv1.HTTPRouteMatch {
1699+ {
1700+ Path : & gwv1.HTTPPathMatch {
1701+ Type : (* gwv1 .PathMatchType )(awssdk .String ("PathPrefix" )),
1702+ Value : awssdk .String ("/" ),
1703+ },
1704+ },
1705+ },
1706+ },
1707+ BackendRefs : []routeutils.Backend {
1708+ {
1709+ ServiceBackend : & routeutils.ServiceBackendConfig {},
1710+ Weight : 1 ,
1711+ },
1712+ },
1713+ },
1714+ },
1715+ },
1716+ },
1717+ },
1718+ expectedRules : []* elbv2model.ListenerRuleSpec {
1719+ {
1720+ Priority : 1 ,
1721+ Actions : []elbv2model.Action {
1722+ {
1723+ Type : "redirect" ,
1724+ RedirectConfig : & elbv2model.RedirectActionConfig {
1725+ Protocol : awssdk .String ("HTTP" ),
1726+ Port : awssdk .String ("900" ),
15911727 StatusCode : "HTTP_301" ,
15921728 },
15931729 },
0 commit comments