|
1 | 1 | import inspect |
2 | 2 | import os |
3 | 3 | import threading |
| 4 | +import re |
4 | 5 |
|
5 | 6 | from api_lib import TASK_SUCCEEDED, APITest |
6 | 7 |
|
@@ -1874,3 +1875,63 @@ def check(self): |
1874 | 1875 | all_repos = self.get("/api/publish") |
1875 | 1876 | self.check_equal(all_repos.status_code, 200) |
1876 | 1877 | self.check_in(repo_expected, all_repos.json()) |
| 1878 | + |
| 1879 | + |
| 1880 | +class PublishAPITestDualSignature(APITest): |
| 1881 | + """ |
| 1882 | + POST /publish/:prefix (local repos), GET /publish |
| 1883 | + """ |
| 1884 | + fixtureGpg = True |
| 1885 | + |
| 1886 | + def check(self): |
| 1887 | + repo_name = self.random_name() |
| 1888 | + self.check_equal(self.post( |
| 1889 | + "/api/repos", json={"Name": repo_name, "DefaultDistribution": "wheezy"}).status_code, 201) |
| 1890 | + |
| 1891 | + d = self.random_name() |
| 1892 | + self.check_equal(self.upload("/api/files/" + d, |
| 1893 | + "libboost-program-options-dev_1.49.0.1_i386.deb", "pyspi_0.6.1-1.3.dsc", |
| 1894 | + "pyspi_0.6.1-1.3.diff.gz", "pyspi_0.6.1.orig.tar.gz", |
| 1895 | + "pyspi-0.6.1-1.3.stripped.dsc").status_code, 200) |
| 1896 | + |
| 1897 | + task = self.post_task("/api/repos/" + repo_name + "/file/" + d) |
| 1898 | + self.check_task(task) |
| 1899 | + |
| 1900 | + # publishing under prefix, default distribution |
| 1901 | + prefix = self.random_name() |
| 1902 | + task = self.post_task( |
| 1903 | + "/api/publish/" + prefix, |
| 1904 | + json={ |
| 1905 | + "SourceKind": "local", |
| 1906 | + "Sources": [{"Name": repo_name}], |
| 1907 | + "Signing": {"GPGKey": "C5ACD2179B5231DFE842EE6121DBB89C16DB3E6D,AEE16DF018354F67FE5F5C72BBF4E19434E91E4E"}, |
| 1908 | + } |
| 1909 | + ) |
| 1910 | + self.check_task(task) |
| 1911 | + repo_expected = { |
| 1912 | + 'AcquireByHash': False, |
| 1913 | + 'Architectures': ['i386', 'source'], |
| 1914 | + 'Codename': '', |
| 1915 | + 'Distribution': 'wheezy', |
| 1916 | + 'Label': '', |
| 1917 | + 'Origin': '', |
| 1918 | + 'NotAutomatic': '', |
| 1919 | + 'ButAutomaticUpgrades': '', |
| 1920 | + 'Path': prefix + '/' + 'wheezy', |
| 1921 | + 'Prefix': prefix, |
| 1922 | + 'SignedBy': '', |
| 1923 | + 'SkipContents': False, |
| 1924 | + 'MultiDist': False, |
| 1925 | + 'SourceKind': 'local', |
| 1926 | + 'Sources': [{'Component': 'main', 'Name': repo_name}], |
| 1927 | + 'Storage': '', |
| 1928 | + 'Suite': ''} |
| 1929 | + |
| 1930 | + all_repos = self.get("/api/publish") |
| 1931 | + self.check_equal(all_repos.status_code, 200) |
| 1932 | + self.check_in(repo_expected, all_repos.json()) |
| 1933 | + |
| 1934 | + self.check_exists("public/" + prefix + "/dists/wheezy/Release") |
| 1935 | + path = os.path.join(os.environ["HOME"], self.aptlyDir, "public", prefix, "dists/wheezy") |
| 1936 | + self.check_cmd_output(f"gpg --verify {path}/Release.gpg {path}/Release", "Release.gpg", |
| 1937 | + match_prepare=lambda s: re.sub(r'Signature made .*', '', s)) |
0 commit comments