Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 19:26:09 +01:00

test-sha256: GitPushCreate

This commit is contained in:
oliverpool 2024-05-16 11:25:52 +02:00
parent 74e07656d2
commit 7e1f7f6a50

View file

@ -56,15 +56,16 @@ func testGit(t *testing.T, u *url.URL) {
forkedUserCtx := NewAPITestContext(t, "user4", "repo1", auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
t.Run("HTTP", func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
ensureAnonymousClone(t, u)
forEachObjectFormat(t, func(t *testing.T, objectFormat git.ObjectFormat) {
defer tests.PrintCurrentTest(t)()
httpContext := baseAPITestContext
httpContext.Reponame = "repo-tmp-17"
httpContext.Reponame = "repo-tmp-17-" + objectFormat.Name()
forkedUserCtx.Reponame = httpContext.Reponame
dstPath := t.TempDir()
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, git.Sha1ObjectFormat)) // FIXME: use forEachObjectFormat
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, objectFormat))
t.Run("AddUserAsCollaborator", doAPIAddCollaborator(forkedUserCtx, httpContext.Username, perm.AccessModeRead))
t.Run("ForkFromDifferentUser", doAPIForkRepository(httpContext, forkedUserCtx.Username))
@ -95,21 +96,23 @@ func testGit(t *testing.T, u *url.URL) {
mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS)
})
t.Run("PushCreate", doPushCreate(httpContext, u))
t.Run("PushCreate", doPushCreate(httpContext, u, objectFormat))
})
})
t.Run("SSH", func(t *testing.T) {
forEachObjectFormat(t, func(t *testing.T, objectFormat git.ObjectFormat) {
defer tests.PrintCurrentTest(t)()
sshContext := baseAPITestContext
sshContext.Reponame = "repo-tmp-18"
sshContext.Reponame = "repo-tmp-18-" + objectFormat.Name()
keyname := "my-testing-key"
forkedUserCtx.Reponame = sshContext.Reponame
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, git.Sha1ObjectFormat)) // FIXME: use forEachObjectFormat
t.Run("CreateRepoInDifferentUser", doAPICreateRepository(forkedUserCtx, false, objectFormat))
t.Run("AddUserAsCollaborator", doAPIAddCollaborator(forkedUserCtx, sshContext.Username, perm.AccessModeRead))
t.Run("ForkFromDifferentUser", doAPIForkRepository(sshContext, forkedUserCtx.Username))
// Setup key the user ssh key
withKeyFile(t, keyname, func(keyFile string) {
t.Run("CreateUserKey", doAPICreateUserKey(sshContext, "test-key", keyFile))
t.Run("CreateUserKey", doAPICreateUserKey(sshContext, "test-key-"+objectFormat.Name(), keyFile))
// Setup remote link
// TODO: get url from api
@ -135,7 +138,8 @@ func testGit(t *testing.T, u *url.URL) {
mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS)
})
t.Run("PushCreate", doPushCreate(sshContext, sshURL))
t.Run("PushCreate", doPushCreate(sshContext, sshURL, objectFormat))
})
})
})
}
@ -586,7 +590,7 @@ func doEnsureDiffNoChange(ctx APITestContext, pr api.PullRequest, diffHash strin
}
}
func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
func doPushCreate(ctx APITestContext, u *url.URL, objectFormat git.ObjectFormat) func(t *testing.T) {
return func(t *testing.T) {
defer tests.PrintCurrentTest(t)()
@ -598,7 +602,7 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) {
tmpDir := t.TempDir()
// Now create local repository to push as our test and set its origin
t.Run("InitTestRepository", doGitInitTestRepository(tmpDir, git.Sha1ObjectFormat)) // FIXME: use forEachObjectFormat
t.Run("InitTestRepository", doGitInitTestRepository(tmpDir, objectFormat))
t.Run("AddRemote", doGitAddRemote(tmpDir, "origin", u))
// Disable "Push To Create" and attempt to push