@@ -81,50 +81,58 @@ func TestSetArtifactoryAsResolutionServer(t *testing.T) {
8181}
8282
8383func TestGetArtifactoryRemoteRepoUrl (t * testing.T ) {
84+ // testFakeToken is a fake test token for unit testing only - NOT a real secret
85+ // #nosec G101 -- This is a fake test token with no real credentials.
86+ testFakeToken := "fake-test-token-12345" //nolint:gosec
8487 server := & config.ServerDetails {
8588 ArtifactoryUrl : "https://server.com/artifactory" ,
86- AccessToken : "eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA" ,
89+ User : "testuser" ,
90+ AccessToken : testFakeToken ,
8791 }
8892 repoName := "test-repo"
8993 repoUrl , err := GetArtifactoryRemoteRepoUrl (server , repoName , GoProxyUrlParams {})
9094 assert .NoError (t , err )
91- assert .Equal (t , "https://test:eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA @server.com/artifactory/api/go/test-repo" , repoUrl )
95+ assert .Equal (t , "https://testuser:" + testFakeToken + " @server.com/artifactory/api/go/test-repo" , repoUrl )
9296}
9397
9498func TestGetArtifactoryApiUrl (t * testing.T ) {
99+ // testFakeToken is a fake test token for unit testing only - NOT a real secret
100+ // #nosec G101 -- This is a fake test token with no real credentials.
101+ testFakeToken := "fake-test-token-12345" //nolint:gosec
102+
95103 details := auth .NewArtifactoryDetails ()
96104 details .SetUrl ("https://test.com/artifactory/" )
97105
98106 // Test username and password
99107 details .SetUser ("frog" )
100- details .SetPassword ("passfrog " )
108+ details .SetPassword ("testpass " )
101109 url , err := getArtifactoryApiUrl ("test-repo" , details , GoProxyUrlParams {})
102110 assert .NoError (t , err )
103- assert .Equal (t , "https://frog:passfrog @test.com/artifactory/api/go/test-repo" , url )
111+ assert .Equal (t , "https://frog:testpass @test.com/artifactory/api/go/test-repo" , url )
104112
105113 // Test username and password with EndpointPrefix and direct
106114 details .SetUser ("frog" )
107- details .SetPassword ("passfrog " )
115+ details .SetPassword ("testpass " )
108116 url , err = getArtifactoryApiUrl ("test-repo" , details , GoProxyUrlParams {EndpointPrefix : "test" , Direct : true })
109117 assert .NoError (t , err )
110- assert .Equal (t , "https://frog:passfrog @test.com/artifactory/test/api/go/test-repo|direct" , url )
118+ assert .Equal (t , "https://frog:testpass @test.com/artifactory/test/api/go/test-repo|direct" , url )
111119
112120 // Test access token
113121 // Set fake access token with username "test"
114- details .SetUser ("" )
115- details .SetAccessToken ("eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA" )
122+ details .SetUser ("testuser " )
123+ details .SetAccessToken (testFakeToken )
116124 url , err = getArtifactoryApiUrl ("test-repo" , details , GoProxyUrlParams {})
117125 assert .NoError (t , err )
118- assert .Equal (t , "https://test:eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA @test.com/artifactory/api/go/test-repo" , url )
126+ assert .Equal (t , "https://testuser:" + testFakeToken + " @test.com/artifactory/api/go/test-repo" , url )
119127
120128 // Test access token with username
121129 // Set fake access token with username "test"
122130 // Expect username to be "frog"
123131 details .SetUser ("frog" )
124- details .SetAccessToken ("eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA" )
132+ details .SetAccessToken (testFakeToken )
125133 url , err = getArtifactoryApiUrl ("test-repo" , details , GoProxyUrlParams {})
126134 assert .NoError (t , err )
127- assert .Equal (t , "https://frog:eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA @test.com/artifactory/api/go/test-repo" , url )
135+ assert .Equal (t , "https://frog:" + testFakeToken + " @test.com/artifactory/api/go/test-repo" , url )
128136}
129137
130138func TestGoProxyUrlParams_BuildUrl (t * testing.T ) {
0 commit comments