summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorPeter GardfjÀll <peter.gardfjall.work@gmail.com>2022-04-01 20:29:57 +0200
committerGitHub <noreply@github.com>2022-04-01 14:29:57 -0400
commit43ff92e122550e2d7cc15e23402fc1a7c8e39e88 (patch)
tree2ed80e7b06041cc7225da0984ab4b8a6809e3d3a /integrations
parent4f27c289472a4cfafb5a9b0e38e6a3413c30c562 (diff)
downloadgitea-43ff92e122550e2d7cc15e23402fc1a7c8e39e88.tar.gz
gitea-43ff92e122550e2d7cc15e23402fc1a7c8e39e88.zip
An attempt to sync a non-mirror repo must give 400 (Bad Request) (#19300)
* An attempt to sync a non-mirror repo must give 400 (Bad Request) * add missing return statement Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_repo_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/integrations/api_repo_test.go b/integrations/api_repo_test.go
index ce1ecb1d43..b585ad15e3 100644
--- a/integrations/api_repo_test.go
+++ b/integrations/api_repo_test.go
@@ -405,6 +405,27 @@ func testAPIRepoMigrateConflict(t *testing.T, u *url.URL) {
})
}
+// mirror-sync must fail with "400 (Bad Request)" when an attempt is made to
+// sync a non-mirror repository.
+func TestAPIMirrorSyncNonMirrorRepo(t *testing.T) {
+ defer prepareTestEnv(t)()
+
+ session := loginUser(t, "user2")
+ token := getTokenForLoggedInUser(t, session)
+
+ var repo api.Repository
+ req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1")
+ resp := MakeRequest(t, req, http.StatusOK)
+ DecodeJSON(t, resp, &repo)
+ assert.EqualValues(t, false, repo.Mirror)
+
+ req = NewRequestf(t, "POST", "/api/v1/repos/user2/repo1/mirror-sync?token=%s", token)
+ resp = session.MakeRequest(t, req, http.StatusBadRequest)
+ errRespJSON := map[string]string{}
+ DecodeJSON(t, resp, &errRespJSON)
+ assert.Equal(t, "Repository is not a mirror", errRespJSON["message"])
+}
+
func TestAPIOrgRepoCreate(t *testing.T) {
testCases := []struct {
ctxUserID int64