mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-11-12 00:16:57 +00:00
Get Netrc machine from clone url (#800)
We previously got the machine hostname for Netrc from the url of the remote, but in cases where the clone-url does not match the api url this can lead to errors.
This commit is contained in:
@@ -52,7 +52,6 @@ func Test_gogs(t *testing.T) {
|
||||
PrivateMode: true,
|
||||
})
|
||||
g.Assert(remote.(*client).URL).Equal("http://localhost:8080")
|
||||
g.Assert(remote.(*client).Machine).Equal("localhost")
|
||||
g.Assert(remote.(*client).Username).Equal("someuser")
|
||||
g.Assert(remote.(*client).Password).Equal("password")
|
||||
g.Assert(remote.(*client).SkipVerify).Equal(true)
|
||||
@@ -66,21 +65,18 @@ func Test_gogs(t *testing.T) {
|
||||
|
||||
g.Describe("Generating a netrc file", func() {
|
||||
g.It("Should return a netrc with the user token", func() {
|
||||
remote, _ := New(Opts{
|
||||
URL: "http://gogs.com",
|
||||
})
|
||||
netrc, _ := remote.Netrc(fakeUser, nil)
|
||||
remote, _ := New(Opts{})
|
||||
netrc, _ := remote.Netrc(fakeUser, fakeRepo)
|
||||
g.Assert(netrc.Machine).Equal("gogs.com")
|
||||
g.Assert(netrc.Login).Equal(fakeUser.Token)
|
||||
g.Assert(netrc.Password).Equal("x-oauth-basic")
|
||||
})
|
||||
g.It("Should return a netrc with the machine account", func() {
|
||||
remote, _ := New(Opts{
|
||||
URL: "http://gogs.com",
|
||||
Username: "someuser",
|
||||
Password: "password",
|
||||
})
|
||||
netrc, _ := remote.Netrc(nil, nil)
|
||||
netrc, _ := remote.Netrc(nil, fakeRepo)
|
||||
g.Assert(netrc.Machine).Equal("gogs.com")
|
||||
g.Assert(netrc.Login).Equal("someuser")
|
||||
g.Assert(netrc.Password).Equal("password")
|
||||
@@ -185,6 +181,7 @@ var (
|
||||
}
|
||||
|
||||
fakeRepo = &model.Repo{
|
||||
Clone: "http://gogs.com/test_name/repo_name.git",
|
||||
Owner: "test_name",
|
||||
Name: "repo_name",
|
||||
FullName: "test_name/repo_name",
|
||||
|
||||
Reference in New Issue
Block a user