aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/gpg_git_test.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-11-26 15:35:41 +0000
committerLunny Xiao <xiaolunwen@gmail.com>2019-11-26 23:35:41 +0800
commit9d9e6ac4117b8efd2f85fc625a4ccfdcf73c4fc3 (patch)
treed3522e058de2f5e1556df9f21e345f9f7633dcf8 /integrations/gpg_git_test.go
parent055f6d229672524e3933940f95aa28939d94961a (diff)
downloadgitea-9d9e6ac4117b8efd2f85fc625a4ccfdcf73c4fc3.tar.gz
gitea-9d9e6ac4117b8efd2f85fc625a4ccfdcf73c4fc3.zip
Yet another attempt to fix the intermittent failure of gpg git test (#9146)
* Yet another attempt to fix the race in gpg_git_test * add some fail nows * Need to set preparetestenv * Ensure that http messages go to the correct server
Diffstat (limited to 'integrations/gpg_git_test.go')
-rw-r--r--integrations/gpg_git_test.go37
1 files changed, 32 insertions, 5 deletions
diff --git a/integrations/gpg_git_test.go b/integrations/gpg_git_test.go
index a5a3406b86..6c9b7c00ff 100644
--- a/integrations/gpg_git_test.go
+++ b/integrations/gpg_git_test.go
@@ -23,6 +23,7 @@ import (
)
func TestGPGGit(t *testing.T) {
+ prepareTestEnv(t)
username := "user2"
// OK Set a new GPG home
@@ -125,11 +126,19 @@ func TestGPGGit(t *testing.T) {
t.Run("CreateCRUDFile-Always", crudActionCreateFile(
t, testCtx, user, "master", "always", "signed-always.txt", func(t *testing.T, response api.FileResponse) {
assert.True(t, response.Verification.Verified)
+ if !response.Verification.Verified {
+ t.FailNow()
+ return
+ }
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
}))
t.Run("CreateCRUDFile-ParentSigned-always", crudActionCreateFile(
t, testCtx, user, "parentsigned", "parentsigned-always", "signed-parent2.txt", func(t *testing.T, response api.FileResponse) {
assert.True(t, response.Verification.Verified)
+ if !response.Verification.Verified {
+ t.FailNow()
+ return
+ }
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
}))
})
@@ -144,6 +153,10 @@ func TestGPGGit(t *testing.T) {
t.Run("CreateCRUDFile-Always-ParentSigned", crudActionCreateFile(
t, testCtx, user, "always", "always-parentsigned", "signed-always-parentsigned.txt", func(t *testing.T, response api.FileResponse) {
assert.True(t, response.Verification.Verified)
+ if !response.Verification.Verified {
+ t.FailNow()
+ return
+ }
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
}))
})
@@ -160,6 +173,10 @@ func TestGPGGit(t *testing.T) {
assert.NotNil(t, branch.Commit)
assert.NotNil(t, branch.Commit.Verification)
assert.True(t, branch.Commit.Verification.Verified)
+ if !branch.Commit.Verification.Verified {
+ t.FailNow()
+ return
+ }
assert.Equal(t, "gitea@fake.local", branch.Commit.Verification.Signer.Email)
}))
})
@@ -170,7 +187,8 @@ func TestGPGGit(t *testing.T) {
t.Run("AlwaysSign-Initial-CRUD-Never", func(t *testing.T) {
defer PrintCurrentTest(t)()
- testCtx := NewAPITestContext(t, username, "initial-always")
+ testCtx := NewAPITestContext(t, username, "initial-always-never")
+ t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
t.Run("CreateCRUDFile-Never", crudActionCreateFile(
t, testCtx, user, "master", "never", "unsigned-never.txt", func(t *testing.T, response api.FileResponse) {
assert.False(t, response.Verification.Verified)
@@ -180,13 +198,17 @@ func TestGPGGit(t *testing.T) {
setting.Repository.Signing.CRUDActions = []string{"parentsigned"}
onGiteaRun(t, func(t *testing.T, u *url.URL) {
u.Path = baseAPITestContext.GitPath()
-
t.Run("AlwaysSign-Initial-CRUD-ParentSigned-On-Always", func(t *testing.T) {
defer PrintCurrentTest(t)()
- testCtx := NewAPITestContext(t, username, "initial-always")
+ testCtx := NewAPITestContext(t, username, "initial-always-parent")
+ t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
t.Run("CreateCRUDFile-ParentSigned", crudActionCreateFile(
t, testCtx, user, "master", "parentsigned", "signed-parent.txt", func(t *testing.T, response api.FileResponse) {
assert.True(t, response.Verification.Verified)
+ if !response.Verification.Verified {
+ t.FailNow()
+ return
+ }
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
}))
})
@@ -197,10 +219,15 @@ func TestGPGGit(t *testing.T) {
t.Run("AlwaysSign-Initial-CRUD-Always", func(t *testing.T) {
defer PrintCurrentTest(t)()
- testCtx := NewAPITestContext(t, username, "initial-always")
+ testCtx := NewAPITestContext(t, username, "initial-always-always")
+ t.Run("CreateRepository", doAPICreateRepository(testCtx, false))
t.Run("CreateCRUDFile-Always", crudActionCreateFile(
t, testCtx, user, "master", "always", "signed-always.txt", func(t *testing.T, response api.FileResponse) {
assert.True(t, response.Verification.Verified)
+ if !response.Verification.Verified {
+ t.FailNow()
+ return
+ }
assert.Equal(t, "gitea@fake.local", response.Verification.Signer.Email)
}))
@@ -287,7 +314,7 @@ func crudActionCreateFile(t *testing.T, ctx APITestContext, user *models.User, f
Email: user.Email,
},
},
- Content: base64.StdEncoding.EncodeToString([]byte("This is new text")),
+ Content: base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("This is new text for %s", path))),
}, callback...)
}