|
7 | 7 | "github.com/jfrog/jfrog-cli-core/v2/utils/config" |
8 | 8 | "github.com/jfrog/jfrog-cli-core/v2/utils/coreutils" |
9 | 9 | "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils" |
| 10 | + "github.com/jfrog/jfrog-client-go/auth" |
10 | 11 | "github.com/stretchr/testify/assert" |
11 | 12 | "os" |
12 | 13 | "path/filepath" |
@@ -119,7 +120,7 @@ func TestBuildToolLoginCommand_Yarn(t *testing.T) { |
119 | 120 | }{ |
120 | 121 | { |
121 | 122 | name: "Token Authentication", |
122 | | - accessToken: "test-token", |
| 123 | + accessToken: dummyToken, |
123 | 124 | }, |
124 | 125 | { |
125 | 126 | name: "Basic Authentication", |
@@ -201,7 +202,7 @@ func TestBuildToolLoginCommand_Pip(t *testing.T) { |
201 | 202 | }{ |
202 | 203 | { |
203 | 204 | name: "Token Authentication", |
204 | | - accessToken: "test-token", |
| 205 | + accessToken: dummyToken, |
205 | 206 | }, |
206 | 207 | { |
207 | 208 | name: "Basic Authentication", |
@@ -233,15 +234,16 @@ func TestBuildToolLoginCommand_Pip(t *testing.T) { |
233 | 234 | assert.NoError(t, err) |
234 | 235 | pipConfigContent := string(pipConfigContentBytes) |
235 | 236 |
|
236 | | - // Validate that the index URL was set correctly in pip.conf. |
237 | | - assert. Contains( t, pipConfigContent, fmt. Sprintf( "index-url = https://%s:%[email protected]/artifactory/api/pypi/test-repo/simple", testCase. user, testCase. password)) |
238 | | - |
239 | | - // Validate token-based authentication. |
240 | | - if testCase.accessToken != "" { |
241 | | - assert. Contains( t, pipConfigContent, fmt. Sprintf( "index-url = https://%[email protected]/artifactory/api/pypi/test-repo/simple", "test-token")) |
242 | | - } else if testCase.user != "" && testCase.password != "" { |
| 237 | + switch { |
| 238 | + case testCase.accessToken != "": |
| 239 | + // Validate token-based authentication. |
| 240 | + assert. Contains( t, pipConfigContent, fmt. Sprintf( "index-url = https://%s:%[email protected]/artifactory/api/pypi/test-repo/simple", auth. ExtractUsernameFromAccessToken( testCase. accessToken), testCase. accessToken)) |
| 241 | + case testCase.user != "" && testCase.password != "": |
243 | 242 | // Validate basic authentication with user and password. |
244 | 243 | assert. Contains( t, pipConfigContent, fmt. Sprintf( "index-url = https://%s:%[email protected]/artifactory/api/pypi/test-repo/simple", "myUser", "myPassword")) |
| 244 | + default: |
| 245 | + // Validate anonymous access. |
| 246 | + assert.Contains(t, pipConfigContent, "index-url = https://acme.jfrog.io/artifactory/api/pypi/test-repo/simple") |
245 | 247 | } |
246 | 248 | }) |
247 | 249 | } |
|
0 commit comments