@@ -14,6 +14,7 @@ import (
1414 . "github.com/onsi/gomega"
1515 "github.com/pivotal-cf/kiln/internal/carvel/models"
1616 "github.com/pivotal-cf/kiln/pkg/cargo"
17+ "github.com/pivotal-cf/kiln/pkg/proofing"
1718 "gopkg.in/yaml.v3"
1819)
1920
@@ -245,7 +246,11 @@ consumes:
245246 Expect (outMeta .Serial ).To (BeFalse ())
246247 Expect (outMeta .PropertyBlueprints ).To (HaveLen (2 ))
247248 Expect (outMeta .FormTypes ).To (HaveLen (1 ))
248- Expect (outMeta .Variables ).To (BeEmpty ())
249+ Expect (outMeta .Variables ).To (HaveLen (1 ))
250+ Expect (outMeta .Variables [0 ].Name ).To (Equal ("sample-tile-ca" ))
251+ Expect (outMeta .Variables [0 ].Type ).To (Equal ("certificate" ))
252+ Expect (outMeta .Variables [0 ].Options ).To (HaveKeyWithValue ("common_name" , "Sample Tile CA" ))
253+ Expect (outMeta .Variables [0 ].Options ).To (HaveKeyWithValue ("is_ca" , true ))
249254 Expect (outMeta .Releases ).To (HaveLen (1 ))
250255 Expect (outMeta .Releases [0 ]).To (ContainSubstring ("k8s-tile-test" ))
251256 Expect (outMeta .InstanceGroups ).To (HaveLen (0 ))
@@ -373,7 +378,7 @@ consumes:
373378 `$( property "admin_password" )` ,
374379 },
375380 FormTypes : []string {`$( form "db_props" )` },
376- Variables : []string {},
381+ Variables : []proofing. Variable {},
377382 PackageInstalls : []string {`$( package "test-install" )` },
378383 }
379384 yamlData , err := yaml .Marshal (& m )
@@ -667,4 +672,42 @@ consumes:
667672 Expect (nonEmpty ).To (Equal (5 ))
668673 })
669674 })
675+
676+ Context ("validateVariables" , func () {
677+ It ("passes for an empty list" , func () {
678+ err := validateVariables ([]proofing.Variable {})
679+ Expect (err ).NotTo (HaveOccurred ())
680+ })
681+
682+ It ("passes for a valid certificate variable" , func () {
683+ err := validateVariables ([]proofing.Variable {
684+ {
685+ Name : "/cf/diego-instance-identity-root-ca-2-6" ,
686+ Type : "certificate" ,
687+ Options : map [string ]any {
688+ "common_name" : "Diego Instance Identity Root CA" ,
689+ "is_ca" : true ,
690+ "duration" : 1095 ,
691+ },
692+ },
693+ })
694+ Expect (err ).NotTo (HaveOccurred ())
695+ })
696+
697+ It ("errors when name is empty" , func () {
698+ err := validateVariables ([]proofing.Variable {
699+ {Name : "" , Type : "certificate" },
700+ })
701+ Expect (err ).To (HaveOccurred ())
702+ Expect (err .Error ()).To (ContainSubstring ("missing required field 'name'" ))
703+ })
704+
705+ It ("errors when type is empty" , func () {
706+ err := validateVariables ([]proofing.Variable {
707+ {Name : "my-var" , Type : "" },
708+ })
709+ Expect (err ).To (HaveOccurred ())
710+ Expect (err .Error ()).To (ContainSubstring ("missing required field 'type'" ))
711+ })
712+ })
670713})
0 commit comments