Merge pull request #696 from apachelogger/AcquireByHash

properly expose AcquireByHash through the api
This commit is contained in:
Andrey Smirnov
2018-01-27 22:55:51 +03:00
committed by GitHub
3 changed files with 22 additions and 0 deletions
+5
View File
@@ -104,6 +104,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
SkipContents *bool SkipContents *bool
Architectures []string Architectures []string
Signing SigningOptions Signing SigningOptions
AcquireByHash *bool
} }
if c.Bind(&b) != nil { if c.Bind(&b) != nil {
@@ -201,6 +202,10 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
published.SkipContents = *b.SkipContents published.SkipContents = *b.SkipContents
} }
if b.AcquireByHash != nil {
published.AcquireByHash = *b.AcquireByHash
}
duplicate := collection.CheckDuplicate(published) duplicate := collection.CheckDuplicate(published)
if duplicate != nil { if duplicate != nil {
context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory()) context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory())
+1
View File
@@ -315,6 +315,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
"Sources": sources, "Sources": sources,
"Storage": p.Storage, "Storage": p.Storage,
"SkipContents": p.SkipContents, "SkipContents": p.SkipContents,
"AcquireByHash": p.AcquireByHash,
}) })
} }
+16
View File
@@ -36,6 +36,7 @@ class PublishAPITestRepo(APITest):
"Signing": DefaultSigningOptions, "Signing": DefaultSigningOptions,
}) })
repo_expected = { repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'wheezy', 'Distribution': 'wheezy',
'Label': '', 'Label': '',
@@ -72,6 +73,7 @@ class PublishAPITestRepo(APITest):
"Architectures": ["i386", "amd64"], "Architectures": ["i386", "amd64"],
}) })
repo2_expected = { repo2_expected = {
'AcquireByHash': False,
'Architectures': ['amd64', 'i386'], 'Architectures': ['amd64', 'i386'],
'Distribution': distribution, 'Distribution': distribution,
'Label': '', 'Label': '',
@@ -120,6 +122,7 @@ class PublishSnapshotAPITest(APITest):
prefix = self.random_name() prefix = self.random_name()
resp = self.post("/api/publish/" + prefix, resp = self.post("/api/publish/" + prefix,
json={ json={
"AcquireByHash": True,
"SourceKind": "snapshot", "SourceKind": "snapshot",
"Sources": [{"Name": snapshot_name}], "Sources": [{"Name": snapshot_name}],
"Signing": DefaultSigningOptions, "Signing": DefaultSigningOptions,
@@ -129,6 +132,7 @@ class PublishSnapshotAPITest(APITest):
}) })
self.check_equal(resp.status_code, 201) self.check_equal(resp.status_code, 201)
self.check_equal(resp.json(), { self.check_equal(resp.json(), {
'AcquireByHash': True,
'Architectures': ['i386'], 'Architectures': ['i386'],
'Distribution': 'squeeze', 'Distribution': 'squeeze',
'Label': '', 'Label': '',
@@ -142,6 +146,7 @@ class PublishSnapshotAPITest(APITest):
'Storage': ''}) 'Storage': ''})
self.check_exists("public/" + prefix + "/dists/squeeze/Release") self.check_exists("public/" + prefix + "/dists/squeeze/Release")
self.check_exists("public/" + prefix + "/dists/squeeze/main/binary-i386/by-hash")
self.check_exists("public/" + prefix + "/dists/squeeze/main/binary-i386/Packages") self.check_exists("public/" + prefix + "/dists/squeeze/main/binary-i386/Packages")
self.check_exists("public/" + prefix + "/dists/squeeze/main/Contents-i386.gz") self.check_exists("public/" + prefix + "/dists/squeeze/main/Contents-i386.gz")
self.check_exists("public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb") self.check_exists("public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb")
@@ -187,11 +192,14 @@ class PublishUpdateAPITestRepo(APITest):
self.check_equal(self.delete("/api/repos/" + repo_name + "/packages/", self.check_equal(self.delete("/api/repos/" + repo_name + "/packages/",
json={"PackageRefs": ['Psource pyspi 0.6.1-1.4 f8f1daa806004e89']}).status_code, 200) json={"PackageRefs": ['Psource pyspi 0.6.1-1.4 f8f1daa806004e89']}).status_code, 200)
# Update and switch AcquireByHash on.
resp = self.put("/api/publish/" + prefix + "/wheezy", resp = self.put("/api/publish/" + prefix + "/wheezy",
json={ json={
"AcquireByHash": True,
"Signing": DefaultSigningOptions, "Signing": DefaultSigningOptions,
}) })
repo_expected = { repo_expected = {
'AcquireByHash': True,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'wheezy', 'Distribution': 'wheezy',
'Label': '', 'Label': '',
@@ -207,6 +215,8 @@ class PublishUpdateAPITestRepo(APITest):
self.check_equal(resp.status_code, 200) self.check_equal(resp.status_code, 200)
self.check_equal(resp.json(), repo_expected) self.check_equal(resp.json(), repo_expected)
self.check_exists("public/" + prefix + "/dists/wheezy/main/binary-i386/by-hash")
self.check_exists("public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb") self.check_exists("public/" + prefix + "/pool/main/b/boost-defaults/libboost-program-options-dev_1.49.0.1_i386.deb")
self.check_not_exists("public/" + prefix + "/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc") self.check_not_exists("public/" + prefix + "/pool/main/p/pyspi/pyspi-0.6.1-1.3.stripped.dsc")
@@ -273,6 +283,7 @@ class PublishUpdateSkipCleanupAPITestRepo(APITest):
"SkipCleanup": True, "SkipCleanup": True,
}) })
repo_expected = { repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'wheezy', 'Distribution': 'wheezy',
'Label': '', 'Label': '',
@@ -328,6 +339,7 @@ class PublishSwitchAPITestRepo(APITest):
self.check_equal(resp.status_code, 201) self.check_equal(resp.status_code, 201)
repo_expected = { repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'wheezy', 'Distribution': 'wheezy',
'Label': '', 'Label': '',
@@ -362,6 +374,7 @@ class PublishSwitchAPITestRepo(APITest):
"SkipContents": True, "SkipContents": True,
}) })
repo_expected = { repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'wheezy', 'Distribution': 'wheezy',
'Label': '', 'Label': '',
@@ -416,6 +429,7 @@ class PublishSwitchAPISkipCleanupTestRepo(APITest):
self.check_equal(resp.status_code, 201) self.check_equal(resp.status_code, 201)
repo_expected = { repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'wheezy', 'Distribution': 'wheezy',
'Label': '', 'Label': '',
@@ -445,6 +459,7 @@ class PublishSwitchAPISkipCleanupTestRepo(APITest):
self.check_equal(resp.status_code, 201) self.check_equal(resp.status_code, 201)
repo_expected = { repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'otherdist', 'Distribution': 'otherdist',
'Label': '', 'Label': '',
@@ -477,6 +492,7 @@ class PublishSwitchAPISkipCleanupTestRepo(APITest):
"SkipContents": True, "SkipContents": True,
}) })
repo_expected = { repo_expected = {
'AcquireByHash': False,
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
'Distribution': 'wheezy', 'Distribution': 'wheezy',
'Label': '', 'Label': '',