@@ -359,7 +359,7 @@ var _ = Describe("APIRule Conversion", func() {
359
359
360
360
})
361
361
362
- It ("should store rules in annotation" , func () {
362
+ It ("should store spec in annotation" , func () {
363
363
var headerConfig , cookieConfig runtime.RawExtension
364
364
_ = convertOverJson (map [string ]string {
365
365
"header1" : "value1" ,
@@ -369,9 +369,19 @@ var _ = Describe("APIRule Conversion", func() {
369
369
"cookie1" : "value2" ,
370
370
}, & cookieConfig )
371
371
372
+ namespace := "test-namespace"
373
+ var port uint32 = 8080
374
+
372
375
apiRuleV1beta1 := v1beta1.APIRule {
373
376
Status : testV1StatusOK ,
374
377
Spec : v1beta1.APIRuleSpec {
378
+ Host : & host1string ,
379
+ Gateway : ptr .To ("gateway-test" ),
380
+ Service : & v1beta1.Service {
381
+ Name : ptr .To ("service-test" ),
382
+ Port : & port ,
383
+ Namespace : & namespace ,
384
+ },
375
385
Rules : []v1beta1.Rule {
376
386
{
377
387
Path : "/path1" ,
@@ -407,7 +417,7 @@ var _ = Describe("APIRule Conversion", func() {
407
417
408
418
// then
409
419
Expect (err ).ToNot (HaveOccurred ())
410
- Expect (apiRuleV2alpha1 .Annotations ["gateway.kyma-project.io/v1beta1-rules " ]).To (BeEquivalentTo (`[{"path":"/path1","service":{"name":"service","port":null},"methods":["GET","POST"],"accessStrategies":[{"handler":"jwt"}],"mutators":[{"handler":"header","config":{"header1":"value1"}},{"handler":"cookie","config":{"cookie1":"value2"}}]}]` ))
420
+ Expect (apiRuleV2alpha1 .Annotations ["gateway.kyma-project.io/v1beta1-spec " ]).To (BeEquivalentTo (`{"host":"host1","service":{"name":"service-test","namespace":"test-namespace","port":8080},"gateway":"gateway-test","rules": [{"path":"/path1","service":{"name":"service","port":null},"methods":["GET","POST"],"accessStrategies":[{"handler":"jwt"}],"mutators":[{"handler":"header","config":{"header1":"value1"}},{"handler":"cookie","config":{"cookie1":"value2"}}]}]} ` ))
411
421
})
412
422
413
423
})
@@ -808,13 +818,13 @@ var _ = Describe("APIRule Conversion", func() {
808
818
}
809
819
Expect (correctMutators ).To (Equal (2 ))
810
820
})
811
- It ("should convert rules from annotation" , func () {
821
+ It ("should convert spec from annotation" , func () {
812
822
// given
813
823
apiRuleV2alpha1 := v2alpha1.APIRule {
814
824
ObjectMeta : metav1.ObjectMeta {
815
825
Annotations : map [string ]string {
816
826
"gateway.kyma-project.io/original-version" : "v1beta1" ,
817
- "gateway.kyma-project.io/v1beta1-rules " : `spec: [{"path":"/path1","service":{"name":"service","port":null},"methods":["GET","POST"],"accessStrategies":[{"handler":"jwt"}],"mutators":[{"handler":"header","config":{"header1":"value1"}},{"handler":"cookie","config":{"cookie1":"value2"}}]}]` ,
827
+ "gateway.kyma-project.io/v1beta1-spec " : `{"host":"host1","service":{"name":"service-test","namespace":"test-namespace","port":8080},"gateway":"gateway-test","rules": [{"path":"/path1","service":{"name":"service","port":null},"methods":["GET","POST"],"accessStrategies":[{"handler":"jwt"}],"mutators":[{"handler":"header","config":{"header1":"value1"}},{"handler":"cookie","config":{"cookie1":"value2"}}]}]} ` ,
818
828
},
819
829
},
820
830
}
@@ -823,10 +833,18 @@ var _ = Describe("APIRule Conversion", func() {
823
833
824
834
// when
825
835
err := apiRuleBeta1 .ConvertFrom (& apiRuleV2alpha1 )
826
-
836
+ var port uint32 = 8080
827
837
// then
828
838
Expect (err ).ToNot (HaveOccurred ())
829
839
Expect (apiRuleBeta1 .Spec .Rules ).To (HaveLen (1 ))
840
+ Expect (apiRuleBeta1 .Spec .Host ).To (Equal (ptr .To (host1string )))
841
+ Expect (apiRuleBeta1 .Spec .Service ).To (Equal (ptr .To (v1beta1.Service {
842
+ Name : ptr .To ("service-test" ),
843
+ Namespace : ptr .To ("test-namespace" ),
844
+ Port : & port ,
845
+ })))
846
+ Expect (* apiRuleBeta1 .Spec .Gateway ).To (Equal ("gateway-test" ))
847
+ Expect (apiRuleBeta1 .Spec .Rules [0 ].Path ).To (Equal ("/path1" ))
830
848
})
831
849
})
832
850
})
0 commit comments