Skip to content

Commit bb0c982

Browse files
committed
Adapting setupRegistryServer to be able to use https with the docker
registryClient Signed-off-by: Soule BA <[email protected]>
1 parent 5fbe573 commit bb0c982

File tree

9 files changed

+56
-88
lines changed

9 files changed

+56
-88
lines changed

api/v1beta2/helmrepository_types.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ type HelmRepositorySpec struct {
8787
// +optional
8888
Timeout *metav1.Duration `json:"timeout,omitempty"`
8989

90-
// InsecureSkipTLSVerify skips the validation of the TLS certificate of the
91-
// OCI registry endpoint.
92-
// +optional
93-
InsecureSkipTLSVerify bool `json:"insecureSkipTLSverify,omitempty"`
94-
9590
// Suspend tells the controller to suspend the reconciliation of this
9691
// HelmRepository.
9792
// +optional

docs/api/v1beta2/source.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -861,19 +861,6 @@ Its default value is 60s.</p>
861861
</tr>
862862
<tr>
863863
<td>
864-
<code>insecureSkipTLSverify</code><br>
865-
<em>
866-
bool
867-
</em>
868-
</td>
869-
<td>
870-
<em>(Optional)</em>
871-
<p>InsecureSkipTLSverify skips the validation of the TLS certificate of the
872-
OCI registry endpoint.</p>
873-
</td>
874-
</tr>
875-
<tr>
876-
<td>
877864
<code>suspend</code><br>
878865
<em>
879866
bool
@@ -2558,19 +2545,6 @@ Its default value is 60s.</p>
25582545
</tr>
25592546
<tr>
25602547
<td>
2561-
<code>insecureSkipTLSverify</code><br>
2562-
<em>
2563-
bool
2564-
</em>
2565-
</td>
2566-
<td>
2567-
<em>(Optional)</em>
2568-
<p>InsecureSkipTLSverify skips the validation of the TLS certificate of the
2569-
OCI registry endpoint.</p>
2570-
</td>
2571-
</tr>
2572-
<tr>
2573-
<td>
25742548
<code>suspend</code><br>
25752549
<em>
25762550
bool

go.mod

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ require (
4040
github.com/fluxcd/pkg/tar v0.2.0
4141
github.com/fluxcd/pkg/testserver v0.4.0
4242
github.com/fluxcd/pkg/version v0.2.2
43+
<<<<<<< HEAD
4344
github.com/fluxcd/source-controller/api v1.0.0
45+
=======
46+
github.com/fluxcd/source-controller/api v1.0.0-rc.5
47+
github.com/foxcpp/go-mockdns v1.0.0
48+
>>>>>>> 4e0d792 (Adapting setupRegistryServer to be able to use https with the docker)
4449
github.com/go-git/go-billy/v5 v5.4.1
4550
github.com/go-git/go-git/v5 v5.8.1
4651
github.com/go-logr/logr v1.2.4
@@ -251,6 +256,7 @@ require (
251256
github.com/mattn/go-isatty v0.0.17 // indirect
252257
github.com/mattn/go-runewidth v0.0.14 // indirect
253258
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
259+
github.com/miekg/dns v1.1.50 // indirect
254260
github.com/miekg/pkcs11 v1.1.1 // indirect
255261
github.com/minio/md5-simd v1.1.2 // indirect
256262
github.com/minio/sha256-simd v1.0.1 // indirect

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ github.com/fluxcd/pkg/testserver v0.4.0/go.mod h1:gjOKX41okmrGYOa4oOF2fiLedDAfPo
418418
github.com/fluxcd/pkg/version v0.2.2 h1:ZpVXECeLA5hIQMft11iLp6gN3cKcz6UNuVTQPw/bRdI=
419419
github.com/fluxcd/pkg/version v0.2.2/go.mod h1:NGnh/no8S6PyfCDxRFrPY3T5BUnqP48MxfxNRU0z8C0=
420420
github.com/foxcpp/go-mockdns v1.0.0 h1:7jBqxd3WDWwi/6WhDvacvH1XsN3rOLXyHM1uhvIx6FI=
421+
github.com/foxcpp/go-mockdns v1.0.0/go.mod h1:lgRN6+KxQBawyIghpnl5CezHFGS9VLzvtVlwxvzXTQ4=
421422
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k=
422423
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
423424
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
@@ -862,7 +863,9 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
862863
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
863864
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
864865
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
866+
github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
865867
github.com/miekg/dns v1.1.50 h1:DQUfb9uc6smULcREF09Uc+/Gd46YWqJd5DbpPE9xkcA=
868+
github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
866869
github.com/miekg/pkcs11 v1.0.3-0.20190429190417-a667d056470f/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
867870
github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU=
868871
github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
@@ -1261,6 +1264,7 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
12611264
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
12621265
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
12631266
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
1267+
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
12641268
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
12651269
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
12661270
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -1341,6 +1345,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
13411345
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
13421346
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
13431347
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
1348+
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
13441349
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
13451350
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
13461351
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -1367,6 +1372,7 @@ golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLd
13671372
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
13681373
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
13691374
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
1375+
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
13701376
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
13711377
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
13721378
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
@@ -1431,6 +1437,8 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
14311437
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14321438
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14331439
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1440+
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1441+
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14341442
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14351443
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
14361444
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1549,6 +1557,7 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw
15491557
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
15501558
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
15511559
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
1560+
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15521561
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15531562
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
15541563
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@@ -1591,6 +1600,7 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
15911600
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
15921601
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
15931602
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
1603+
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
15941604
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
15951605
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
15961606
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=

internal/controller/helmchart_controller_test.go

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,16 +2201,15 @@ func TestHelmChartReconciler_reconcileSourceFromOCI_authStrategy(t *testing.T) {
22012201
}
22022202

22032203
tests := []struct {
2204-
name string
2205-
url string
2206-
registryOpts registryOptions
2207-
secretOpts secretOptions
2208-
insecureSkipTLSVerify bool
2209-
provider string
2210-
providerImg string
2211-
want sreconcile.Result
2212-
wantErr bool
2213-
assertConditions []metav1.Condition
2204+
name string
2205+
url string
2206+
registryOpts registryOptions
2207+
secretOpts secretOptions
2208+
provider string
2209+
providerImg string
2210+
want sreconcile.Result
2211+
wantErr bool
2212+
assertConditions []metav1.Condition
22142213
}{
22152214
{
22162215
name: "HTTP without basic auth",
@@ -2306,22 +2305,6 @@ func TestHelmChartReconciler_reconcileSourceFromOCI_authStrategy(t *testing.T) {
23062305
*conditions.UnknownCondition(meta.ReadyCondition, meta.ProgressingReason, "building artifact: pulled 'helmchart' chart with version '0.1.0'"),
23072306
},
23082307
},
2309-
{
2310-
name: "HTTPS With InsecureSkipTLSVerify",
2311-
want: sreconcile.ResultSuccess,
2312-
registryOpts: registryOptions{
2313-
withBasicAuth: true,
2314-
},
2315-
secretOpts: secretOptions{
2316-
username: testRegistryUsername,
2317-
password: testRegistryPassword,
2318-
},
2319-
insecureSkipTLSVerify: true,
2320-
assertConditions: []metav1.Condition{
2321-
*conditions.TrueCondition(meta.ReconcilingCondition, meta.ProgressingReason, "building artifact: pulled 'helmchart' chart with version '0.1.0'"),
2322-
*conditions.UnknownCondition(meta.ReadyCondition, meta.ProgressingReason, "building artifact: pulled 'helmchart' chart with version '0.1.0'"),
2323-
},
2324-
},
23252308
}
23262309

23272310
for _, tt := range tests {
@@ -2368,8 +2351,6 @@ func TestHelmChartReconciler_reconcileSourceFromOCI_authStrategy(t *testing.T) {
23682351
repo.Spec.URL = tt.providerImg
23692352
}
23702353

2371-
repo.Spec.InsecureSkipTLSVerify = tt.insecureSkipTLSVerify
2372-
23732354
var secret *corev1.Secret
23742355
if tt.secretOpts.username != "" && tt.secretOpts.password != "" {
23752356
secret = &corev1.Secret{

internal/controller/helmrepository_controller.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,6 @@ func (r *HelmRepositoryReconciler) reconcileSource(ctx context.Context, sp *patc
413413
}
414414
}
415415

416-
if obj.Spec.InsecureSkipTLSVerify {
417-
tlsConfig.InsecureSkipVerify = true
418-
}
419-
420416
// Construct Helm chart repository with options and download index
421417
newChartRepo, err := repository.NewChartRepository(obj.Spec.URL, "", r.Getters, clientOpts.TlsConfig, clientOpts.GetterOpts...)
422418
if err != nil {

internal/controller/helmrepository_controller_oci.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,6 @@ func (r *HelmRepositoryOCIReconciler) reconcile(ctx context.Context, sp *patch.S
350350
}
351351
}
352352

353-
if tlsConfig == nil {
354-
tlsConfig = &tls.Config{}
355-
}
356-
357-
tlsConfig.InsecureSkipVerify = obj.Spec.InsecureSkipTLSVerify
358-
359353
loginOpt, err := makeLoginOption(authenticator, keychain, obj.Spec.URL)
360354
if err != nil {
361355
conditions.MarkFalse(obj, meta.ReadyCondition, sourcev1.AuthenticationFailedReason, err.Error())

internal/controller/helmrepository_controller_oci_test.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ func TestHelmRepositoryOCIReconciler_authStrategy(t *testing.T) {
172172
url string
173173
registryOpts registryOptions
174174
secretOpts secretOptions
175-
insecureSkipTLSVerify bool
176175
provider string
177176
providerImg string
178177
want ctrl.Result
@@ -272,21 +271,6 @@ func TestHelmRepositoryOCIReconciler_authStrategy(t *testing.T) {
272271
*conditions.TrueCondition(meta.ReadyCondition, meta.SucceededReason, "Helm repository is ready"),
273272
},
274273
},
275-
{
276-
name: "HTTPS With InsecureSkipTLSVerify",
277-
want: ctrl.Result{RequeueAfter: interval},
278-
registryOpts: registryOptions{
279-
withBasicAuth: true,
280-
},
281-
secretOpts: secretOptions{
282-
username: testRegistryUsername,
283-
password: testRegistryPassword,
284-
},
285-
insecureSkipTLSVerify: true,
286-
assertConditions: []metav1.Condition{
287-
*conditions.TrueCondition(meta.ReadyCondition, meta.SucceededReason, "Helm repository is ready"),
288-
},
289-
},
290274
}
291275

292276
for _, tt := range tests {
@@ -325,8 +309,6 @@ func TestHelmRepositoryOCIReconciler_authStrategy(t *testing.T) {
325309
obj.Spec.URL = tt.providerImg
326310
}
327311

328-
obj.Spec.InsecureSkipTLSVerify = tt.insecureSkipTLSVerify
329-
330312
var secret *corev1.Secret
331313
if tt.secretOpts.username != "" && tt.secretOpts.password != "" {
332314
secret = &corev1.Secret{

internal/controller/suite_test.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ import (
2222
"fmt"
2323
"io"
2424
"math/rand"
25+
"net"
2526
"os"
2627
"path/filepath"
2728
"testing"
2829
"time"
2930

31+
"github.com/foxcpp/go-mockdns"
3032
"github.com/phayes/freeport"
3133
"github.com/sirupsen/logrus"
3234
"golang.org/x/crypto/bcrypt"
@@ -114,6 +116,8 @@ type registryClientTestServer struct {
114116
registryHost string
115117
workspaceDir string
116118
registryClient *helmreg.Client
119+
// A mock DNS server needed for TLS connection testing.
120+
srv *mockdns.Server
117121
}
118122

119123
type registryOptions struct {
@@ -148,8 +152,25 @@ func setupRegistryServer(ctx context.Context, workspaceDir string, opts registry
148152
if err != nil {
149153
return nil, fmt.Errorf("failed to get free port: %s", err)
150154
}
151-
152155
server.registryHost = fmt.Sprintf("localhost:%d", port)
156+
if opts.withTLS {
157+
// docker `MatchLocalhost` is a host match function which returns true for
158+
// localhost, and is used to enforce http for localhost requests."
159+
// That function does not handle matching of ip addresses in octal,
160+
// decimal or hex form.
161+
server.registryHost = fmt.Sprintf("0x7f000001:%d", port)
162+
// As of Go 1.20, Go may lookup "0x7f000001" as a DNS entry and fail.
163+
// Using a mock DNS server to handle the address.
164+
server.srv, err = mockdns.NewServer(map[string]mockdns.Zone{
165+
"0x7f000001.": {
166+
A: []string{"127.0.0.1"},
167+
},
168+
}, false)
169+
if err != nil {
170+
return nil, fmt.Errorf("failed to create mock DNS server: %s", err)
171+
}
172+
server.srv.PatchNet(net.DefaultResolver)
173+
}
153174
config.HTTP.Addr = fmt.Sprintf("127.0.0.1:%d", port)
154175
config.HTTP.DrainTimeout = time.Duration(10) * time.Second
155176
config.Storage = map[string]configuration.Parameters{"inmemory": map[string]interface{}{}}
@@ -178,6 +199,7 @@ func setupRegistryServer(ctx context.Context, workspaceDir string, opts registry
178199
if opts.withTLS {
179200
config.HTTP.TLS.Certificate = "testdata/certs/server.pem"
180201
config.HTTP.TLS.Key = "testdata/certs/server-key.pem"
202+
config.HTTP.TLS.ClientCAs = []string{"testdata/certs/ca.pem"}
181203
}
182204

183205
// setup logger options
@@ -198,6 +220,13 @@ func setupRegistryServer(ctx context.Context, workspaceDir string, opts registry
198220
return server, nil
199221
}
200222

223+
func (s *registryClientTestServer) stopSrv() {
224+
if s.srv != nil {
225+
mockdns.UnpatchNet(net.DefaultResolver)
226+
s.srv.Close()
227+
}
228+
}
229+
201230
func TestMain(m *testing.M) {
202231
initTestTLS()
203232

@@ -234,6 +263,7 @@ func TestMain(m *testing.M) {
234263
if err != nil {
235264
panic(fmt.Sprintf("Failed to create a test registry server: %v", err))
236265
}
266+
defer testRegistryServer.stopSrv()
237267

238268
if err := (&GitRepositoryReconciler{
239269
Client: testEnv,

0 commit comments

Comments
 (0)