From ef6b7af06a73b3c1b8481c42cd32f4bc7993d314 Mon Sep 17 00:00:00 2001 From: andreasvikke Date: Tue, 25 Aug 2026 13:26:58 +0200 Subject: [PATCH] feat: add integration test for new JFROG_CLI_CERTS_DIR env --- artifactory_test.go | 26 ++++++++++++++++++++++++++ go.mod | 2 ++ go.sum | 2 -- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/artifactory_test.go b/artifactory_test.go index 18184cc7d..9d1537353 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -1635,6 +1635,32 @@ func TestArtifactorySelfSignedCert(t *testing.T) { assert.NoError(t, err) readerCloseAndAssert(t, reader) + // Remove the certificates from CLI security dir before testing custom cert dir location + defer clientTestUtils.RemoveAndAssert(t, filepath.Join(certsPath, certificate.KeyFile)) + defer clientTestUtils.RemoveAndAssert(t, filepath.Join(certsPath, certificate.CertFile)) + + // Create a new temp dir for certificates and set the CertsDir env variable + tempCertsDirPath, createTempDirCallback := coretests.CreateTempDirWithCallbackAndAssert(t) + defer createTempDirCallback() + setEnvCallBack = clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.CertsDir, tempCertsDirPath) + defer setEnvCallBack() + + // Check the certificate dir have moved to the new temp dir location + certsPath, err = coreutils.GetJfrogCertsDir() + assert.NoError(t, err) + assert.Equal(t, tempCertsDirPath, certsPath) + + // Copy the server certificates to the custom CLI certificate dir and run again. We expect the command to succeed. + err = biutils.CopyFile(certsPath, certificate.KeyFile) + assert.NoError(t, err) + err = biutils.CopyFile(certsPath, certificate.CertFile) + assert.NoError(t, err) + searchCmd = generic.NewSearchCommand() + searchCmd.SetServerDetails(serverDetails).SetSpec(fileSpec) + reader, err = searchCmd.Search() + assert.NoError(t, err) + readerCloseAndAssert(t, reader) + serverDetails.ArtifactoryUrl = artAuth.GetUrl() cleanArtifactoryTest() } diff --git a/go.mod b/go.mod index 0cc5a2a4f..c2884b7d2 100644 --- a/go.mod +++ b/go.mod @@ -249,3 +249,5 @@ require ( // replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.54.2-0.20251007084958-5eeaa42c31a6 // replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260818062137-18e36e626c63 + +replace github.com/jfrog/jfrog-cli-core/v2 => ../jfrog-cli-core diff --git a/go.sum b/go.sum index 4abd40adb..13968ddc2 100644 --- a/go.sum +++ b/go.sum @@ -404,8 +404,6 @@ github.com/jfrog/jfrog-cli-application v1.0.2-0.20260817110546-58a0a6fe6fc9 h1:g github.com/jfrog/jfrog-cli-application v1.0.2-0.20260817110546-58a0a6fe6fc9/go.mod h1:p8yLtbmCxxQucIbLZKnWu0F+EDtj6NLXbRQCEK/nb6o= github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260819070735-a590327f2489 h1:FxdCh8hxWuboF+q6okuJimF96aTFNSTXlIi0Blwp3Uo= github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260819070735-a590327f2489/go.mod h1:1ACZmkzA38Si48i9f052M4BDLfti02lHUfL/f853Ny0= -github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260814125750-77deb9f6259c h1:H77lybOSbPe2T70+l0Q9zy7eXWLbLj4ph2R2Svahf5A= -github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260814125750-77deb9f6259c/go.mod h1:gf7aUg/G9JyltCNhwMD5RVEsFzUCKPWKXRcTXSqMYBk= github.com/jfrog/jfrog-cli-evidence v0.11.0 h1:LcRgu2ynNu47/Za1vbwn0jHiOvSzgCcCPvi7S8/rotM= github.com/jfrog/jfrog-cli-evidence v0.11.0/go.mod h1:I83k7IH/cmMh00LyZOp13jctj8/pPKVHSAlu7GMJgwI= github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20260618062042-6053ab368cab h1:Zn/qB8LYhSu82YDtbqXwErN1RPHTHe/a3gQY6Ti/OBE=