Skip to content

Commit 122867d

Browse files
committed
fix(atls): apply updated certificates when TLS secrets change
1 parent 2bab77a commit 122867d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

internal/controller/apisixtls_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (r *ApisixTlsReconciler) listApisixTlsForSecret(ctx context.Context, obj cl
236236
ctx,
237237
r.Client,
238238
r.Log,
239-
&apiv2.ApisixConsumerList{},
239+
&apiv2.ApisixTlsList{},
240240
client.MatchingFields{
241241
indexer.SecretIndexRef: indexer.GenIndexKey(secret.GetNamespace(), secret.GetName()),
242242
},

test/e2e/crds/v2/tls.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,27 @@ spec:
175175
WithHost("api6.com").
176176
Expect().
177177
Status(200)
178+
179+
err = s.NewKubeTlsSecret("test-tls-secret", framework.TestCert, framework.TestKey)
180+
Expect(err).NotTo(HaveOccurred(), "updating TLS secret")
181+
182+
Eventually(func() error {
183+
tlss, err := s.DefaultDataplaneResource().SSL().List(context.Background())
184+
if err != nil {
185+
return err
186+
}
187+
if len(tlss) != 1 {
188+
return fmt.Errorf("expected 1 tls, got %d", len(tls))
189+
}
190+
certs := tlss[0].Certificates
191+
if len(certs) != 1 {
192+
return fmt.Errorf("expected 1 certificate, got %d", len(certs))
193+
}
194+
if !strings.Contains(certs[0].Certificate, framework.TestCert) {
195+
return fmt.Errorf("certificate not updated yet")
196+
}
197+
return nil
198+
}).WithTimeout(30*time.Second).ProbeEvery(1*time.Second).ShouldNot(HaveOccurred(), "tls secret updated in dataplane")
178199
})
179200

180201
It("ApisixTls with mTLS test", func() {

0 commit comments

Comments
 (0)