While trying to clone a repo with jgit, passing wrong username to UsernamePasswordCredentialsProvider
actually does not result in any error, which is very surprising to me. Why is it working? How is the repo being cloned when the username is incorrect?
Tried it with version 4.6.0.201612231935-r and 6.5.0.202303070854-r
I have a function that is trying to clone a git repo, given a username and access token. While trying to handle exceptions for edge cases, I noticed that passing an incorrect username, but correct access token for a specific git url and branch does NOT give any error at all!
` return Git.cloneRepository()
.setURI(repoDetailsModel.getRepoUrl())
.setCredentialsProvider(
new UsernamePasswordCredentialsProvider(
"INCORRECT_RANDOM_USER" , repoDetailsModel.getAccessToken()))
.setDirectory(tempDir)
.setBranchesToClone(Arrays.asList(REPO_BRANCH_PATH + repoDetailsModel.getRepoBranch()))
.setBranch(REPO_BRANCH_PATH + repoDetailsModel.getRepoBranch())
.call();`
But passing incorrect access token does give the expected "not authorized" error.
Is this a bug in the jgit library?
Does UsernamePasswordCredentialsProvider
allow for anonymous access as long as the access token is correct by design?