@@ -4811,18 +4811,22 @@ func Test_defaultModelBuildTask_buildSSLRedirectConfig(t *testing.T) {
48114811 wantErr : nil ,
48124812 },
48134813 {
4814- name : "single Ingress with ssl-redirect annotation " ,
4814+ name : "single Ingress with IngressClassParam for ssl-redirect" ,
48154815 fields : fields {
48164816 ingGroup : Group {
48174817 ID : GroupID {Namespace : "ns-1" , Name : "ing-1" },
48184818 Members : []ClassifiedIngress {
48194819 {
4820+ IngClassConfig : ClassConfiguration {
4821+ IngClassParams : & v1beta1.IngressClassParams {
4822+ Spec : v1beta1.IngressClassParamsSpec {
4823+ SSLRedirectPort : "443" ,
4824+ },
4825+ },
4826+ },
48204827 Ing : & networking.Ingress {ObjectMeta : metav1.ObjectMeta {
48214828 Namespace : "ns-1" ,
48224829 Name : "ing-1" ,
4823- Annotations : map [string ]string {
4824- "alb.ingress.kubernetes.io/ssl-redirect" : "443" ,
4825- },
48264830 },
48274831 Spec : networking.IngressSpec {
48284832 Rules : []networking.IngressRule {
@@ -5155,6 +5159,199 @@ func Test_defaultModelBuildTask_buildSSLRedirectConfig(t *testing.T) {
51555159 },
51565160 wantErr : nil ,
51575161 },
5162+ {
5163+ name : "multiple Ingress with one IngressClassParam for ssl-redirect" ,
5164+ fields : fields {
5165+ ingGroup : Group {
5166+ ID : GroupID {Namespace : "ns-1" , Name : "ing-1" },
5167+ Members : []ClassifiedIngress {
5168+ {
5169+ IngClassConfig : ClassConfiguration {
5170+ IngClassParams : & v1beta1.IngressClassParams {
5171+ Spec : v1beta1.IngressClassParamsSpec {
5172+ SSLRedirectPort : "443" ,
5173+ },
5174+ },
5175+ },
5176+ Ing : & networking.Ingress {ObjectMeta : metav1.ObjectMeta {
5177+ Namespace : "ns-1" ,
5178+ Name : "ing-1" ,
5179+ Annotations : map [string ]string {},
5180+ },
5181+ Spec : networking.IngressSpec {
5182+ Rules : []networking.IngressRule {
5183+ {
5184+ Host : "app-1.example.com" ,
5185+ IngressRuleValue : networking.IngressRuleValue {
5186+ HTTP : & networking.HTTPIngressRuleValue {
5187+ Paths : []networking.HTTPIngressPath {
5188+ {
5189+ Path : "/svc-1" ,
5190+ Backend : networking.IngressBackend {
5191+ Service : & networking.IngressServiceBackend {
5192+ Name : "svc-1" ,
5193+ Port : networking.ServiceBackendPort {
5194+ Name : "http" ,
5195+ },
5196+ },
5197+ },
5198+ },
5199+ },
5200+ },
5201+ },
5202+ },
5203+ },
5204+ },
5205+ },
5206+ },
5207+ {
5208+ Ing : & networking.Ingress {ObjectMeta : metav1.ObjectMeta {
5209+ Namespace : "ns-2" ,
5210+ Name : "ing-2" ,
5211+ },
5212+ Spec : networking.IngressSpec {
5213+ Rules : []networking.IngressRule {
5214+ {
5215+ Host : "app-2.example.com" ,
5216+ IngressRuleValue : networking.IngressRuleValue {
5217+ HTTP : & networking.HTTPIngressRuleValue {
5218+ Paths : []networking.HTTPIngressPath {
5219+ {
5220+ Path : "/svc-2" ,
5221+ Backend : networking.IngressBackend {
5222+ Service : & networking.IngressServiceBackend {
5223+ Name : "svc-2" ,
5224+ Port : networking.ServiceBackendPort {
5225+ Name : "http" ,
5226+ },
5227+ },
5228+ },
5229+ },
5230+ },
5231+ },
5232+ },
5233+ },
5234+ },
5235+ },
5236+ },
5237+ },
5238+ },
5239+ },
5240+ },
5241+ args : args {
5242+ listenPortConfigByPort : map [int32 ]listenPortConfig {
5243+ 80 : {
5244+ protocol : elbv2model .ProtocolHTTP ,
5245+ },
5246+ 443 : {
5247+ protocol : elbv2model .ProtocolHTTPS ,
5248+ },
5249+ },
5250+ },
5251+ want : & SSLRedirectConfig {
5252+ SSLPort : 443 ,
5253+ StatusCode : "HTTP_301" ,
5254+ },
5255+ wantErr : nil ,
5256+ },
5257+ {
5258+ name : "multiple Ingress with SSLRedirectPort defined by both annotation and IngressClassParams" ,
5259+ fields : fields {
5260+ ingGroup : Group {
5261+ ID : GroupID {Namespace : "ns-1" , Name : "ing-1" },
5262+ Members : []ClassifiedIngress {
5263+ {
5264+ IngClassConfig : ClassConfiguration {
5265+ IngClassParams : & v1beta1.IngressClassParams {
5266+ Spec : v1beta1.IngressClassParamsSpec {
5267+ SSLRedirectPort : "443" ,
5268+ },
5269+ },
5270+ },
5271+ Ing : & networking.Ingress {ObjectMeta : metav1.ObjectMeta {
5272+ Namespace : "ns-1" ,
5273+ Name : "ing-1" ,
5274+ Annotations : map [string ]string {},
5275+ },
5276+ Spec : networking.IngressSpec {
5277+ Rules : []networking.IngressRule {
5278+ {
5279+ Host : "app-1.example.com" ,
5280+ IngressRuleValue : networking.IngressRuleValue {
5281+ HTTP : & networking.HTTPIngressRuleValue {
5282+ Paths : []networking.HTTPIngressPath {
5283+ {
5284+ Path : "/svc-1" ,
5285+ Backend : networking.IngressBackend {
5286+ Service : & networking.IngressServiceBackend {
5287+ Name : "svc-1" ,
5288+ Port : networking.ServiceBackendPort {
5289+ Name : "http" ,
5290+ },
5291+ },
5292+ },
5293+ },
5294+ },
5295+ },
5296+ },
5297+ },
5298+ },
5299+ },
5300+ },
5301+ },
5302+ {
5303+ Ing : & networking.Ingress {ObjectMeta : metav1.ObjectMeta {
5304+ Namespace : "ns-2" ,
5305+ Name : "ing-2" ,
5306+ Annotations : map [string ]string {
5307+ "alb.ingress.kubernetes.io/ssl-redirect" : "443" ,
5308+ },
5309+ },
5310+ Spec : networking.IngressSpec {
5311+ Rules : []networking.IngressRule {
5312+ {
5313+ Host : "app-2.example.com" ,
5314+ IngressRuleValue : networking.IngressRuleValue {
5315+ HTTP : & networking.HTTPIngressRuleValue {
5316+ Paths : []networking.HTTPIngressPath {
5317+ {
5318+ Path : "/svc-2" ,
5319+ Backend : networking.IngressBackend {
5320+ Service : & networking.IngressServiceBackend {
5321+ Name : "svc-2" ,
5322+ Port : networking.ServiceBackendPort {
5323+ Name : "http" ,
5324+ },
5325+ },
5326+ },
5327+ },
5328+ },
5329+ },
5330+ },
5331+ },
5332+ },
5333+ },
5334+ },
5335+ },
5336+ },
5337+ },
5338+ },
5339+ args : args {
5340+ listenPortConfigByPort : map [int32 ]listenPortConfig {
5341+ 80 : {
5342+ protocol : elbv2model .ProtocolHTTP ,
5343+ },
5344+ 443 : {
5345+ protocol : elbv2model .ProtocolHTTPS ,
5346+ },
5347+ },
5348+ },
5349+ want : & SSLRedirectConfig {
5350+ SSLPort : 443 ,
5351+ StatusCode : "HTTP_301" ,
5352+ },
5353+ wantErr : nil ,
5354+ },
51585355 {
51595356 name : "multiple Ingress with same ssl-redirect annotation" ,
51605357 fields : fields {
0 commit comments