mirror of
https://github.com/google/nomulus.git
synced 2025-06-01 10:14:04 +02:00
Fix some GPG related test issues
We were running FOSS tests on an old version of Ubuntu (14.04) which comes with a rather old gpg version 1.4.16 compared to the current version 2.1.22 (https://lists.gnupg.org/pipermail/gnupg-announce/2017q3/000411.html). As a result some default settings have changed between these versions, leading to test failures when tests are run on newer platforms. In this CL several of the settings are made explicit, no longer depending on default values, which makes them work on either platform. 1. "--no-mdc-error" is set. We do not have mdc integrity protection for the test keys, which results in a non-zero return value for newer versions of GPG. Setting this flag makes return value zero again. 2. "--keyid-format" long is set. GPG key IDs are the last 16 (long key id) or 8 (short key id) octets of the key fingerprint (https://security.stackexchange.com/questions/84280/short-openpgp-key-ids-are-insecure-how-to-configure-gnupg-to-use-long-key-ids-i). Older version uses the short id as default, whereas newer versions defaults to long id. Also change the expected key ID to 16 bytes accordingly. 3. Output stderr in GpgSystemCommandRule when failure occurs during key import. This help debug key import failure due to too long gpg root path. Note: this failure itself is not fixed and still would occur on newer Debian or macOS systems. 4. Set gpg root folder permission correctly to 700, otherwise the newer version gpg will return non-zero value. Previously used method set it to 755. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178163297
This commit is contained in:
parent
d87f01e7bf
commit
6bd0fc58de
4 changed files with 59 additions and 25 deletions
|
@ -147,7 +147,14 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
// gpg: WARNING: message was not integrity protected
|
||||
logger.info("Running GPG to list info about OpenPGP message...");
|
||||
{
|
||||
Process pid = gpg.exec(cmd.get(), "--list-packets", rydeFile.toString());
|
||||
Process pid =
|
||||
gpg.exec(
|
||||
cmd.get(),
|
||||
"--list-packets",
|
||||
"--ignore-mdc-error",
|
||||
"--keyid-format",
|
||||
"long",
|
||||
rydeFile.toString());
|
||||
String stdout = slurp(pid.getInputStream());
|
||||
String stderr = slurp(pid.getErrorStream());
|
||||
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
|
||||
|
@ -175,7 +182,9 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
assertWithMessage("Unexpected asymmetric encryption algorithm")
|
||||
.that(stderr)
|
||||
.contains("encrypted with 2048-bit RSA key");
|
||||
assertWithMessage("Unexpected receiver public key").that(stderr).contains("ID 54E1EB0F");
|
||||
assertWithMessage("Unexpected receiver public key")
|
||||
.that(stderr)
|
||||
.contains("ID 7F9084EE54E1EB0F");
|
||||
}
|
||||
|
||||
// Iron Mountain now verifies that rydeFile is authentic and was signed appropriately.
|
||||
|
@ -203,7 +212,8 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
// gpg: WARNING: message was not integrity protected
|
||||
logger.info("Running GPG to extract tar...");
|
||||
{
|
||||
Process pid = gpg.exec(cmd.get(), "--use-embedded-filename", rydeFile.toString());
|
||||
Process pid =
|
||||
gpg.exec(cmd.get(), "--use-embedded-filename", "--ignore-mdc-error", rydeFile.toString());
|
||||
String stderr = slurp(pid.getErrorStream());
|
||||
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
|
||||
}
|
||||
|
@ -226,7 +236,7 @@ public class RydeGpgIntegrationTest extends ShardableTestCase {
|
|||
return CharStreams.toString(new InputStreamReader(new FileInputStream(file), UTF_8));
|
||||
}
|
||||
|
||||
private String slurp(InputStream is) throws FileNotFoundException, IOException {
|
||||
private String slurp(InputStream is) throws IOException {
|
||||
return CharStreams.toString(new InputStreamReader(is, UTF_8));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue