diff --git a/artifactory/commands/buildtoollogin/buildtoollogin_test.go b/artifactory/commands/buildtoollogin/buildtoollogin_test.go index eb95e5160..85e0097c9 100644 --- a/artifactory/commands/buildtoollogin/buildtoollogin_test.go +++ b/artifactory/commands/buildtoollogin/buildtoollogin_test.go @@ -156,13 +156,14 @@ func TestBuildToolLoginCommand_Pipenv(t *testing.T) { } func testBuildToolLoginCommandPip(t *testing.T, buildTool project.ProjectType) { - // Retrieve the home directory and construct the pip.conf file path. - homeDir, err := os.UserHomeDir() - assert.NoError(t, err) + var pipConfFilePath string if coreutils.IsWindows() { - pipConfFilePath = filepath.Join(homeDir, "pip", "pip.ini") + pipConfFilePath = filepath.Join(os.Getenv("APPDATA"), "pip", "pip.ini") } else { + // Retrieve the home directory and construct the pip.conf file path. + homeDir, err := os.UserHomeDir() + assert.NoError(t, err) pipConfFilePath = filepath.Join(homeDir, ".config", "pip", "pip.conf") } diff --git a/artifactory/commands/utils/npmcmdutils.go b/artifactory/commands/utils/npmcmdutils.go index d21cdea8e..2c4fe43ac 100644 --- a/artifactory/commands/utils/npmcmdutils.go +++ b/artifactory/commands/utils/npmcmdutils.go @@ -103,14 +103,15 @@ func GetNpmRepositoryUrl(repositoryName, artifactoryUrl string) string { // GetNpmAuthKeyValue generates the correct authentication key and value for npm or Yarn, based on the repo URL. func GetNpmAuthKeyValue(serverDetails *config.ServerDetails, repoUrl string) (key, value string) { - keySuffix := "" - if serverDetails.GetAccessToken() != "" { + var keySuffix string + switch { + case serverDetails.GetAccessToken() != "": keySuffix = NpmConfigAuthTokenKey value = serverDetails.GetAccessToken() - } else if serverDetails.GetUser() != "" && serverDetails.GetPassword() != "" { + case serverDetails.GetUser() != "" && serverDetails.GetPassword() != "": keySuffix = NpmConfigAuthKey value = basicAuthBase64Encode(serverDetails.GetUser(), serverDetails.GetPassword()) - } else { + default: return "", "" }