Add fixes for delete_repo scope
This commit is contained in:
parent
b4c35e82bb
commit
0ff93b83ec
2 changed files with 9 additions and 4 deletions
|
@ -43,7 +43,7 @@ func TestGit(t *testing.T) {
|
||||||
|
|
||||||
func testGit(t *testing.T, u *url.URL) {
|
func testGit(t *testing.T, u *url.URL) {
|
||||||
username := "user2"
|
username := "user2"
|
||||||
baseAPITestContext := NewAPITestContext(t, username, "repo1", "repo", "write_public_key")
|
baseAPITestContext := NewAPITestContext(t, username, "repo1", "repo", "write_public_key", "delete_repo")
|
||||||
|
|
||||||
u.Path = baseAPITestContext.GitPath()
|
u.Path = baseAPITestContext.GitPath()
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ func TestPushDeployKeyOnEmptyRepo(t *testing.T) {
|
||||||
func testPushDeployKeyOnEmptyRepo(t *testing.T, u *url.URL) {
|
func testPushDeployKeyOnEmptyRepo(t *testing.T, u *url.URL) {
|
||||||
// OK login
|
// OK login
|
||||||
ctx := NewAPITestContext(t, "user2", "deploy-key-empty-repo-1", "repo")
|
ctx := NewAPITestContext(t, "user2", "deploy-key-empty-repo-1", "repo")
|
||||||
|
ctxWithDeleteRepo := NewAPITestContext(t, "user2", "deploy-key-empty-repo-1", "repo", "delete_repo")
|
||||||
|
|
||||||
keyname := fmt.Sprintf("%s-push", ctx.Reponame)
|
keyname := fmt.Sprintf("%s-push", ctx.Reponame)
|
||||||
u.Path = ctx.GitPath()
|
u.Path = ctx.GitPath()
|
||||||
|
|
||||||
|
@ -73,7 +75,7 @@ func testPushDeployKeyOnEmptyRepo(t *testing.T, u *url.URL) {
|
||||||
|
|
||||||
t.Run("CheckIsNotEmpty", doCheckRepositoryEmptyStatus(ctx, false))
|
t.Run("CheckIsNotEmpty", doCheckRepositoryEmptyStatus(ctx, false))
|
||||||
|
|
||||||
t.Run("DeleteRepository", doAPIDeleteRepository(ctx))
|
t.Run("DeleteRepository", doAPIDeleteRepository(ctxWithDeleteRepo))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +93,12 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
|
||||||
|
|
||||||
// OK login
|
// OK login
|
||||||
ctx := NewAPITestContext(t, username, reponame, "repo", "admin_public_key")
|
ctx := NewAPITestContext(t, username, reponame, "repo", "admin_public_key")
|
||||||
|
ctxWithDeleteRepo := NewAPITestContext(t, username, reponame, "repo", "admin_public_key", "delete_repo")
|
||||||
|
|
||||||
otherCtx := ctx
|
otherCtx := ctx
|
||||||
otherCtx.Reponame = "ssh-key-test-repo-2"
|
otherCtx.Reponame = "ssh-key-test-repo-2"
|
||||||
|
otherCtxWithDeleteRepo := ctxWithDeleteRepo
|
||||||
|
otherCtxWithDeleteRepo.Reponame = otherCtx.Reponame
|
||||||
|
|
||||||
failCtx := ctx
|
failCtx := ctx
|
||||||
failCtx.ExpectedCode = http.StatusUnprocessableEntity
|
failCtx.ExpectedCode = http.StatusUnprocessableEntity
|
||||||
|
@ -171,9 +176,9 @@ func testKeyOnlyOneType(t *testing.T, u *url.URL) {
|
||||||
|
|
||||||
t.Run("PushToOther", doGitPushTestRepository(dstOtherPath, "origin", "master"))
|
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) {
|
t.Run("CreateUserKey", doAPICreateUserKey(ctx, keyname, keyFile, func(t *testing.T, publicKey api.PublicKey) {
|
||||||
userKeyPublicKeyID = publicKey.ID
|
userKeyPublicKeyID = publicKey.ID
|
||||||
|
|
Loading…
Add table
Reference in a new issue