@@ -2,6 +2,7 @@ package commands
22
33import (
44 "encoding/json"
5+ "github.com/jfrog/jfrog-cli-core/common/tests"
56 "testing"
67
78 "github.com/jfrog/jfrog-cli-core/utils/config"
@@ -15,7 +16,7 @@ func init() {
1516}
1617
1718func TestBasicAuth (t * testing.T ) {
18- inputDetails := createTestServerDetails ()
19+ inputDetails := tests . CreateTestServerDetails ()
1920 inputDetails .User = "admin"
2021 inputDetails .Password = "password"
2122
@@ -24,7 +25,7 @@ func TestBasicAuth(t *testing.T) {
2425}
2526
2627func TestUsernameSavedLowercase (t * testing.T ) {
27- inputDetails := createTestServerDetails ()
28+ inputDetails := tests . CreateTestServerDetails ()
2829 inputDetails .User = "ADMIN"
2930 inputDetails .Password = "password"
3031
@@ -36,7 +37,7 @@ func TestUsernameSavedLowercase(t *testing.T) {
3637func TestApiKey (t * testing.T ) {
3738 // API key is no longer allowed to be configured without providing a username.
3839 // This test is here to make sure that old configurations (with API key and no username) are still accepted.
39- inputDetails := createTestServerDetails ()
40+ inputDetails := tests . CreateTestServerDetails ()
4041 inputDetails .ApiKey = "apiKey"
4142 configAndTest (t , inputDetails , false )
4243
@@ -46,7 +47,7 @@ func TestApiKey(t *testing.T) {
4647}
4748
4849func TestArtifactorySshKey (t * testing.T ) {
49- inputDetails := createTestServerDetails ()
50+ inputDetails := tests . CreateTestServerDetails ()
5051 inputDetails .SshKeyPath = "/tmp/sshKey"
5152 inputDetails .SshPassphrase = "123456"
5253 inputDetails .ArtifactoryUrl = "ssh://localhost:1339/"
@@ -56,7 +57,7 @@ func TestArtifactorySshKey(t *testing.T) {
5657}
5758
5859func TestAccessToken (t * testing.T ) {
59- inputDetails := createTestServerDetails ()
60+ inputDetails := tests . CreateTestServerDetails ()
6061 inputDetails .AccessToken = "accessToken"
6162
6263 configAndTest (t , inputDetails , false )
@@ -65,7 +66,7 @@ func TestAccessToken(t *testing.T) {
6566
6667func TestRefreshToken (t * testing.T ) {
6768 // Import after tokens were generated.
68- inputDetails := createTestServerDetails ()
69+ inputDetails := tests . CreateTestServerDetails ()
6970 inputDetails .User = "admin"
7071 inputDetails .Password = "password"
7172 inputDetails .AccessToken = "accessToken"
@@ -82,7 +83,7 @@ func TestRefreshToken(t *testing.T) {
8283}
8384
8485func TestEmptyCredentials (t * testing.T ) {
85- configAndTest (t , createTestServerDetails (), false )
86+ configAndTest (t , tests . CreateTestServerDetails (), false )
8687}
8788
8889func TestUrls (t * testing.T ) {
@@ -123,7 +124,7 @@ func testUrls(t *testing.T, interactive bool) {
123124}
124125
125126func TestBasicAuthOnlyOption (t * testing.T ) {
126- inputDetails := createTestServerDetails ()
127+ inputDetails := tests . CreateTestServerDetails ()
127128 inputDetails .User = "admin"
128129 inputDetails .Password = "password"
129130
@@ -168,17 +169,3 @@ func configStructToString(artConfig *config.ServerDetails) string {
168169 marshaledStruct , _ := json .Marshal (* artConfig )
169170 return string (marshaledStruct )
170171}
171-
172- func createTestServerDetails () * config.ServerDetails {
173- return & config.ServerDetails {
174- Url : "http://localhost:8080" ,
175- ArtifactoryUrl : "http://localhost:8080/artifactory" ,
176- DistributionUrl : "http://localhost:8080/distribution" ,
177- XrayUrl : "http://localhost:8080/xray" ,
178- MissionControlUrl : "http://localhost:8080/mc" ,
179- PipelinesUrl : "http://localhost:8080/pipelines" ,
180- ServerId : "test" ,
181- IsDefault : false ,
182- ClientCertPath : "ClientCertPath" , ClientCertKeyPath : "ClientCertKeyPath" ,
183- }
184- }
0 commit comments