mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-03 12:43:48 +00:00
Include forge type in netrc (#4908)
This commit is contained in:
parent
7528179f21
commit
434670ddbd
11 changed files with 14 additions and 3 deletions
|
@ -349,6 +349,7 @@ func (c *config) Netrc(u *model.User, _ *model.Repo) (*model.Netrc, error) {
|
|||
Machine: "bitbucket.org",
|
||||
Login: "x-token-auth",
|
||||
Password: u.AccessToken,
|
||||
Type: model.ForgeTypeBitbucket,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ func TestBitbucket(t *testing.T) {
|
|||
assert.Equal(t, "bitbucket.org", netrc.Machine)
|
||||
assert.Equal(t, "x-token-auth", netrc.Login)
|
||||
assert.Equal(t, fakeUser.AccessToken, netrc.Password)
|
||||
assert.Equal(t, model.ForgeTypeBitbucket, netrc.Type)
|
||||
|
||||
user, _, err := c.Login(ctx, &types.OAuthRequest{})
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -331,6 +331,7 @@ func (c *client) Netrc(_ *model.User, r *model.Repo) (*model.Netrc, error) {
|
|||
Login: c.username,
|
||||
Password: c.password,
|
||||
Machine: host,
|
||||
Type: model.ForgeTypeBitbucketDatacenter,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -350,6 +350,7 @@ func (c *Forgejo) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
|||
Login: login,
|
||||
Password: token,
|
||||
Machine: host,
|
||||
Type: model.ForgeTypeForgejo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ func Test_forgejo(t *testing.T) {
|
|||
assert.Equal(t, "forgejo.org", netrc.Machine)
|
||||
assert.Equal(t, fakeUser.Login, netrc.Login)
|
||||
assert.Equal(t, fakeUser.AccessToken, netrc.Password)
|
||||
assert.Equal(t, model.ForgeTypeForgejo, netrc.Type)
|
||||
})
|
||||
t.Run("netrc with machine account", func(t *testing.T) {
|
||||
forge, _ := New(Opts{})
|
||||
|
|
|
@ -352,6 +352,7 @@ func (c *Gitea) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
|||
Login: login,
|
||||
Password: token,
|
||||
Machine: host,
|
||||
Type: model.ForgeTypeGitea,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ func Test_gitea(t *testing.T) {
|
|||
assert.Equal(t, "gitea.com", netrc.Machine)
|
||||
assert.Equal(t, fakeUser.Login, netrc.Login)
|
||||
assert.Equal(t, fakeUser.AccessToken, netrc.Password)
|
||||
assert.Equal(t, model.ForgeTypeGitea, netrc.Type)
|
||||
})
|
||||
t.Run("netrc with machine account", func(t *testing.T) {
|
||||
forge, _ := New(Opts{})
|
||||
|
|
|
@ -360,6 +360,7 @@ func (c *client) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
|||
Login: login,
|
||||
Password: token,
|
||||
Machine: host,
|
||||
Type: model.ForgeTypeGithub,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ func Test_github(t *testing.T) {
|
|||
assert.Equal(t, "github.com", netrc.Machine)
|
||||
assert.Equal(t, fakeUser.AccessToken, netrc.Login)
|
||||
assert.Equal(t, "x-oauth-basic", netrc.Password)
|
||||
assert.Equal(t, model.ForgeTypeGithub, netrc.Type)
|
||||
})
|
||||
t.Run("netrc with machine account", func(t *testing.T) {
|
||||
forge, _ := New(Opts{})
|
||||
|
|
|
@ -476,6 +476,7 @@ func (g *GitLab) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error) {
|
|||
Login: login,
|
||||
Password: token,
|
||||
Machine: host,
|
||||
Type: model.ForgeTypeGitlab,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,5 @@ type Netrc struct {
|
|||
Machine string `json:"machine"`
|
||||
Login string `json:"login"`
|
||||
Password string `json:"password"`
|
||||
Type ForgeType `json:"type"`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue