Skip to content

Commit

Permalink
Fix proxy and certificates tests (#2661)
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi authored Aug 21, 2024
1 parent 3702b82 commit 9c08b29
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,8 +1542,7 @@ func TestArtifactorySelfSignedCert(t *testing.T) {
if reader != nil {
readerCloseAndAssert(t, reader)
}
_, isUrlErr := err.(*url.Error)
assert.True(t, isUrlErr, "Expected a connection failure, since reverse proxy didn't load self-signed-certs. Connection however is successful", err)
assert.ErrorContains(t, err, "certificate", "Expected a connection failure, since reverse proxy didn't load self-signed-certs. Connection however is successful")

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

// Inject client certificates, we expect the search to succeed
serverDetails.ClientCertPath = certificate.CertFile
Expand Down Expand Up @@ -1746,8 +1744,8 @@ func testArtifactoryProxy(t *testing.T, isHttps bool) {
func prepareArtifactoryUrlForProxyTest(t *testing.T) string {
rtUrl, err := url.Parse(serverDetails.ArtifactoryUrl)
assert.NoError(t, err)
rtHost, port, err := net.SplitHostPort(rtUrl.Host)
assert.NoError(t, err)
rtHost := rtUrl.Hostname()
port := rtUrl.Port()
if rtHost == "localhost" || rtHost == "127.0.0.1" {
externalIp, err := getExternalIP()
assert.NoError(t, err)
Expand All @@ -1763,8 +1761,7 @@ func checkForErrDueToMissingProxy(spec *spec.SpecFiles, t *testing.T) {
if reader != nil {
readerCloseAndAssert(t, reader)
}
_, isUrlErr := err.(*url.Error)
assert.True(t, isUrlErr, "Expected the request to fails, since the proxy is down.", err)
assert.ErrorContains(t, err, "proxy", "Expected the request to fails, since the proxy is down.", err)
}

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

0 comments on commit 9c08b29

Please sign in to comment.