Skip to content

Commit 7213d29

Browse files
authored
Merge pull request #362 from fwal/fwal/fix-gpg
Remove unused keyservers
2 parents e91696e + 498aaa2 commit 7213d29

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

__tests__/gpg.test.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,39 @@ describe("gpg", () => {
1616
expect(mockExec).toBeCalledTimes(1);
1717
});
1818

19-
it("uses the next keyserver in the pool if the previous fails", async () => {
20-
const failingServers = 3;
21-
let testedServers = 0;
19+
// NOTE: Currently disabled as the pool only contains one server
20+
// it("uses the next keyserver in the pool if the previous fails", async () => {
21+
// const failingServers = 3;
22+
// let testedServers = 0;
23+
24+
// mockExec.mockImplementation(() => {
25+
// testedServers++;
26+
// if (testedServers >= failingServers) {
27+
// return Promise.resolve(0);
28+
// } else {
29+
// return Promise.resolve(1);
30+
// }
31+
// });
32+
33+
// await refreshKeys();
34+
// expect(mockExec).toBeCalledTimes(3);
35+
// });
36+
37+
it("makes a second attempt if the keyserver fails", async () => {
38+
const attempts = 2;
39+
let tests = 0;
2240

2341
mockExec.mockImplementation(() => {
24-
testedServers++;
25-
if (testedServers >= failingServers) {
42+
tests++;
43+
if (tests >= attempts) {
2644
return Promise.resolve(0);
2745
} else {
2846
return Promise.resolve(1);
2947
}
3048
});
3149

3250
await refreshKeys();
33-
expect(mockExec).toBeCalledTimes(3);
51+
expect(mockExec).toBeCalledTimes(2);
3452
});
3553

3654
it("throws an error if all servers in the pool fails", async () => {

src/gpg.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ export async function verify(signaturePath: string, packagePath: string) {
2121
}
2222

2323
export async function refreshKeys() {
24-
const pool = [
25-
"hkp://pool.sks-keyservers.net",
26-
"ha.pool.sks-keyservers.net",
27-
"keyserver.ubuntu.com",
28-
"hkp://keyserver.ubuntu.com",
29-
"pgp.mit.edu",
30-
];
24+
const pool = ["hkp://keyserver.ubuntu.com"];
3125

3226
for (const server of pool) {
3327
core.debug(`Refreshing keys from ${server}`);
28+
// 1st try...
3429
if (await refreshKeysFromServer(server)) {
35-
core.debug(`Refresh successful`);
30+
core.debug(`Refresh successful on first attempt`);
31+
return;
32+
}
33+
34+
// 2nd try...
35+
if (await refreshKeysFromServer(server)) {
36+
core.debug(`Refresh successful on second attempt`);
3637
return;
3738
}
3839
core.debug(`Refresh failed`);

0 commit comments

Comments
 (0)