summaryrefslogtreecommitdiffstats
path: root/tests/integration/ssh_key_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/ssh_key_test.go')
-rw-r--r--tests/integration/ssh_key_test.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/integration/ssh_key_test.go b/tests/integration/ssh_key_test.go
index 89a2774303..1e9dc264a6 100644
--- a/tests/integration/ssh_key_test.go
+++ b/tests/integration/ssh_key_test.go
@@ -12,6 +12,7 @@ import (
"testing"
"time"
+ auth_model "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/modules/git"
api "code.gitea.io/gitea/modules/structs"
@@ -47,7 +48,9 @@ func TestPushDeployKeyOnEmptyRepo(t *testing.T) {
func testPushDeployKeyOnEmptyRepo(t *testing.T, u *url.URL) {
// OK login
- ctx := NewAPITestContext(t, "user2", "deploy-key-empty-repo-1")
+ ctx := NewAPITestContext(t, "user2", "deploy-key-empty-repo-1", auth_model.AccessTokenScopeRepo)
+ ctxWithDeleteRepo := NewAPITestContext(t, "user2", "deploy-key-empty-repo-1", auth_model.AccessTokenScopeRepo, auth_model.AccessTokenScopeDeleteRepo)
+
keyname := fmt.Sprintf("%s-push", ctx.Reponame)
u.Path = ctx.GitPath()
@@ -72,7 +75,7 @@ func testPushDeployKeyOnEmptyRepo(t *testing.T, u *url.URL) {
t.Run("CheckIsNotEmpty", doCheckRepositoryEmptyStatus(ctx, false))
- t.Run("DeleteRepository", doAPIDeleteRepository(ctx))
+ t.Run("DeleteRepository", doAPIDeleteRepository(ctxWithDeleteRepo))
})
}
@@ -89,10 +92,13 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
keyname := fmt.Sprintf("%s-push", reponame)
// OK login
- ctx := NewAPITestContext(t, username, reponame)
+ ctx := NewAPITestContext(t, username, reponame, auth_model.AccessTokenScopeRepo, auth_model.AccessTokenScopeAdminPublicKey)
+ ctxWithDeleteRepo := NewAPITestContext(t, username, reponame, auth_model.AccessTokenScopeRepo, auth_model.AccessTokenScopeAdminPublicKey, auth_model.AccessTokenScopeDeleteRepo)
otherCtx := ctx
otherCtx.Reponame = "ssh-key-test-repo-2"
+ otherCtxWithDeleteRepo := ctxWithDeleteRepo
+ otherCtxWithDeleteRepo.Reponame = otherCtx.Reponame
failCtx := ctx
failCtx.ExpectedCode = http.StatusUnprocessableEntity
@@ -160,7 +166,7 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
otherSSHURL := createSSHUrl(otherCtx.GitPath(), u)
dstOtherPath := t.TempDir()
- t.Run("DeleteRepository", doAPIDeleteRepository(ctx))
+ t.Run("DeleteRepository", doAPIDeleteRepository(ctxWithDeleteRepo))
t.Run("FailToCreateUserKeyAsStillDeploy", doAPICreateUserKey(failCtx, keyname, keyFile))
@@ -170,9 +176,9 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
t.Run("PushToOther", doGitPushTestRepository(dstOtherPath, "origin", "master"))
- t.Run("DeleteOtherRepository", doAPIDeleteRepository(otherCtx))
+ t.Run("DeleteOtherRepository", doAPIDeleteRepository(otherCtxWithDeleteRepo))
- t.Run("RecreateRepository", doAPICreateRepository(ctx, false))
+ t.Run("RecreateRepository", doAPICreateRepository(ctxWithDeleteRepo, false))
t.Run("CreateUserKey", doAPICreateUserKey(ctx, keyname, keyFile, func(t *testing.T, publicKey api.PublicKey) {
userKeyPublicKeyID = publicKey.ID