summaryrefslogtreecommitdiffstats
path: root/integrations/git_test.go
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2020-02-05 03:40:35 -0600
committerGitHub <noreply@github.com>2020-02-05 10:40:35 +0100
commit95013fde60748c425eb910dcab5d1fdd1c89ae18 (patch)
treebe73a9f9669fafe0788bd042a567cd43004da78f /integrations/git_test.go
parent7dcd305424e1d3bfb1fc2b1eaa02ed47a83bddec (diff)
downloadgitea-95013fde60748c425eb910dcab5d1fdd1c89ae18.tar.gz
gitea-95013fde60748c425eb910dcab5d1fdd1c89ae18.zip
Fix push-create SSH bugs (#10145)
* Attempt to fix push-create SSH bugs Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix binding Signed-off-by: jolheiser <john.olheiser@gmail.com> * Invalid ctx Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'integrations/git_test.go')
-rw-r--r--integrations/git_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/integrations/git_test.go b/integrations/git_test.go
index 7d37555f06..7753b2cb72 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -422,6 +422,9 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
tmpDir, err := ioutil.TempDir("", ctx.Reponame)
assert.NoError(t, err)
+ _, err = git.NewCommand("clone", u.String()).RunInDir(tmpDir)
+ assert.Error(t, err)
+
err = git.InitRepository(tmpDir, false)
assert.NoError(t, err)
@@ -449,6 +452,13 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
_, err = git.NewCommand("remote", "add", "origin", u.String()).RunInDir(tmpDir)
assert.NoError(t, err)
+ invalidCtx := ctx
+ invalidCtx.Reponame = fmt.Sprintf("invalid/repo-tmp-push-create-%s", u.Scheme)
+ u.Path = invalidCtx.GitPath()
+
+ _, err = git.NewCommand("remote", "add", "invalid", u.String()).RunInDir(tmpDir)
+ assert.NoError(t, err)
+
// Push to create disabled
setting.Repository.EnablePushCreateUser = false
_, err = git.NewCommand("push", "origin", "master").RunInDir(tmpDir)
@@ -456,6 +466,12 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
// Push to create enabled
setting.Repository.EnablePushCreateUser = true
+
+ // Invalid repo
+ _, err = git.NewCommand("push", "invalid", "master").RunInDir(tmpDir)
+ assert.Error(t, err)
+
+ // Valid repo
_, err = git.NewCommand("push", "origin", "master").RunInDir(tmpDir)
assert.NoError(t, err)