Skip to content

Commit

Permalink
Improvement: Add Test for publish with passphrase but batch=false
Browse files Browse the repository at this point in the history
  • Loading branch information
reglim committed Aug 18, 2023
1 parent 847fd90 commit c9b8b23
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions system/t12_api/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,3 +750,44 @@ def check(self):
get = self.get("/repos/apiandserve/pool/main/b/boost-defaults/i-dont-exist")
if get.status_code != 404:
raise Exception(f"Expected status 404 != {get.status_code}")


class PublishWithoutBadgeAndNoPassphraseShouldError(APITest):
"""
POST /publish/:prefix (local repos), GET /publish
"""
def check(self):
repo_name = self.random_name()
snapshot_name = self.random_name()
self.check_equal(
self.post("/api/repos", json={"Name": repo_name}).status_code, 201)

d = self.random_name()
self.check_equal(self.upload("/api/files/" + d,
"libboost-program-options-dev_1.49.0.1_i386.deb").status_code, 200)

self.check_equal(self.post_task("/api/repos/" + repo_name + "/file/" + d).json()['State'], TASK_SUCCEEDED)

self.check_equal(self.post_task("/api/repos/" + repo_name + '/snapshots', json={'Name': snapshot_name}).json()['State'], TASK_SUCCEEDED)

prefix = self.random_name()
resp = self.post(
"/api/publish/" + prefix,
json={
"SourceKind": "snapshot",
"Sources": [{"Name": snapshot_name}],
"Signing": {
"Batch": False,
"Keyring": os.path.join(os.path.dirname(inspect.getsourcefile(APITest)), "files") + "/aptly_passphrase.pub",
"SecretKeyring": os.path.join(os.path.dirname(inspect.getsourcefile(APITest)), "files") + "/aptly_passphrase.sec",
},
"Distribution": "squeeze",
"NotAutomatic": "yes",
"ButAutomaticUpgrades": "yes",
"Origin": "earth",
"Label": "fun",
},
timeout=2
)
print(resp.json())
self.check_equal(False, True)

0 comments on commit c9b8b23

Please sign in to comment.