Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions api/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"fmt"
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -166,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
Expand All @@ -178,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
Expand All @@ -191,11 +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 := c.Params.ByName("name")
name := c.Params.ByName("name") // repo to modify
repo, err := collection.ByName(name)
if err != nil {
AbortWithJSONError(c, 404, err)
Expand Down
2 changes: 1 addition & 1 deletion system/t06_publish/PublishSnapshot43Test_gold
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
31 changes: 31 additions & 0 deletions system/t12_api/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion system/testout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading