@@ -131,6 +131,69 @@ func TestSyncRelatedObjects(t *testing.T) {
131131 Type : corev1 .SecretTypeOpaque ,
132132 },
133133 },
134+
135+ //////////////////////////////////////////////////////////////////////////////////////////////
136+
137+ {
138+ name : "sync referenced Secret down from kcp to the service cluster" ,
139+ workspace : "sync-referenced-secret-down" ,
140+ mainResource : crds.Crontab {
141+ ObjectMeta : metav1.ObjectMeta {
142+ Name : "my-crontab" ,
143+ Namespace : "default" ,
144+ },
145+ Spec : crds.CrontabSpec {
146+ CronSpec : "* * *" ,
147+ Image : "ubuntu:latest" ,
148+ },
149+ },
150+ relatedConfig : syncagentv1alpha1.RelatedResourceSpec {
151+ Identifier : "credentials" ,
152+ Origin : "kcp" ,
153+ Kind : "Secret" ,
154+ Source : syncagentv1alpha1.RelatedResourceSource {
155+ RelatedResourceSourceSpec : syncagentv1alpha1.RelatedResourceSourceSpec {
156+ Reference : & syncagentv1alpha1.RelatedResourceReference {
157+ Path : "metadata.name" , // irrelevant
158+ Regex : & syncagentv1alpha1.RegularExpression {
159+ Replacement : "my-credentials" ,
160+ },
161+ },
162+ },
163+ },
164+ Destination : syncagentv1alpha1.RelatedResourceDestination {
165+ RelatedResourceDestinationSpec : syncagentv1alpha1.RelatedResourceDestinationSpec {
166+ Reference : & syncagentv1alpha1.RelatedResourceReference {
167+ Path : "metadata.name" , // irrelevant
168+ Regex : & syncagentv1alpha1.RegularExpression {
169+ Replacement : "my-credentials" ,
170+ },
171+ },
172+ },
173+ },
174+ },
175+ sourceRelatedObject : corev1.Secret {
176+ ObjectMeta : metav1.ObjectMeta {
177+ Name : "my-credentials" ,
178+ Namespace : "default" ,
179+ },
180+ Data : map [string ][]byte {
181+ "password" : []byte ("hunter2" ),
182+ },
183+ Type : corev1 .SecretTypeOpaque ,
184+ },
185+
186+ expectedSyncedRelatedObject : corev1.Secret {
187+ ObjectMeta : metav1.ObjectMeta {
188+ Name : "my-credentials" ,
189+ Namespace : "synced-default" ,
190+ },
191+ Data : map [string ][]byte {
192+ "password" : []byte ("hunter2" ),
193+ },
194+ Type : corev1 .SecretTypeOpaque ,
195+ },
196+ },
134197 }
135198
136199 for _ , testcase := range testcases {
0 commit comments