From 0516fb90af1ad61b063119c465e080fc6ab610ae Mon Sep 17 00:00:00 2001 From: theoborealis <221909172+theoborealis@users.noreply.github.com> Date: Thu, 27 Nov 2025 15:09:34 +0300 Subject: [PATCH 1/5] fixed urlencode for repo name in /put --- api/repos.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/api/repos.go b/api/repos.go index ff496f2cd..c5e8b6036 100644 --- a/api/repos.go +++ b/api/repos.go @@ -3,6 +3,7 @@ package api import ( "fmt" "net/http" + "net/url" "os" "path/filepath" "sort" @@ -195,7 +196,11 @@ func apiReposEdit(c *gin.Context) { collectionFactory := context.NewCollectionFactory() collection := collectionFactory.LocalRepoCollection() - name := c.Params.ByName("name") + name, err := url.PathUnescape(c.Params.ByName("name")) + if err != nil { + AbortWithJSONError(c, 400, err) + return + } repo, err := collection.ByName(name) if err != nil { AbortWithJSONError(c, 404, err) From b625e799d93663804892cb9de0642b4cb7a48055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Sun, 4 Jan 2026 17:44:58 +0100 Subject: [PATCH 2/5] system test: fix home directory reference --- system/t06_publish/PublishSnapshot43Test_gold | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/t06_publish/PublishSnapshot43Test_gold b/system/t06_publish/PublishSnapshot43Test_gold index 8738ec92f..0ffddaf32 100644 --- a/system/t06_publish/PublishSnapshot43Test_gold +++ b/system/t06_publish/PublishSnapshot43Test_gold @@ -5,7 +5,7 @@ Signing file 'Release' with gpg, please enter your passphrase when prompted: Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: Snapshot snap43 has been successfully published. -Please setup your webserver to serve directory '/home/runner/.aptly/public' with autoindexing. +Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing. Now you can add following line to apt sources: deb http://your-server/ maverick main Don't forget to add your GPG key to apt with apt-key. From 98928d7a4c5e1e241068a19c424e26d9562482fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Mon, 5 Jan 2026 12:18:21 +0100 Subject: [PATCH 3/5] tests: remove temporary folders --- system/testout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/testout.py b/system/testout.py index f7dc134d8..d63d6316a 100644 --- a/system/testout.py +++ b/system/testout.py @@ -3,7 +3,7 @@ class TestOut: def __init__(self): - self.tmp_file = tempfile.NamedTemporaryFile(delete=False) + self.tmp_file = tempfile.NamedTemporaryFile(delete=True) self.read_pos = 0 def fileno(self): From 827098a3c44e62fe6ff1796a912ac23b82a416ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Sun, 25 Jan 2026 12:22:35 +0100 Subject: [PATCH 4/5] tests: add api repo edit test --- system/t12_api/repos.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/system/t12_api/repos.py b/system/t12_api/repos.py index 424f9f49f..6448a5576 100644 --- a/system/t12_api/repos.py +++ b/system/t12_api/repos.py @@ -461,3 +461,34 @@ def check(self): self.check_equal(self.get(f"/api/repos/{repo2_name}/packages").json(), ['Pi386 libboost-program-options-dev 1.49.0.1 918d2f433384e378']) + + +class ReposAPITestCreateEdit(APITest): + """ + POST /api/repos, + """ + def check(self): + repo_name = self.random_name() + ' with space' + repo_desc = {'Comment': 'fun repo', + 'DefaultComponent': 'contrib', + 'DefaultDistribution': 'bookworm', + 'Name': repo_name} + + resp = self.post("/api/repos", json=repo_desc) + self.check_equal(resp.json(), repo_desc) + self.check_equal(resp.status_code, 201) + + repo_desc = {'Comment': 'modified repo', + 'DefaultComponent': 'main', + 'DefaultDistribution': 'trixie', + 'Name': repo_name + '@renamed'} + resp = self.put(f"/api/repos/{repo_name}", json=repo_desc) + self.check_equal(resp.json(), repo_desc) + self.check_equal(resp.status_code, 200) + + resp = self.get("/api/repos/" + repo_name + '@renamed') + self.check_equal(resp.json(), repo_desc) + self.check_equal(resp.status_code, 200) + + resp = self.delete("/api/repos/" + repo_name + '@renamed') + self.check_equal(resp.status_code, 200) From fa39bcaa255a1f94f08e1654acfb7ad77fae7264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Sun, 25 Jan 2026 13:39:33 +0100 Subject: [PATCH 5/5] api: make updating name optional in repo edit and path escape the new name param --- api/repos.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/api/repos.go b/api/repos.go index c5e8b6036..aaa633086 100644 --- a/api/repos.go +++ b/api/repos.go @@ -167,7 +167,7 @@ func apiReposCreate(c *gin.Context) { type reposEditParams struct { // Name of repository to modify - Name *string `binding:"required" json:"Name" example:"repo1"` + Name *string ` json:"Name" example:"new-repo-name"` // Change Comment of repository Comment *string ` json:"Comment" example:"example repo"` // Change Default Distribution for publishing @@ -179,7 +179,7 @@ type reposEditParams struct { // @Summary Update Repository // @Description **Update local repository meta information** // @Tags Repos -// @Param name path string true "Repository name" +// @Param name path string true "Repository name to modify" // @Consume json // @Param request body reposEditParams true "Parameters" // @Produce json @@ -192,15 +192,20 @@ func apiReposEdit(c *gin.Context) { if c.Bind(&b) != nil { return } + if b.Name != nil { + new_name, err := url.PathUnescape(*b.Name) + if err != nil { + AbortWithJSONError(c, 400, err) + return + } + *b.Name = new_name + } + collectionFactory := context.NewCollectionFactory() collection := collectionFactory.LocalRepoCollection() - name, err := url.PathUnescape(c.Params.ByName("name")) - if err != nil { - AbortWithJSONError(c, 400, err) - return - } + name := c.Params.ByName("name") // repo to modify repo, err := collection.ByName(name) if err != nil { AbortWithJSONError(c, 404, err)