Skip to content

Commit 9c08b29

Browse files
authored
Fix proxy and certificates tests (#2661)
1 parent 3702b82 commit 9c08b29

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

artifactory_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,8 +1542,7 @@ func TestArtifactorySelfSignedCert(t *testing.T) {
15421542
if reader != nil {
15431543
readerCloseAndAssert(t, reader)
15441544
}
1545-
_, isUrlErr := err.(*url.Error)
1546-
assert.True(t, isUrlErr, "Expected a connection failure, since reverse proxy didn't load self-signed-certs. Connection however is successful", err)
1545+
assert.ErrorContains(t, err, "certificate", "Expected a connection failure, since reverse proxy didn't load self-signed-certs. Connection however is successful")
15471546

15481547
// Set insecureTls to true and run again. We expect the command to succeed.
15491548
serverDetails.InsecureTls = true
@@ -1605,8 +1604,7 @@ func TestArtifactoryClientCert(t *testing.T) {
16051604
if reader != nil {
16061605
readerCloseAndAssert(t, reader)
16071606
}
1608-
_, isUrlErr := err.(*url.Error)
1609-
assert.True(t, isUrlErr, "Expected a connection failure, since client did not provide a client certificate. Connection however is successful")
1607+
assert.ErrorContains(t, err, "certificate", "Expected a connection failure, since client did not provide a client certificate. Connection however is successful")
16101608

16111609
// Inject client certificates, we expect the search to succeed
16121610
serverDetails.ClientCertPath = certificate.CertFile
@@ -1746,8 +1744,8 @@ func testArtifactoryProxy(t *testing.T, isHttps bool) {
17461744
func prepareArtifactoryUrlForProxyTest(t *testing.T) string {
17471745
rtUrl, err := url.Parse(serverDetails.ArtifactoryUrl)
17481746
assert.NoError(t, err)
1749-
rtHost, port, err := net.SplitHostPort(rtUrl.Host)
1750-
assert.NoError(t, err)
1747+
rtHost := rtUrl.Hostname()
1748+
port := rtUrl.Port()
17511749
if rtHost == "localhost" || rtHost == "127.0.0.1" {
17521750
externalIp, err := getExternalIP()
17531751
assert.NoError(t, err)
@@ -1763,8 +1761,7 @@ func checkForErrDueToMissingProxy(spec *spec.SpecFiles, t *testing.T) {
17631761
if reader != nil {
17641762
readerCloseAndAssert(t, reader)
17651763
}
1766-
_, isUrlErr := err.(*url.Error)
1767-
assert.True(t, isUrlErr, "Expected the request to fails, since the proxy is down.", err)
1764+
assert.ErrorContains(t, err, "proxy", "Expected the request to fails, since the proxy is down.", err)
17681765
}
17691766

17701767
func checkIfServerIsUp(port, proxyScheme string, useClientCerts bool) error {

0 commit comments

Comments
 (0)