-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not inject GIT_USERNAME and GIT_PASSWORD into git clone URL #141
Conversation
} | ||
srv := httptest.NewServer(opts.authMW(createGitHandler(t, opts))) | ||
return srv.URL | ||
} | ||
|
||
func checkBasicAuth(username, password string) func(http.Handler) http.Handler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review: moved to gittest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it intended to be used anywhere else in envbuilder? I'm considering moving it to integration/gittest.go
Ok, I found the place. Speaking of consistency with coder/coder that should land in testutil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do in a follow-up PR 👍
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCloneRepo(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("Clones", func(t *testing.T) { | ||
t.Parallel() | ||
for _, tc := range []struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review: trying to cover all cases outlined here:
https://github.com/coder/envbuilder?tab=readme-ov-file#git-authentication
} | ||
srv := httptest.NewServer(opts.authMW(createGitHandler(t, opts))) | ||
return srv.URL | ||
} | ||
|
||
func checkBasicAuth(username, password string) func(http.Handler) http.Handler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it intended to be used anywhere else in envbuilder? I'm considering moving it to integration/gittest.go
Ok, I found the place. Speaking of consistency with coder/coder that should land in testutil
.
return string(content) | ||
} | ||
|
||
func setupGit(t *testing.T, user, pass string) (url string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving this to gittest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open a a separate PR to refactor this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments so quickly!
Fixes #126
We had been writing the
GIT_USERNAME
andGIT_PASSWORD
into the git auth URL as well as setting basic HTTP auth credentials.This causes
GIT_USERNAME
andGIT_PASSWORD
to be present in the.git/config
of the clond repo, which is not desirable.This PR removes that behaviour and modifies existing unit tests to assert that the git clone URL is not modified from what the user passes in.
The previous behaviour can be preserved by explicitly setting basic auth in the git clone URL, if required.