Convert RDE tests (and some test rules) from JUnit 4 to JUnit 5 (#677)

* Add JUnit Params and start using it

* Convert rest of RDE tests

* Don't check headers for generated tests

* Expand visibility to fix build breakage

* Bump JUnit versions to 5.6.2
This commit is contained in:
Ben McIlwain 2020-07-10 21:32:36 -04:00 committed by GitHub
parent a52d99ca47
commit 10b23e590e
63 changed files with 715 additions and 829 deletions

View file

@ -61,12 +61,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.json:json:20160212 org.json:json:20160212
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -61,12 +61,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.json:json:20160212 org.json:json:20160212
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -61,12 +61,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.json:json:20160212 org.json:json:20160212
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -61,12 +61,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.json:json:20160212 org.json:json:20160212
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -20,10 +20,10 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -20,10 +20,10 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -21,10 +21,10 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -21,10 +21,10 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -77,9 +77,9 @@ PRESUBMITS = {
PresubmitCheck( PresubmitCheck(
r".*Copyright 20\d{2} The Nomulus Authors\. All Rights Reserved\.", r".*Copyright 20\d{2} The Nomulus Authors\. All Rights Reserved\.",
("java", "js", "soy", "sql", "py", "sh", "gradle"), { ("java", "js", "soy", "sql", "py", "sh", "gradle"), {
".git", "/build/", "/generated/", "node_modules/", ".git", "/build/", "/generated/", "/generated_tests/",
"JUnitBackports.java", "registrar_bin.", "registrar_dbg.", "node_modules/", "JUnitBackports.java", "registrar_bin.",
"google-java-format-diff.py", "registrar_dbg.", "google-java-format-diff.py",
"nomulus.golden.sql", "soyutils_usegoog.js" "nomulus.golden.sql", "soyutils_usegoog.js"
}, REQUIRED): }, REQUIRED):
"File did not include the license header.", "File did not include the license header.",

View file

@ -312,6 +312,7 @@ dependencies {
testCompile deps['org.junit.jupiter:junit-jupiter-api'] testCompile deps['org.junit.jupiter:junit-jupiter-api']
testCompile deps['org.junit.jupiter:junit-jupiter-engine'] testCompile deps['org.junit.jupiter:junit-jupiter-engine']
testCompile deps['org.junit.jupiter:junit-jupiter-migrationsupport'] testCompile deps['org.junit.jupiter:junit-jupiter-migrationsupport']
testCompile deps['org.junit.jupiter:junit-jupiter-params']
testCompile deps['org.junit.platform:junit-platform-runner'] testCompile deps['org.junit.platform:junit-platform-runner']
testCompile deps['org.junit.platform:junit-platform-suite-api'] testCompile deps['org.junit.platform:junit-platform-suite-api']
testCompile deps['org.junit.vintage:junit-vintage-engine'] testCompile deps['org.junit.vintage:junit-vintage-engine']

View file

@ -246,6 +246,7 @@ org.json:json:20160810
org.junit.jupiter:junit-jupiter-api:5.6.2 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.2 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2 org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2
org.junit.jupiter:junit-jupiter-params:5.6.2
org.junit.platform:junit-platform-commons:1.6.2 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.2 org.junit.platform:junit-platform-engine:1.6.2
org.junit.platform:junit-platform-launcher:1.6.2 org.junit.platform:junit-platform-launcher:1.6.2

View file

@ -244,6 +244,7 @@ org.json:json:20160810
org.junit.jupiter:junit-jupiter-api:5.6.2 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.2 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2 org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2
org.junit.jupiter:junit-jupiter-params:5.6.2
org.junit.platform:junit-platform-commons:1.6.2 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.2 org.junit.platform:junit-platform-engine:1.6.2
org.junit.platform:junit-platform-launcher:1.6.2 org.junit.platform:junit-platform-launcher:1.6.2

View file

@ -249,6 +249,7 @@ org.json:json:20160810
org.junit.jupiter:junit-jupiter-api:5.6.2 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.2 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2 org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2
org.junit.jupiter:junit-jupiter-params:5.6.2
org.junit.platform:junit-platform-commons:1.6.2 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.2 org.junit.platform:junit-platform-engine:1.6.2
org.junit.platform:junit-platform-launcher:1.6.2 org.junit.platform:junit-platform-launcher:1.6.2

View file

@ -249,6 +249,7 @@ org.json:json:20160810
org.junit.jupiter:junit-jupiter-api:5.6.2 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.2 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2 org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2
org.junit.jupiter:junit-jupiter-params:5.6.2
org.junit.platform:junit-platform-commons:1.6.2 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.2 org.junit.platform:junit-platform-engine:1.6.2
org.junit.platform:junit-platform-launcher:1.6.2 org.junit.platform:junit-platform-launcher:1.6.2

View file

@ -29,17 +29,13 @@ import org.bouncycastle.openpgp.PGPUtil;
import org.bouncycastle.openpgp.bc.BcPGPSecretKeyRing; import org.bouncycastle.openpgp.bc.BcPGPSecretKeyRing;
import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder; import org.bouncycastle.openpgp.operator.bc.BcPBESecretKeyDecryptorBuilder;
import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider; import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link KeySerializer}. */ /** Unit tests for {@link KeySerializer}. */
@RunWith(JUnit4.class) class KeySerializerTest {
public class KeySerializerTest {
@Rule @RegisterExtension final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
/** /**
* An Armored representation of a pgp secret key. * An Armored representation of a pgp secret key.
@ -50,65 +46,65 @@ public class KeySerializerTest {
*/ */
private static final String ARMORED_KEY_STRING = private static final String ARMORED_KEY_STRING =
"-----BEGIN PGP PRIVATE KEY BLOCK-----\n" "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
+ "Version: GnuPG v1\n" + "Version: GnuPG v1\n"
+ "\n" + "\n"
+ "lQO+BFjbx+IBCADO3hs5CE2fIorcq8+yBdnVb1+pyPrm/48vIHCIhFHeqBjmxuY9\n" + "lQO+BFjbx+IBCADO3hs5CE2fIorcq8+yBdnVb1+pyPrm/48vIHCIhFHeqBjmxuY9\n"
+ "cdgRjiNTXp8Rs1N4e1cXWtiA2vuoBmkLF1REckgyPyocn/ssta/pRHd4fqskrQwJ\n" + "cdgRjiNTXp8Rs1N4e1cXWtiA2vuoBmkLF1REckgyPyocn/ssta/pRHd4fqskrQwJ\n"
+ "CoIoQaP3bd+KSUJoxTSckWgXFQnoNWj1kg5gv8WnY7nWB0jtjwyGSQoHy/pK3h94\n" + "CoIoQaP3bd+KSUJoxTSckWgXFQnoNWj1kg5gv8WnY7nWB0jtjwyGSQoHy/pK3h94\n"
+ "GDrHg5CQBVZ3N6NBob9bGoEhi53gh/1UIUS8GVSLS9Qwt26+3oJ1RlGl7PQoDjeK\n" + "GDrHg5CQBVZ3N6NBob9bGoEhi53gh/1UIUS8GVSLS9Qwt26+3oJ1RlGl7PQoDjeK\n"
+ "oraY8i0sl9rD06qVTFtmXLHHogP4WgD6GItTam7flPqXXNzl0PUk0mTcv9cwt4VP\n" + "oraY8i0sl9rD06qVTFtmXLHHogP4WgD6GItTam7flPqXXNzl0PUk0mTcv9cwt4VP\n"
+ "WZ5YJ7y5CqNhwqU9YeirbooHq6T9+nHxU2ddABEBAAH+AwMCjPetoiDH5m5gRgn4\n" + "WZ5YJ7y5CqNhwqU9YeirbooHq6T9+nHxU2ddABEBAAH+AwMCjPetoiDH5m5gRgn4\n"
+ "FB3io2zclIcCEnvfby1VZ/82u2nZXtSK9N5twf6pWH4KD1/3VkgqlEBhrQkqz8v4\n" + "FB3io2zclIcCEnvfby1VZ/82u2nZXtSK9N5twf6pWH4KD1/3VkgqlEBhrQkqz8v4\n"
+ "C5AWObWT1lF1hQkh/O6OFTPN7DMUSqLX/z6qXv7c5fMFU69CGq6B64s/SMKxfI1p\n" + "C5AWObWT1lF1hQkh/O6OFTPN7DMUSqLX/z6qXv7c5fMFU69CGq6B64s/SMKxfI1p\n"
+ "roDoFA912GlVH89ZT8BDtTahQQzJyHL/61KZVMidLt6IqeWsI3XCy1u8/WkLYkBG\n" + "roDoFA912GlVH89ZT8BDtTahQQzJyHL/61KZVMidLt6IqeWsI3XCy1u8/WkLYkBG\n"
+ "dqvCPBf2mlVeEOwmoAPWTMvV1lHlvauu4ofLJh8VYoO+wziX86yiQ37tsPN8Jspx\n" + "dqvCPBf2mlVeEOwmoAPWTMvV1lHlvauu4ofLJh8VYoO+wziX86yiQ37tsPN8Jspx\n"
+ "gpaiSH6f2x+I7vXFKO2ThqC8jNjfQFLnQ9yWtDYVtLgA6POMLFNOb9c733lzvHPU\n" + "gpaiSH6f2x+I7vXFKO2ThqC8jNjfQFLnQ9yWtDYVtLgA6POMLFNOb9c733lzvHPU\n"
+ "UgQRCumAyTeX0wLoC2rEG3Qu/o+Sbm10BNQmkNBxH+Pkdk+ubO/4lvaY8+nxWw1t\n" + "UgQRCumAyTeX0wLoC2rEG3Qu/o+Sbm10BNQmkNBxH+Pkdk+ubO/4lvaY8+nxWw1t\n"
+ "sIzoUoln1dHo5lbJsA/++ttNZsAMPlGB5nDC/EmhUHjKDhRpj9OwX+aFxAbBpJXg\n" + "sIzoUoln1dHo5lbJsA/++ttNZsAMPlGB5nDC/EmhUHjKDhRpj9OwX+aFxAbBpJXg\n"
+ "BKBirm7VnWp+rUd5YlwKDOJFLlNKgFmh8XBTTpe9DE/qKvnABlFjdhXpUXYEMfHw\n" + "BKBirm7VnWp+rUd5YlwKDOJFLlNKgFmh8XBTTpe9DE/qKvnABlFjdhXpUXYEMfHw\n"
+ "D7mS1J3gtd2Iz24pwbL52XA+M5nIWnX0A9N4pi/k+3M02T6up/qcqArjf/CFFZS1\n" + "D7mS1J3gtd2Iz24pwbL52XA+M5nIWnX0A9N4pi/k+3M02T6up/qcqArjf/CFFZS1\n"
+ "CSng1xYPBrxDJyIXTsFFQ7kEJrSUyvXylsLHVeXZmnwqmmjh8RFohTWecDSHgxi6\n" + "CSng1xYPBrxDJyIXTsFFQ7kEJrSUyvXylsLHVeXZmnwqmmjh8RFohTWecDSHgxi6\n"
+ "R4m9ZHVagWxecDvNmxY5vPRzhNmP5w/teCMVnEHH5VXktBmbn8TW3hLaFHs2H88b\n" + "R4m9ZHVagWxecDvNmxY5vPRzhNmP5w/teCMVnEHH5VXktBmbn8TW3hLaFHs2H88b\n"
+ "xovFXrn1pQ7hg6KLURbhXsBQlL/3NXFSXYc5cimP4lewnd6sqlnSfY/o9JujgoAV\n" + "xovFXrn1pQ7hg6KLURbhXsBQlL/3NXFSXYc5cimP4lewnd6sqlnSfY/o9JujgoAV\n"
+ "v1Wo63Jjl9fhlu8Vr/sHrAPWQS9mWzMUJy6EcTJRop39J90fPqcsz7Iz4gdH8QNY\n" + "v1Wo63Jjl9fhlu8Vr/sHrAPWQS9mWzMUJy6EcTJRop39J90fPqcsz7Iz4gdH8QNY\n"
+ "ve/iLjIuGbkK4KevptD7oR4zUIwKUpIKVJTr1Q2ukKU0pAVCyn19nRAR1RGri81L\n" + "ve/iLjIuGbkK4KevptD7oR4zUIwKUpIKVJTr1Q2ukKU0pAVCyn19nRAR1RGri81L\n"
+ "jbRAR1RMRCBUZXN0ZXIgKFRoaXMga2V5IGlzIHVzZWQgZm9yIHRlc3RzIG9ubHkp\n" + "jbRAR1RMRCBUZXN0ZXIgKFRoaXMga2V5IGlzIHVzZWQgZm9yIHRlc3RzIG9ubHkp\n"
+ "IDx0ZXN0ZXJAdGVzdC50ZXN0PokBOAQTAQIAIgUCWNvH4gIbAwYLCQgHAwIGFQgC\n" + "IDx0ZXN0ZXJAdGVzdC50ZXN0PokBOAQTAQIAIgUCWNvH4gIbAwYLCQgHAwIGFQgC\n"
+ "CQoLBBYCAwECHgECF4AACgkQxCHL9+c/Gv2LKgf+KdUPUlKq0N3oSzXk5RcXJZDT\n" + "CQoLBBYCAwECHgECF4AACgkQxCHL9+c/Gv2LKgf+KdUPUlKq0N3oSzXk5RcXJZDT\n"
+ "v8teeLXyu3loaXzEuK89/V5BdDL5nRu8+GUhfFRkd/LFv0rwehcJZ5TtXghukk6r\n" + "v8teeLXyu3loaXzEuK89/V5BdDL5nRu8+GUhfFRkd/LFv0rwehcJZ5TtXghukk6r\n"
+ "5kvekPf8vVjgMO89RrmiW2oKqqmhP8VZd1T1vQacQ4J6eNKCjbuLym47m4Vp9VZm\n" + "5kvekPf8vVjgMO89RrmiW2oKqqmhP8VZd1T1vQacQ4J6eNKCjbuLym47m4Vp9VZm\n"
+ "lHNGNgkDbU1zVxhF23rLqOqzltiIcyCafMPFJNRUANlLkEIvAo8dGziqn5l2X71w\n" + "lHNGNgkDbU1zVxhF23rLqOqzltiIcyCafMPFJNRUANlLkEIvAo8dGziqn5l2X71w\n"
+ "9KQw4LzQHrR1ulm0h4SbYwhQQ2Qz1FzfVjyuRUjye5QJxLEa9M92l1oLMjubt3Qx\n" + "9KQw4LzQHrR1ulm0h4SbYwhQQ2Qz1FzfVjyuRUjye5QJxLEa9M92l1oLMjubt3Qx\n"
+ "QEiL05Bp3uYd+S97BuxbDFz+hNUHfIaSVuwrVgdz2tcwBTyBl2jUTukKC2nMfJ0D\n" + "QEiL05Bp3uYd+S97BuxbDFz+hNUHfIaSVuwrVgdz2tcwBTyBl2jUTukKC2nMfJ0D\n"
+ "vgRY28fiAQgA3qW5JTZNG26Iv9k+cysl5TWeAO71yrEAL4WAXoKQYIEVMcCi3Rt9\n" + "vgRY28fiAQgA3qW5JTZNG26Iv9k+cysl5TWeAO71yrEAL4WAXoKQYIEVMcCi3Rt9\n"
+ "YW+FhZ+z056n3EZsgIYsPniipdyRBrehQI5f9CRFcyqkMu8tuBIqsJaZAhcMcYoN\n" + "YW+FhZ+z056n3EZsgIYsPniipdyRBrehQI5f9CRFcyqkMu8tuBIqsJaZAhcMcYoN\n"
+ "zNWqk7mK5Wjp4yfQAEkyb13YXg+zFEtBiEOG5FPonA+vGIFeOUKSR0s+hoxhcBvS\n" + "zNWqk7mK5Wjp4yfQAEkyb13YXg+zFEtBiEOG5FPonA+vGIFeOUKSR0s+hoxhcBvS\n"
+ "Q5BGXlHP20UQBdLtPfnOx+scI9sjYBtO13ZaURBnsHfHSyDnNa5HZD6eTk7V8bjy\n" + "Q5BGXlHP20UQBdLtPfnOx+scI9sjYBtO13ZaURBnsHfHSyDnNa5HZD6eTk7V8bjy\n"
+ "ScUDHOW/Ujva3yH/7KQeR42cdba38zpvSlivwIpnGtNlhABR+mZhee5BwxGNusJ9\n" + "ScUDHOW/Ujva3yH/7KQeR42cdba38zpvSlivwIpnGtNlhABR+mZhee5BwxGNusJ9\n"
+ "D/Xi8dSSjpwZH8b6fHhwoSpb5AK6tvGgHwARAQAB/gMDAoz3raIgx+ZuYJS4j+fX\n" + "D/Xi8dSSjpwZH8b6fHhwoSpb5AK6tvGgHwARAQAB/gMDAoz3raIgx+ZuYJS4j+fX\n"
+ "6PmrHg+nOoes3i2RufCvjMhRSMU+aZo1e8fNWP9NnVKPna9Ya2PHGkHHUZlx6CE9\n" + "6PmrHg+nOoes3i2RufCvjMhRSMU+aZo1e8fNWP9NnVKPna9Ya2PHGkHHUZlx6CE9\n"
+ "EPvMwl9d8web5vBSCkzNwtUtgCrShk7cyDbHq7dLzbqxZTZK+HKX6CGL3dAC1Z1J\n" + "EPvMwl9d8web5vBSCkzNwtUtgCrShk7cyDbHq7dLzbqxZTZK+HKX6CGL3dAC1Z1J\n"
+ "zvgpj6enpTZSKSbxkPSGcxlXkT/hm7x+wYXsPgbMGH/rRnHJ1Ycg4nlHxq7sPgHK\n" + "zvgpj6enpTZSKSbxkPSGcxlXkT/hm7x+wYXsPgbMGH/rRnHJ1Ycg4nlHxq7sPgHK\n"
+ "Jgfl3a4WuyN6Ja1mVPPYxSSyKusFdXZHreqR+GLwGc2PsKjQy870uJPF4zBGYya1\n" + "Jgfl3a4WuyN6Ja1mVPPYxSSyKusFdXZHreqR+GLwGc2PsKjQy870uJPF4zBGYya1\n"
+ "iJ/8o5xJ1OxLa+SrvPExgkFmt271SHFAYk0Xx/IUshZZVP+3i8HHo7yMKEANxM+n\n" + "iJ/8o5xJ1OxLa+SrvPExgkFmt271SHFAYk0Xx/IUshZZVP+3i8HHo7yMKEANxM+n\n"
+ "Mcr9MW963Dm8thbxy3yC2GvufYz13yJJeWnMel/enSDvSieUAFsEH4NalE7HX7Mv\n" + "Mcr9MW963Dm8thbxy3yC2GvufYz13yJJeWnMel/enSDvSieUAFsEH4NalE7HX7Mv\n"
+ "NoBx6wuQTFVdojauXrERD75vYGamMC1/0h+6rzejE4HP0iDHlujJmkucAD2K8ibb\n" + "NoBx6wuQTFVdojauXrERD75vYGamMC1/0h+6rzejE4HP0iDHlujJmkucAD2K8ibb\n"
+ "ax4QiRJtatel48wYqjIkhZ8x6mFaUiBL34iyh4t0vY0CgZOsEIegy1pRkoO8u72T\n" + "ax4QiRJtatel48wYqjIkhZ8x6mFaUiBL34iyh4t0vY0CgZOsEIegy1pRkoO8u72T\n"
+ "rcgFHhHQgtf6OaPG4QnSWbxrftRmZe7W4K5tyrmoLHjsm6exAFcTmpl79qE8Mn+7\n" + "rcgFHhHQgtf6OaPG4QnSWbxrftRmZe7W4K5tyrmoLHjsm6exAFcTmpl79qE8Mn+7\n"
+ "jTspdKeTkhse5K/7ct749kZDD8FwVhSP9vqfbDhwmdmCQNp5rRQKm1+YBnamlnuz\n" + "jTspdKeTkhse5K/7ct749kZDD8FwVhSP9vqfbDhwmdmCQNp5rRQKm1+YBnamlnuz\n"
+ "IEWzxmQ2NqjEeV65bk7BfnbHYe42ZNNIzE4XahzrBVwhtMaLGLz/7YF4Czwrbn0D\n" + "IEWzxmQ2NqjEeV65bk7BfnbHYe42ZNNIzE4XahzrBVwhtMaLGLz/7YF4Czwrbn0D\n"
+ "KQwjp5qbjDAO+0FCOxN4xFItazp0bKlHnGYflEPLbFoeplBfi2sZfmQ6PUmA3UPr\n" + "KQwjp5qbjDAO+0FCOxN4xFItazp0bKlHnGYflEPLbFoeplBfi2sZfmQ6PUmA3UPr\n"
+ "T96e6fHBsctYVa4JP0HWKGcwYIhih9uD53UFsg0BJW5iXsGfMzuEo2TUXBD5qFUN\n" + "T96e6fHBsctYVa4JP0HWKGcwYIhih9uD53UFsg0BJW5iXsGfMzuEo2TUXBD5qFUN\n"
+ "xrS5Nt/Ra1psaaZxXDeiHWM5qlmk37xoFjnPV5RV0014TqNr//VHgJknWNuhcMqJ\n" + "xrS5Nt/Ra1psaaZxXDeiHWM5qlmk37xoFjnPV5RV0014TqNr//VHgJknWNuhcMqJ\n"
+ "AR8EGAECAAkFAljbx+ICGwwACgkQxCHL9+c/Gv1WzQf+Ihv0zeOFOZdvI6xOTVXS\n" + "AR8EGAECAAkFAljbx+ICGwwACgkQxCHL9+c/Gv1WzQf+Ihv0zeOFOZdvI6xOTVXS\n"
+ "qBg6k1aMdbwqshaHEvLhAY00XQmhPr65ymEJVaWRloviQ76dN9k4tTi6lYX/CGob\n" + "qBg6k1aMdbwqshaHEvLhAY00XQmhPr65ymEJVaWRloviQ76dN9k4tTi6lYX/CGob\n"
+ "bi3fUNDNQGKdyvhoxtneKsXw/3LfFh7JphVWQizh/yJHsKFvzmmMpnC4WTJ3NBTe\n" + "bi3fUNDNQGKdyvhoxtneKsXw/3LfFh7JphVWQizh/yJHsKFvzmmMpnC4WTJ3NBTe\n"
+ "G+CcHlGdFYuxc4+Z9nZG2jOorQtlFGLEqLzdM8+OJ8KyOqvaOpa0vaMyvN40QiGv\n" + "G+CcHlGdFYuxc4+Z9nZG2jOorQtlFGLEqLzdM8+OJ8KyOqvaOpa0vaMyvN40QiGv\n"
+ "raEbRpkDbxJiPp4RuPiu7S8KwKpmjgmuAXaoYKcrL8KIt9WvYWQirW8oZcbP3g/1\n" + "raEbRpkDbxJiPp4RuPiu7S8KwKpmjgmuAXaoYKcrL8KIt9WvYWQirW8oZcbP3g/1\n"
+ "laUCBMklv75toeXKeYi5Y74CvnPuciCKsNtm0fZkmhfE1vpPFn4/UqRmDtPrToVQ\n" + "laUCBMklv75toeXKeYi5Y74CvnPuciCKsNtm0fZkmhfE1vpPFn4/UqRmDtPrToVQ\n"
+ "GQ==\n" + "GQ==\n"
+ "=qeFB\n" + "=qeFB\n"
+ "-----END PGP PRIVATE KEY BLOCK-----\n"; + "-----END PGP PRIVATE KEY BLOCK-----\n";
private static final BcPGPSecretKeyRing SECRET_KEYRING = getSecretKeyring(); private static final BcPGPSecretKeyRing SECRET_KEYRING = getSecretKeyring();
@ -139,20 +135,22 @@ public class KeySerializerTest {
} }
} }
@Test public void serializeString() { @Test
void serializeString() {
String result = KeySerializer.deserializeString(KeySerializer.serializeString("value\n")); String result = KeySerializer.deserializeString(KeySerializer.serializeString("value\n"));
assertThat(result).isEqualTo("value\n"); assertThat(result).isEqualTo("value\n");
} }
@Test public void serializePublicKey() throws Exception { @Test
void serializePublicKey() throws Exception {
PGPPublicKey publicKeyResult = PGPPublicKey publicKeyResult =
KeySerializer.deserializePublicKey( KeySerializer.deserializePublicKey(KeySerializer.serializePublicKey(PUBLIC_KEY));
KeySerializer.serializePublicKey(PUBLIC_KEY));
assertThat(publicKeyResult.getEncoded()).isEqualTo(PUBLIC_KEY.getEncoded()); assertThat(publicKeyResult.getEncoded()).isEqualTo(PUBLIC_KEY.getEncoded());
} }
@Test public void serializeKeyPair() throws Exception { @Test
void serializeKeyPair() throws Exception {
PGPKeyPair keyPairResult = PGPKeyPair keyPairResult =
KeySerializer.deserializeKeyPair( KeySerializer.deserializeKeyPair(
KeySerializer.serializeKeyPair(new PGPKeyPair(PUBLIC_KEY, PRIVATE_KEY))); KeySerializer.serializeKeyPair(new PGPKeyPair(PUBLIC_KEY, PRIVATE_KEY)));

View file

@ -26,67 +26,57 @@ import google.registry.testing.BouncyCastleProviderRule;
import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) /** Unit tests for {@link KmsKeyring}. */
public class KmsKeyringTest { class KmsKeyringTest {
@Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); @RegisterExtension final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
private KmsKeyring keyring; private KmsKeyring keyring;
@Before @BeforeEach
public void setUp() { void beforeEach() {
keyring = new KmsKeyring(new FakeKmsConnection()); keyring = new KmsKeyring(new FakeKmsConnection());
} }
@Test @Test
public void test_getCloudSqlPassword() throws Exception { void test_getCloudSqlPassword() {
saveCleartextSecret("cloud-sql-password-string"); saveCleartextSecret("cloud-sql-password-string");
String cloudSqlPassword = keyring.getCloudSqlPassword(); String cloudSqlPassword = keyring.getCloudSqlPassword();
assertThat(cloudSqlPassword).isEqualTo("cloud-sql-password-stringmoo"); assertThat(cloudSqlPassword).isEqualTo("cloud-sql-password-stringmoo");
} }
@Test @Test
public void test_getToolsCloudSqlPassword() throws Exception { void test_getToolsCloudSqlPassword() {
saveCleartextSecret("tools-cloud-sql-password-string"); saveCleartextSecret("tools-cloud-sql-password-string");
String toolsCloudSqlPassword = keyring.getToolsCloudSqlPassword(); String toolsCloudSqlPassword = keyring.getToolsCloudSqlPassword();
assertThat(toolsCloudSqlPassword).isEqualTo("tools-cloud-sql-password-stringmoo"); assertThat(toolsCloudSqlPassword).isEqualTo("tools-cloud-sql-password-stringmoo");
} }
@Test @Test
public void test_getRdeSigningKey() throws Exception { void test_getRdeSigningKey() throws Exception {
saveKeyPairSecret("rde-signing-public", "rde-signing-private"); saveKeyPairSecret("rde-signing-public", "rde-signing-private");
PGPKeyPair rdeSigningKey = keyring.getRdeSigningKey(); PGPKeyPair rdeSigningKey = keyring.getRdeSigningKey();
assertThat(KeySerializer.serializeKeyPair(rdeSigningKey)) assertThat(KeySerializer.serializeKeyPair(rdeSigningKey))
.isEqualTo(KeySerializer.serializeKeyPair(KmsTestHelper.getKeyPair())); .isEqualTo(KeySerializer.serializeKeyPair(KmsTestHelper.getKeyPair()));
} }
@Test @Test
public void test_getRdeStagingEncryptionKey() throws Exception { void test_getRdeStagingEncryptionKey() throws Exception {
savePublicKeySecret("rde-staging-public"); savePublicKeySecret("rde-staging-public");
PGPPublicKey rdeStagingEncryptionKey = keyring.getRdeStagingEncryptionKey(); PGPPublicKey rdeStagingEncryptionKey = keyring.getRdeStagingEncryptionKey();
assertThat(rdeStagingEncryptionKey.getFingerprint()) assertThat(rdeStagingEncryptionKey.getFingerprint())
.isEqualTo(KmsTestHelper.getPublicKey().getFingerprint()); .isEqualTo(KmsTestHelper.getPublicKey().getFingerprint());
} }
@Test @Test
public void test_getRdeStagingDecryptionKey() throws Exception { void test_getRdeStagingDecryptionKey() throws Exception {
savePrivateKeySecret("rde-staging-private"); savePrivateKeySecret("rde-staging-private");
savePublicKeySecret("rde-staging-public"); savePublicKeySecret("rde-staging-public");
@ -99,96 +89,75 @@ public class KmsKeyringTest {
} }
@Test @Test
public void test_getRdeReceiverKey() throws Exception { void test_getRdeReceiverKey() throws Exception {
savePublicKeySecret("rde-receiver-public"); savePublicKeySecret("rde-receiver-public");
PGPPublicKey rdeReceiverKey = keyring.getRdeReceiverKey(); PGPPublicKey rdeReceiverKey = keyring.getRdeReceiverKey();
assertThat(rdeReceiverKey.getFingerprint()) assertThat(rdeReceiverKey.getFingerprint())
.isEqualTo(KmsTestHelper.getPublicKey().getFingerprint()); .isEqualTo(KmsTestHelper.getPublicKey().getFingerprint());
} }
@Test @Test
public void test_getBrdaSigningKey() throws Exception { void test_getBrdaSigningKey() throws Exception {
saveKeyPairSecret("brda-signing-public", "brda-signing-private"); saveKeyPairSecret("brda-signing-public", "brda-signing-private");
PGPKeyPair brdaSigningKey = keyring.getBrdaSigningKey(); PGPKeyPair brdaSigningKey = keyring.getBrdaSigningKey();
assertThat(KeySerializer.serializeKeyPair(brdaSigningKey)) assertThat(KeySerializer.serializeKeyPair(brdaSigningKey))
.isEqualTo(KeySerializer.serializeKeyPair(KmsTestHelper.getKeyPair())); .isEqualTo(KeySerializer.serializeKeyPair(KmsTestHelper.getKeyPair()));
} }
@Test @Test
public void test_getBrdaReceiverKey() throws Exception { void test_getBrdaReceiverKey() throws Exception {
savePublicKeySecret("brda-receiver-public"); savePublicKeySecret("brda-receiver-public");
PGPPublicKey brdaReceiverKey = keyring.getBrdaReceiverKey(); PGPPublicKey brdaReceiverKey = keyring.getBrdaReceiverKey();
assertThat(brdaReceiverKey.getFingerprint()) assertThat(brdaReceiverKey.getFingerprint())
.isEqualTo(KmsTestHelper.getPublicKey().getFingerprint()); .isEqualTo(KmsTestHelper.getPublicKey().getFingerprint());
} }
@Test @Test
public void test_getRdeSshClientPublicKey() { void test_getRdeSshClientPublicKey() {
saveCleartextSecret("rde-ssh-client-public-string"); saveCleartextSecret("rde-ssh-client-public-string");
String rdeSshClientPublicKey = keyring.getRdeSshClientPublicKey(); String rdeSshClientPublicKey = keyring.getRdeSshClientPublicKey();
assertThat(rdeSshClientPublicKey).isEqualTo("rde-ssh-client-public-stringmoo"); assertThat(rdeSshClientPublicKey).isEqualTo("rde-ssh-client-public-stringmoo");
} }
@Test @Test
public void test_getRdeSshClientPrivateKey() { void test_getRdeSshClientPrivateKey() {
saveCleartextSecret("rde-ssh-client-private-string"); saveCleartextSecret("rde-ssh-client-private-string");
String rdeSshClientPrivateKey = keyring.getRdeSshClientPrivateKey(); String rdeSshClientPrivateKey = keyring.getRdeSshClientPrivateKey();
assertThat(rdeSshClientPrivateKey).isEqualTo("rde-ssh-client-private-stringmoo"); assertThat(rdeSshClientPrivateKey).isEqualTo("rde-ssh-client-private-stringmoo");
} }
@Test @Test
public void test_getIcannReportingPassword() { void test_getIcannReportingPassword() {
saveCleartextSecret("icann-reporting-password-string"); saveCleartextSecret("icann-reporting-password-string");
String icannReportingPassword = keyring.getIcannReportingPassword(); String icannReportingPassword = keyring.getIcannReportingPassword();
assertThat(icannReportingPassword).isEqualTo("icann-reporting-password-stringmoo"); assertThat(icannReportingPassword).isEqualTo("icann-reporting-password-stringmoo");
} }
@Test @Test
public void test_getMarksdbDnlLoginAndPassword() { void test_getMarksdbDnlLoginAndPassword() {
saveCleartextSecret("marksdb-dnl-login-string"); saveCleartextSecret("marksdb-dnl-login-string");
String marksdbDnlLoginAndPassword = keyring.getMarksdbDnlLoginAndPassword(); String marksdbDnlLoginAndPassword = keyring.getMarksdbDnlLoginAndPassword();
assertThat(marksdbDnlLoginAndPassword).isEqualTo("marksdb-dnl-login-stringmoo"); assertThat(marksdbDnlLoginAndPassword).isEqualTo("marksdb-dnl-login-stringmoo");
} }
@Test @Test
public void test_getMarksdbLordnPassword() { void test_getMarksdbLordnPassword() {
saveCleartextSecret("marksdb-lordn-password-string"); saveCleartextSecret("marksdb-lordn-password-string");
String marksdbLordnPassword = keyring.getMarksdbLordnPassword(); String marksdbLordnPassword = keyring.getMarksdbLordnPassword();
assertThat(marksdbLordnPassword).isEqualTo("marksdb-lordn-password-stringmoo"); assertThat(marksdbLordnPassword).isEqualTo("marksdb-lordn-password-stringmoo");
} }
@Test @Test
public void test_getMarksdbSmdrlLoginAndPassword() { void test_getMarksdbSmdrlLoginAndPassword() {
saveCleartextSecret("marksdb-smdrl-login-string"); saveCleartextSecret("marksdb-smdrl-login-string");
String marksdbSmdrlLoginAndPassword = keyring.getMarksdbSmdrlLoginAndPassword(); String marksdbSmdrlLoginAndPassword = keyring.getMarksdbSmdrlLoginAndPassword();
assertThat(marksdbSmdrlLoginAndPassword).isEqualTo("marksdb-smdrl-login-stringmoo"); assertThat(marksdbSmdrlLoginAndPassword).isEqualTo("marksdb-smdrl-login-stringmoo");
} }
@Test @Test
public void test_getJsonCredential() { void test_getJsonCredential() {
saveCleartextSecret("json-credential-string"); saveCleartextSecret("json-credential-string");
String jsonCredential = keyring.getJsonCredential(); String jsonCredential = keyring.getJsonCredential();
assertThat(jsonCredential).isEqualTo("json-credential-stringmoo"); assertThat(jsonCredential).isEqualTo("json-credential-stringmoo");
} }

View file

@ -27,29 +27,27 @@ import google.registry.testing.BouncyCastleProviderRule;
import java.io.IOException; import java.io.IOException;
import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) /** Unit tests for {@link KmsUpdater} */
public class KmsUpdaterTest { public class KmsUpdaterTest {
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
@Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
private KmsUpdater updater; private KmsUpdater updater;
@Before @BeforeEach
public void setUp() { void beforeEach() {
updater = new KmsUpdater(new FakeKmsConnection()); updater = new KmsUpdater(new FakeKmsConnection());
} }
@Test @Test
public void test_setMultipleSecrets() { void test_setMultipleSecrets() {
updater updater
.setMarksdbDnlLoginAndPassword("value1") .setMarksdbDnlLoginAndPassword("value1")
.setIcannReportingPassword("value2") .setIcannReportingPassword("value2")
@ -69,7 +67,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setBrdaReceiverKey() throws Exception { void test_setBrdaReceiverKey() throws Exception {
updater.setBrdaReceiverPublicKey(KmsTestHelper.getPublicKey()).update(); updater.setBrdaReceiverPublicKey(KmsTestHelper.getPublicKey()).update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -79,7 +77,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setBrdaSigningKey() throws Exception { void test_setBrdaSigningKey() throws Exception {
updater.setBrdaSigningKey(KmsTestHelper.getKeyPair()).update(); updater.setBrdaSigningKey(KmsTestHelper.getKeyPair()).update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -93,7 +91,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setCloudSqlPassword() { void test_setCloudSqlPassword() {
updater.setCloudSqlPassword("value1").update(); updater.setCloudSqlPassword("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -101,7 +99,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setToolsCloudSqlPassword() { void test_setToolsCloudSqlPassword() {
updater.setToolsCloudSqlPassword("value1").update(); updater.setToolsCloudSqlPassword("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -111,7 +109,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setIcannReportingPassword() { void test_setIcannReportingPassword() {
updater.setIcannReportingPassword("value1").update(); updater.setIcannReportingPassword("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -121,7 +119,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setJsonCredential() { void test_setJsonCredential() {
updater.setJsonCredential("value1").update(); updater.setJsonCredential("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -129,7 +127,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setMarksdbDnlLoginAndPassword() { void test_setMarksdbDnlLoginAndPassword() {
updater.setMarksdbDnlLoginAndPassword("value1").update(); updater.setMarksdbDnlLoginAndPassword("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -137,7 +135,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setMarksdbLordnPassword() { void test_setMarksdbLordnPassword() {
updater.setMarksdbLordnPassword("value1").update(); updater.setMarksdbLordnPassword("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -147,7 +145,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setMarksdbSmdrlLoginAndPassword() { void test_setMarksdbSmdrlLoginAndPassword() {
updater.setMarksdbSmdrlLoginAndPassword("value1").update(); updater.setMarksdbSmdrlLoginAndPassword("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -155,7 +153,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setRdeReceiverKey() throws Exception { void test_setRdeReceiverKey() throws Exception {
updater.setRdeReceiverPublicKey(KmsTestHelper.getPublicKey()).update(); updater.setRdeReceiverPublicKey(KmsTestHelper.getPublicKey()).update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -166,7 +164,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setRdeSigningKey() throws Exception { void test_setRdeSigningKey() throws Exception {
updater.setRdeSigningKey(KmsTestHelper.getKeyPair()).update(); updater.setRdeSigningKey(KmsTestHelper.getKeyPair()).update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -180,7 +178,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setRdeSshClientPrivateKey() { void test_setRdeSshClientPrivateKey() {
updater.setRdeSshClientPrivateKey("value1").update(); updater.setRdeSshClientPrivateKey("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -190,7 +188,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setRdeSshClientPublicKey() { void test_setRdeSshClientPublicKey() {
updater.setRdeSshClientPublicKey("value1").update(); updater.setRdeSshClientPublicKey("value1").update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(
@ -200,7 +198,7 @@ public class KmsUpdaterTest {
} }
@Test @Test
public void test_setRdeStagingKey() throws Exception { void test_setRdeStagingKey() throws Exception {
updater.setRdeStagingKey(KmsTestHelper.getKeyPair()).update(); updater.setRdeStagingKey(KmsTestHelper.getKeyPair()).update();
verifySecretAndSecretRevisionWritten( verifySecretAndSecretRevisionWritten(

View file

@ -65,10 +65,8 @@ import org.bouncycastle.openpgp.operator.bc.BcPGPDigestCalculatorProvider;
import org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory; import org.bouncycastle.openpgp.operator.bc.BcPublicKeyDataDecryptorFactory;
import org.bouncycastle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator; import org.bouncycastle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator;
import org.bouncycastle.util.encoders.Base64; import org.bouncycastle.util.encoders.Base64;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** /**
* Bouncy Castle – How does it work?! * Bouncy Castle – How does it work?!
@ -96,8 +94,6 @@ import org.junit.runners.JUnit4;
* using 1.46 so thankfully we're not far enough behind that the Bouncy Castle authors have decided * using 1.46 so thankfully we're not far enough behind that the Bouncy Castle authors have decided
* to remove these functions. But a migration effort will be necessary in the future. * to remove these functions. But a migration effort will be necessary in the future.
*/ */
@RunWith(JUnit4.class)
@SuppressWarnings("resource")
public class BouncyCastleTest { public class BouncyCastleTest {
private static final String FALL_OF_HYPERION_A_DREAM = "" private static final String FALL_OF_HYPERION_A_DREAM = ""
@ -122,11 +118,10 @@ public class BouncyCastleTest {
private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Rule @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Test @Test
public void testCompressDecompress() throws Exception { void testCompressDecompress() throws Exception {
// Compress the data and write out a compressed data OpenPGP message. // Compress the data and write out a compressed data OpenPGP message.
byte[] data; byte[] data;
try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
@ -150,7 +145,7 @@ public class BouncyCastleTest {
} }
@Test @Test
public void testSignVerify_Detached() throws Exception { void testSignVerify_Detached() throws Exception {
// Load the keys. // Load the keys.
PGPPublicKeyRing publicKeyRing = new BcPGPPublicKeyRing(PUBLIC_KEY); PGPPublicKeyRing publicKeyRing = new BcPGPPublicKeyRing(PUBLIC_KEY);
PGPSecretKeyRing privateKeyRing = new BcPGPSecretKeyRing(PRIVATE_KEY); PGPSecretKeyRing privateKeyRing = new BcPGPSecretKeyRing(PRIVATE_KEY);
@ -190,7 +185,7 @@ public class BouncyCastleTest {
} }
@Test @Test
public void testSignVerify_OnePass() throws Exception { void testSignVerify_OnePass() throws Exception {
// Load the keys. // Load the keys.
PGPPublicKeyRing publicKeyRing = new BcPGPPublicKeyRing(PUBLIC_KEY); PGPPublicKeyRing publicKeyRing = new BcPGPPublicKeyRing(PUBLIC_KEY);
PGPSecretKeyRing privateKeyRing = new BcPGPSecretKeyRing(PRIVATE_KEY); PGPSecretKeyRing privateKeyRing = new BcPGPSecretKeyRing(PRIVATE_KEY);
@ -234,7 +229,7 @@ public class BouncyCastleTest {
} }
@Test @Test
public void testEncryptDecrypt_ExplicitStyle() throws Exception { void testEncryptDecrypt_ExplicitStyle() throws Exception {
int bufferSize = 64 * 1024; int bufferSize = 64 * 1024;
// Alice loads Bob's "publicKey" into memory. // Alice loads Bob's "publicKey" into memory.
@ -275,7 +270,7 @@ public class BouncyCastleTest {
} }
@Test @Test
public void testEncryptDecrypt_KeyRingStyle() throws Exception { void testEncryptDecrypt_KeyRingStyle() throws Exception {
int bufferSize = 64 * 1024; int bufferSize = 64 * 1024;
// Alice loads Bob's "publicKey" into memory from her public key ring. // Alice loads Bob's "publicKey" into memory from her public key ring.
@ -320,7 +315,7 @@ public class BouncyCastleTest {
} }
@Test @Test
public void testCompressEncryptDecryptDecompress_KeyRingStyle() throws Exception { void testCompressEncryptDecryptDecompress_KeyRingStyle() throws Exception {
int bufsz = 64 * 1024; int bufsz = 64 * 1024;
// Alice loads Bob's "publicKey" into memory from her public key ring. // Alice loads Bob's "publicKey" into memory from her public key ring.

View file

@ -42,15 +42,12 @@ import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link BrdaCopyAction}. */ /** Unit tests for {@link BrdaCopyAction}. */
@RunWith(JUnit4.class)
public class BrdaCopyActionTest { public class BrdaCopyActionTest {
private static final ByteSource DEPOSIT_XML = RdeTestData.loadBytes("deposit_full.xml"); private static final ByteSource DEPOSIT_XML = RdeTestData.loadBytes("deposit_full.xml");
@ -64,24 +61,24 @@ public class BrdaCopyActionTest {
private static final GcsFilename SIG_FILE = private static final GcsFilename SIG_FILE =
new GcsFilename("tub", "lol_2010-10-17_thin_S1_R0.sig"); new GcsFilename("tub", "lol_2010-10-17_thin_S1_R0.sig");
@Rule @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
@Rule @RegisterExtension
public final GpgSystemCommandRule gpg = new GpgSystemCommandRule( public final GpgSystemCommandRule gpg =
RdeTestData.loadBytes("pgp-public-keyring.asc"), new GpgSystemCommandRule(
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc")); RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc"));
private static PGPPublicKey encryptKey; private static PGPPublicKey encryptKey;
private static PGPPrivateKey decryptKey; private static PGPPrivateKey decryptKey;
private static PGPPublicKey receiverKey; private static PGPPublicKey receiverKey;
private static PGPKeyPair signingKey; private static PGPKeyPair signingKey;
@BeforeClass @BeforeAll
public static void beforeClass() { static void beforeAll() {
try (Keyring keyring = new FakeKeyringModule().get()) { try (Keyring keyring = new FakeKeyringModule().get()) {
encryptKey = keyring.getRdeStagingEncryptionKey(); encryptKey = keyring.getRdeStagingEncryptionKey();
decryptKey = keyring.getRdeStagingDecryptionKey(); decryptKey = keyring.getRdeStagingDecryptionKey();
@ -94,8 +91,8 @@ public class BrdaCopyActionTest {
private final GcsUtils gcsUtils = new GcsUtils(gcsService, 1024); private final GcsUtils gcsUtils = new GcsUtils(gcsService, 1024);
private final BrdaCopyAction action = new BrdaCopyAction(); private final BrdaCopyAction action = new BrdaCopyAction();
@Before @BeforeEach
public void before() throws Exception { void beforeEach() throws Exception {
action.gcsUtils = gcsUtils; action.gcsUtils = gcsUtils;
action.tld = "lol"; action.tld = "lol";
action.watermark = DateTime.parse("2010-10-17TZ"); action.watermark = DateTime.parse("2010-10-17TZ");
@ -112,7 +109,7 @@ public class BrdaCopyActionTest {
} }
@Test @Test
public void testRun() { void testRun() {
action.run(); action.run();
assertThat(gcsUtils.existsAndNotEmpty(STAGE_FILE)).isTrue(); assertThat(gcsUtils.existsAndNotEmpty(STAGE_FILE)).isTrue();
assertThat(gcsUtils.existsAndNotEmpty(RYDE_FILE)).isTrue(); assertThat(gcsUtils.existsAndNotEmpty(RYDE_FILE)).isTrue();
@ -120,7 +117,7 @@ public class BrdaCopyActionTest {
} }
@Test @Test
public void testRun_rydeFormat() throws Exception { void testRun_rydeFormat() throws Exception {
assumeTrue(hasCommand("gpg --version")); assumeTrue(hasCommand("gpg --version"));
action.run(); action.run();
@ -167,7 +164,7 @@ public class BrdaCopyActionTest {
} }
@Test @Test
public void testRun_rydeSignature() throws Exception { void testRun_rydeSignature() throws Exception {
assumeTrue(hasCommand("gpg --version")); assumeTrue(hasCommand("gpg --version"));
action.run(); action.run();

View file

@ -47,11 +47,9 @@ import google.registry.xjc.rdecontact.XjcRdeContact;
import google.registry.xjc.rdecontact.XjcRdeContactElement; import google.registry.xjc.rdecontact.XjcRdeContactElement;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** /**
* Unit tests for {@link ContactResourceToXjcConverter}. * Unit tests for {@link ContactResourceToXjcConverter}.
@ -59,19 +57,18 @@ import org.junit.runners.JUnit4;
* <p>This tests the mapping between {@link ContactResource} and {@link XjcRdeContact} as well as * <p>This tests the mapping between {@link ContactResource} and {@link XjcRdeContact} as well as
* some exceptional conditions. * some exceptional conditions.
*/ */
@RunWith(JUnit4.class)
public class ContactResourceToXjcConverterTest { public class ContactResourceToXjcConverterTest {
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
@Before @BeforeEach
public void before() { void beforeEach() {
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
} }
@Test @Test
public void testConvertContact() { void testConvertContact() {
ContactResource contact = makeContactResource(); ContactResource contact = makeContactResource();
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(contact); XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(contact);
@ -232,7 +229,7 @@ public class ContactResourceToXjcConverterTest {
} }
@Test @Test
public void testConvertContact_absentVoiceAndFaxNumbers() { void testConvertContact_absentVoiceAndFaxNumbers() {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact( XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(
makeContactResource().asBuilder() makeContactResource().asBuilder()
.setVoiceNumber(null) .setVoiceNumber(null)
@ -243,7 +240,7 @@ public class ContactResourceToXjcConverterTest {
} }
@Test @Test
public void testConvertContact_absentDisclose() { void testConvertContact_absentDisclose() {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact( XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(
makeContactResource().asBuilder() makeContactResource().asBuilder()
.setDisclose(null) .setDisclose(null)
@ -252,7 +249,7 @@ public class ContactResourceToXjcConverterTest {
} }
@Test @Test
public void testConvertContact_absentTransferData() { void testConvertContact_absentTransferData() {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact( XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(
makeContactResource().asBuilder() makeContactResource().asBuilder()
.setLastTransferTime(null) .setLastTransferTime(null)
@ -263,7 +260,7 @@ public class ContactResourceToXjcConverterTest {
} }
@Test @Test
public void testMarshal() throws Exception { void testMarshal() throws Exception {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(makeContactResource()); XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(makeContactResource());
wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8); wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8);
} }

View file

@ -71,11 +71,9 @@ import google.registry.xjc.secdns.XjcSecdnsDsDataType;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import org.joda.money.Money; import org.joda.money.Money;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** /**
* Unit tests for {@link DomainBaseToXjcConverter}. * Unit tests for {@link DomainBaseToXjcConverter}.
@ -83,22 +81,21 @@ import org.junit.runners.JUnit4;
* <p>This tests the mapping between {@link DomainBase} and {@link XjcRdeDomain} as well as some * <p>This tests the mapping between {@link DomainBase} and {@link XjcRdeDomain} as well as some
* exceptional conditions. * exceptional conditions.
*/ */
@RunWith(JUnit4.class)
public class DomainBaseToXjcConverterTest { public class DomainBaseToXjcConverterTest {
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
private final DateTime now = DateTime.parse("2014-01-01T00:00:00Z"); private final DateTime now = DateTime.parse("2014-01-01T00:00:00Z");
private final FakeClock clock = new FakeClock(now); private final FakeClock clock = new FakeClock(now);
@Before @BeforeEach
public void before() { void beforeEach() {
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
} }
@Test @Test
public void testConvertThick() { void testConvertThick() {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL); XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL);
assertThat(bean.getClID()).isEqualTo("GetTheeBack"); assertThat(bean.getClID()).isEqualTo("GetTheeBack");
@ -179,7 +176,7 @@ public class DomainBaseToXjcConverterTest {
} }
@Test @Test
public void testConvertThin() { void testConvertThin() {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN); XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN);
assertThat(bean.getRegistrant()).isNull(); assertThat(bean.getRegistrant()).isNull();
assertThat(bean.getContacts()).isEmpty(); assertThat(bean.getContacts()).isEmpty();
@ -187,18 +184,18 @@ public class DomainBaseToXjcConverterTest {
} }
@Test @Test
public void testMarshalThick() throws Exception { void testMarshalThick() throws Exception {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL); XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL);
wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8); wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8);
} }
@Test @Test
public void testMarshalThin() throws Exception { void testMarshalThin() throws Exception {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN); XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN);
wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8); wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8);
} }
public XjcRdeDeposit wrapDeposit(XjcRdeDomain domain) { XjcRdeDeposit wrapDeposit(XjcRdeDomain domain) {
XjcRdeDeposit deposit = new XjcRdeDeposit(); XjcRdeDeposit deposit = new XjcRdeDeposit();
deposit.setId("984302"); deposit.setId("984302");
deposit.setType(XjcRdeDepositTypeType.FULL); deposit.setType(XjcRdeDepositTypeType.FULL);

View file

@ -35,18 +35,15 @@ import google.registry.testing.FakeClock;
import google.registry.testing.FakeLockHandler; import google.registry.testing.FakeLockHandler;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
import org.junit.After; import org.junit.jupiter.api.AfterEach;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link EscrowTaskRunner}. */ /** Unit tests for {@link EscrowTaskRunner}. */
@RunWith(JUnit4.class)
public class EscrowTaskRunnerTest { public class EscrowTaskRunnerTest {
@Rule @RegisterExtension
public final AppEngineRule appEngine = public final AppEngineRule appEngine =
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build(); AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
@ -57,8 +54,8 @@ public class EscrowTaskRunnerTest {
private EscrowTaskRunner runner; private EscrowTaskRunner runner;
private Registry registry; private Registry registry;
@Before @BeforeEach
public void before() { void beforeEach() {
createTld("lol"); createTld("lol");
registry = Registry.get("lol"); registry = Registry.get("lol");
runner = new EscrowTaskRunner(); runner = new EscrowTaskRunner();
@ -68,13 +65,13 @@ public class EscrowTaskRunnerTest {
DateTimeZone.setDefault(DateTimeZone.forID("America/New_York")); // Make sure UTC stuff works. DateTimeZone.setDefault(DateTimeZone.forID("America/New_York")); // Make sure UTC stuff works.
} }
@After @AfterEach
public void after() { void afterEach() {
DateTimeZone.setDefault(previousDateTimeZone); DateTimeZone.setDefault(previousDateTimeZone);
} }
@Test @Test
public void testRun_cursorIsToday_advancesCursorToTomorrow() throws Exception { void testRun_cursorIsToday_advancesCursorToTomorrow() throws Exception {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z")); clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource( persistResource(
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry)); Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-06TZ"), registry));
@ -87,7 +84,7 @@ public class EscrowTaskRunnerTest {
} }
@Test @Test
public void testRun_cursorMissing_assumesTodayAndAdvancesCursorToTomorrow() throws Exception { void testRun_cursorMissing_assumesTodayAndAdvancesCursorToTomorrow() throws Exception {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z")); clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
runner.lockRunAndRollForward( runner.lockRunAndRollForward(
task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1)); task, registry, standardSeconds(30), CursorType.RDE_STAGING, standardDays(1));
@ -98,7 +95,7 @@ public class EscrowTaskRunnerTest {
} }
@Test @Test
public void testRun_cursorInTheFuture_doesNothing() { void testRun_cursorInTheFuture_doesNothing() {
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z")); clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource( persistResource(
Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ"), registry)); Cursor.create(CursorType.RDE_STAGING, DateTime.parse("2006-06-07TZ"), registry));
@ -112,7 +109,7 @@ public class EscrowTaskRunnerTest {
} }
@Test @Test
public void testRun_lockIsntAvailable_throws503() { void testRun_lockIsntAvailable_throws503() {
String lockName = "EscrowTaskRunner " + task.getClass().getSimpleName(); String lockName = "EscrowTaskRunner " + task.getClass().getSimpleName();
clock.setTo(DateTime.parse("2006-06-06T00:30:00Z")); clock.setTo(DateTime.parse("2006-06-06T00:30:00Z"));
persistResource( persistResource(

View file

@ -14,13 +14,14 @@
package google.registry.rde; package google.registry.rde;
import static com.google.common.base.Strings.repeat;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.testing.SystemInfo.hasCommand; import static google.registry.testing.SystemInfo.hasCommand;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assume.assumeTrue; import static org.junit.Assume.assumeTrue;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.io.CharStreams; import com.google.common.io.CharStreams;
import google.registry.keyring.api.Keyring; import google.registry.keyring.api.Keyring;
import google.registry.testing.BouncyCastleProviderRule; import google.registry.testing.BouncyCastleProviderRule;
@ -32,55 +33,57 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.stream.Stream;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.junit.Rule; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.experimental.theories.DataPoints; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.experimental.theories.Theories; import org.junit.jupiter.params.provider.Arguments;
import org.junit.experimental.theories.Theory; import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runner.RunWith;
/** GnuPG integration tests for {@link Ghostryde}. */ /** GnuPG integration tests for {@link Ghostryde}. */
@RunWith(Theories.class) class GhostrydeGpgIntegrationTest {
@SuppressWarnings("resource")
public class GhostrydeGpgIntegrationTest {
@Rule @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Rule @RegisterExtension
public final GpgSystemCommandRule gpg = public final GpgSystemCommandRule gpg =
new GpgSystemCommandRule( new GpgSystemCommandRule(
RdeTestData.loadBytes("pgp-public-keyring.asc"), RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-registry.asc")); RdeTestData.loadBytes("pgp-private-keyring-registry.asc"));
@DataPoints private static final ImmutableList<String> COMMANDS = ImmutableList.of("gpg", "gpg2");
public static GpgCommand[] commands = new GpgCommand[] { private static final ImmutableList<String> CONTENTS =
new GpgCommand("gpg"), ImmutableList.of(
new GpgCommand("gpg2"), "(◕‿◕)",
}; Strings.repeat("Fanatics have their dreams, wherewith they weave\n", 1000),
"\0yolo",
"");
@DataPoints static Stream<Arguments> provideTestCombinations() {
public static Content[] contents = new Content[] { Stream.Builder<Arguments> stream = Stream.builder();
new Content("(◕‿◕)"), for (String command : COMMANDS) {
new Content(repeat("Fanatics have their dreams, wherewith they weave\n", 1000)), for (String content : CONTENTS) {
new Content("\0yolo"), stream.add(Arguments.of(command, content));
new Content(""), }
}; }
return stream.build();
}
@Theory @ParameterizedTest
public void test(GpgCommand cmd, Content content) throws Exception { @MethodSource("provideTestCombinations")
assumeTrue(hasCommand(cmd.get() + " --version")); void test(String command, String content) throws Exception {
assumeTrue(hasCommand(command + " --version"));
Keyring keyring = new FakeKeyringModule().get(); Keyring keyring = new FakeKeyringModule().get();
PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey(); PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey();
File file = new File(gpg.getCwd(), "love.gpg"); File file = new File(gpg.getCwd(), "love.gpg");
byte[] data = content.get().getBytes(UTF_8); byte[] data = content.getBytes(UTF_8);
try (OutputStream output = new FileOutputStream(file); try (OutputStream output = new FileOutputStream(file);
OutputStream ghostrydeEncoder = Ghostryde.encoder(output, publicKey)) { OutputStream ghostrydeEncoder = Ghostryde.encoder(output, publicKey)) {
ghostrydeEncoder.write(data); ghostrydeEncoder.write(data);
} }
Process pid = gpg.exec(cmd.get(), "--list-packets", "--keyid-format", "long", file.getPath()); Process pid = gpg.exec(command, "--list-packets", "--keyid-format", "long", file.getPath());
String stdout = CharStreams.toString(new InputStreamReader(pid.getInputStream(), UTF_8)); String stdout = CharStreams.toString(new InputStreamReader(pid.getInputStream(), UTF_8));
String stderr = CharStreams.toString(new InputStreamReader(pid.getErrorStream(), UTF_8)); String stderr = CharStreams.toString(new InputStreamReader(pid.getErrorStream(), UTF_8));
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0); assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
@ -90,39 +93,15 @@ public class GhostrydeGpgIntegrationTest {
assertThat(stdout).contains("name=\"" + Ghostryde.INNER_FILENAME + "\""); assertThat(stdout).contains("name=\"" + Ghostryde.INNER_FILENAME + "\"");
assertThat(stderr).contains("encrypted with 2048-bit RSA key, ID A59C132F3589A1D5"); assertThat(stderr).contains("encrypted with 2048-bit RSA key, ID A59C132F3589A1D5");
pid = gpg.exec(cmd.get(), "--use-embedded-filename", file.getPath()); pid = gpg.exec(command, "--use-embedded-filename", file.getPath());
stderr = CharStreams.toString(new InputStreamReader(pid.getErrorStream(), UTF_8)); stderr = CharStreams.toString(new InputStreamReader(pid.getErrorStream(), UTF_8));
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0); assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
File dataFile = new File(gpg.getCwd(), Ghostryde.INNER_FILENAME); File dataFile = new File(gpg.getCwd(), Ghostryde.INNER_FILENAME);
assertThat(dataFile.exists()).isTrue(); assertThat(dataFile.exists()).isTrue();
assertThat(slurp(dataFile)).isEqualTo(content.get()); assertThat(slurp(dataFile)).isEqualTo(content);
} }
private String slurp(File file) throws IOException { private String slurp(File file) throws IOException {
return CharStreams.toString(new InputStreamReader(new FileInputStream(file), UTF_8)); return CharStreams.toString(new InputStreamReader(new FileInputStream(file), UTF_8));
} }
private static class GpgCommand {
private final String value;
GpgCommand(String value) {
this.value = value;
}
String get() {
return value;
}
}
private static class Content {
private final String value;
Content(String value) {
this.value = value;
}
String get() {
return value;
}
}
} }

View file

@ -14,7 +14,6 @@
package google.registry.rde; package google.registry.rde;
import static com.google.common.base.Strings.repeat;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.keyring.api.PgpHelper.KeyRequirement.ENCRYPT; import static google.registry.keyring.api.PgpHelper.KeyRequirement.ENCRYPT;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
@ -24,6 +23,8 @@ import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertThrows;
import static org.junit.Assume.assumeThat; import static org.junit.Assume.assumeThat;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import google.registry.keyring.api.Keyring; import google.registry.keyring.api.Keyring;
import google.registry.testing.BouncyCastleProviderRule; import google.registry.testing.BouncyCastleProviderRule;
@ -33,52 +34,55 @@ import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Base64; import java.util.Base64;
import java.util.stream.Stream;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPrivateKey; import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.experimental.theories.DataPoints; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.experimental.theories.Theories; import org.junit.jupiter.params.provider.Arguments;
import org.junit.experimental.theories.Theory; import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runner.RunWith;
/** Unit tests for {@link Ghostryde}. */ /** Unit tests for {@link Ghostryde}. */
@RunWith(Theories.class)
@SuppressWarnings("resource") @SuppressWarnings("resource")
public class GhostrydeTest { public class GhostrydeTest {
@Rule @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@DataPoints private static final ImmutableList<String> CONTENTS =
public static Content[] contents = new Content[] { ImmutableList.of(
new Content("hi"), "hi",
new Content("(◕‿◕)"), "(◕‿◕)",
new Content(repeat("Fanatics have their dreams, wherewith they weave.\n", 1000)), Strings.repeat("Fanatics have their dreams, wherewith they weave\n", 1000),
new Content("\0yolo"), "\0yolo",
new Content(""), "");
};
@Theory static Stream<Arguments> provideTestCombinations() {
public void testSimpleApi(Content content) throws Exception { return CONTENTS.stream().map(Arguments::of);
}
@ParameterizedTest
@MethodSource("provideTestCombinations")
void testSimpleApi(String content) throws Exception {
Keyring keyring = new FakeKeyringModule().get(); Keyring keyring = new FakeKeyringModule().get();
byte[] data = content.get().getBytes(UTF_8); byte[] data = content.getBytes(UTF_8);
PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey(); PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey();
PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey(); PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey();
byte[] blob = Ghostryde.encode(data, publicKey); byte[] blob = Ghostryde.encode(data, publicKey);
byte[] result = Ghostryde.decode(blob, privateKey); byte[] result = Ghostryde.decode(blob, privateKey);
assertThat(new String(result, UTF_8)).isEqualTo(content.get()); assertThat(new String(result, UTF_8)).isEqualTo(content);
} }
@Theory @ParameterizedTest
public void testStreamingApi(Content content) throws Exception { @MethodSource("provideTestCombinations")
void testStreamingApi(String content) throws Exception {
Keyring keyring = new FakeKeyringModule().get(); Keyring keyring = new FakeKeyringModule().get();
byte[] data = content.get().getBytes(UTF_8); byte[] data = content.getBytes(UTF_8);
PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey(); PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey();
PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey(); PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey();
@ -94,13 +98,14 @@ public class GhostrydeTest {
} }
assertThat(bsOut.size()).isEqualTo(data.length); assertThat(bsOut.size()).isEqualTo(data.length);
assertThat(new String(bsOut.toByteArray(), UTF_8)).isEqualTo(content.get()); assertThat(new String(bsOut.toByteArray(), UTF_8)).isEqualTo(content);
} }
@Theory @ParameterizedTest
public void testStreamingApi_withSize(Content content) throws Exception { @MethodSource("provideTestCombinations")
void testStreamingApi_withSize(String content) throws Exception {
Keyring keyring = new FakeKeyringModule().get(); Keyring keyring = new FakeKeyringModule().get();
byte[] data = content.get().getBytes(UTF_8); byte[] data = content.getBytes(UTF_8);
PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey(); PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey();
ByteArrayOutputStream bsOut = new ByteArrayOutputStream(); ByteArrayOutputStream bsOut = new ByteArrayOutputStream();
@ -114,14 +119,15 @@ public class GhostrydeTest {
assertThat(Long.parseLong(new String(lenOut.toByteArray(), UTF_8))).isEqualTo(data.length); assertThat(Long.parseLong(new String(lenOut.toByteArray(), UTF_8))).isEqualTo(data.length);
} }
@Theory @ParameterizedTest
public void testFailure_tampering(Content content) throws Exception { @MethodSource("provideTestCombinations")
assumeThat(content.get().length(), is(greaterThan(100))); void testFailure_tampering(String content) throws Exception {
assumeThat(content.length(), is(greaterThan(100)));
Keyring keyring = new FakeKeyringModule().get(); Keyring keyring = new FakeKeyringModule().get();
PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey(); PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey();
PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey(); PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey();
byte[] data = content.get().getBytes(UTF_8); byte[] data = content.getBytes(UTF_8);
ByteArrayOutputStream bsOut = new ByteArrayOutputStream(); ByteArrayOutputStream bsOut = new ByteArrayOutputStream();
try (OutputStream encoder = Ghostryde.encoder(bsOut, publicKey)) { try (OutputStream encoder = Ghostryde.encoder(bsOut, publicKey)) {
@ -143,14 +149,15 @@ public class GhostrydeTest {
assertThat(thrown).hasMessageThat().contains("tampering"); assertThat(thrown).hasMessageThat().contains("tampering");
} }
@Theory @ParameterizedTest
public void testFailure_corruption(Content content) throws Exception { @MethodSource("provideTestCombinations")
assumeThat(content.get().length(), is(lessThan(100))); void testFailure_corruption(String content) throws Exception {
assumeThat(content.length(), is(lessThan(100)));
Keyring keyring = new FakeKeyringModule().get(); Keyring keyring = new FakeKeyringModule().get();
PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey(); PGPPublicKey publicKey = keyring.getRdeStagingEncryptionKey();
PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey(); PGPPrivateKey privateKey = keyring.getRdeStagingDecryptionKey();
byte[] data = content.get().getBytes(UTF_8); byte[] data = content.getBytes(UTF_8);
ByteArrayOutputStream bsOut = new ByteArrayOutputStream(); ByteArrayOutputStream bsOut = new ByteArrayOutputStream();
try (OutputStream encoder = Ghostryde.encoder(bsOut, publicKey)) { try (OutputStream encoder = Ghostryde.encoder(bsOut, publicKey)) {
@ -173,7 +180,7 @@ public class GhostrydeTest {
} }
@Test @Test
public void testFullEncryption() throws Exception { void testFullEncryption() throws Exception {
// Check that the full encryption hasn't changed. All the other tests check that encrypting and // Check that the full encryption hasn't changed. All the other tests check that encrypting and
// decrypting results in the original data, but not whether the encryption method has changed. // decrypting results in the original data, but not whether the encryption method has changed.
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
@ -207,7 +214,7 @@ public class GhostrydeTest {
} }
@Test @Test
public void testFailure_keyMismatch() throws Exception { void testFailure_keyMismatch() throws Exception {
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
byte[] data = "Fanatics have their dreams, wherewith they weave.".getBytes(UTF_8); byte[] data = "Fanatics have their dreams, wherewith they weave.".getBytes(UTF_8);
PGPKeyPair dsa1 = keyringModule.get("rde-unittest@registry.test", ENCRYPT); PGPKeyPair dsa1 = keyringModule.get("rde-unittest@registry.test", ENCRYPT);
@ -238,8 +245,8 @@ public class GhostrydeTest {
} }
@Test @Test
@Ignore("Intentionally corrupting a PGP key is easier said than done >_>") @Disabled("Intentionally corrupting a PGP key is easier said than done >_>")
public void testFailure_keyCorruption() throws Exception { void testFailure_keyCorruption() throws Exception {
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
byte[] data = "Fanatics have their dreams, wherewith they weave.".getBytes(UTF_8); byte[] data = "Fanatics have their dreams, wherewith they weave.".getBytes(UTF_8);
PGPKeyPair rsa = keyringModule.get("rde-unittest@registry.test", ENCRYPT); PGPKeyPair rsa = keyringModule.get("rde-unittest@registry.test", ENCRYPT);
@ -271,16 +278,4 @@ public class GhostrydeTest {
bytes[position] = 23; bytes[position] = 23;
} }
} }
private static class Content {
private final String value;
Content(String value) {
this.value = value;
}
String get() {
return value;
}
}
} }

View file

@ -33,11 +33,9 @@ import google.registry.xjc.rdehost.XjcRdeHost;
import google.registry.xjc.rdehost.XjcRdeHostElement; import google.registry.xjc.rdehost.XjcRdeHostElement;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** /**
* Unit tests for {@link HostResourceToXjcConverter}. * Unit tests for {@link HostResourceToXjcConverter}.
@ -45,19 +43,18 @@ import org.junit.runners.JUnit4;
* <p>This tests the mapping between {@link HostResource} and {@link XjcRdeHost} as well as some * <p>This tests the mapping between {@link HostResource} and {@link XjcRdeHost} as well as some
* exceptional conditions. * exceptional conditions.
*/ */
@RunWith(JUnit4.class)
public class HostResourceToXjcConverterTest { public class HostResourceToXjcConverterTest {
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
@Before @BeforeEach
public void init() { void beforeEach() {
createTld("foobar"); createTld("foobar");
} }
@Test @Test
public void testConvertSubordinateHost() { void testConvertSubordinateHost() {
DomainBase domain = DomainBase domain =
newDomainBase("love.foobar") newDomainBase("love.foobar")
.asBuilder() .asBuilder()
@ -120,7 +117,7 @@ public class HostResourceToXjcConverterTest {
} }
@Test @Test
public void testConvertExternalHost() { void testConvertExternalHost() {
XjcRdeHost bean = XjcRdeHost bean =
HostResourceToXjcConverter.convertExternalHost( HostResourceToXjcConverter.convertExternalHost(
new HostResource.Builder() new HostResource.Builder()
@ -169,7 +166,7 @@ public class HostResourceToXjcConverterTest {
} }
@Test @Test
public void testConvertExternalHost_ipv6() { void testConvertExternalHost_ipv6() {
XjcRdeHost bean = XjcRdeHost bean =
HostResourceToXjcConverter.convertExternalHost( HostResourceToXjcConverter.convertExternalHost(
new HostResource.Builder() new HostResource.Builder()
@ -190,7 +187,7 @@ public class HostResourceToXjcConverterTest {
} }
@Test @Test
public void testHostStatusValueIsInvalid() { void testHostStatusValueIsInvalid() {
assertThrows( assertThrows(
IllegalArgumentException.class, IllegalArgumentException.class,
() -> () ->
@ -210,7 +207,7 @@ public class HostResourceToXjcConverterTest {
} }
@Test @Test
public void testMarshal() throws Exception { void testMarshal() throws Exception {
// Bean! Bean! Bean! // Bean! Bean! Bean!
XjcRdeHostElement bean = XjcRdeHostElement bean =
HostResourceToXjcConverter.convertExternal( HostResourceToXjcConverter.convertExternal(

View file

@ -35,27 +35,23 @@ import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.InjectRule; import google.registry.testing.InjectRule;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link PendingDepositChecker}. */ /** Unit tests for {@link PendingDepositChecker}. */
@RunWith(JUnit4.class)
public class PendingDepositCheckerTest { public class PendingDepositCheckerTest {
@Rule @RegisterExtension public final InjectRule inject = new InjectRule();
public final InjectRule inject = new InjectRule();
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
private final FakeClock clock = new FakeClock(); private final FakeClock clock = new FakeClock();
private final PendingDepositChecker checker = new PendingDepositChecker(); private final PendingDepositChecker checker = new PendingDepositChecker();
@Before @BeforeEach
public void before() { void beforeEach() {
inject.setStaticField(Ofy.class, "clock", clock); inject.setStaticField(Ofy.class, "clock", clock);
checker.brdaDayOfWeek = TUESDAY; checker.brdaDayOfWeek = TUESDAY;
checker.brdaInterval = standardDays(7); checker.brdaInterval = standardDays(7);
@ -64,14 +60,14 @@ public class PendingDepositCheckerTest {
} }
@Test @Test
public void testMethod_noTldsWithEscrowEnabled_returnsEmpty() { void testMethod_noTldsWithEscrowEnabled_returnsEmpty() {
createTld("pal"); createTld("pal");
createTld("fun"); createTld("fun");
assertThat(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda()).isEmpty(); assertThat(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda()).isEmpty();
} }
@Test @Test
public void testMethod_firstDeposit_depositsRdeTodayAtMidnight() { void testMethod_firstDeposit_depositsRdeTodayAtMidnight() {
clock.setTo(DateTime.parse("2000-01-01T08:00Z")); // Saturday clock.setTo(DateTime.parse("2000-01-01T08:00Z")); // Saturday
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -82,7 +78,7 @@ public class PendingDepositCheckerTest {
} }
@Test @Test
public void testMethod_firstDepositOnBrdaDay_depositsBothRdeAndBrda() { void testMethod_firstDepositOnBrdaDay_depositsBothRdeAndBrda() {
clock.setTo(DateTime.parse("2000-01-04T08:00Z")); // Tuesday clock.setTo(DateTime.parse("2000-01-04T08:00Z")); // Tuesday
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -95,7 +91,7 @@ public class PendingDepositCheckerTest {
} }
@Test @Test
public void testMethod_firstRdeDeposit_initializesCursorToMidnightToday() { void testMethod_firstRdeDeposit_initializesCursorToMidnightToday() {
clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -107,7 +103,7 @@ public class PendingDepositCheckerTest {
} }
@Test @Test
public void testMethod_subsequentRdeDeposit_doesntMutateCursor() { void testMethod_subsequentRdeDeposit_doesntMutateCursor() {
clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -120,7 +116,7 @@ public class PendingDepositCheckerTest {
} }
@Test @Test
public void testMethod_firstBrdaDepositButNotOnBrdaDay_doesntInitializeCursor() { void testMethod_firstBrdaDepositButNotOnBrdaDay_doesntInitializeCursor() {
clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
Registry registry = Registry.get("lol"); Registry registry = Registry.get("lol");
@ -133,7 +129,7 @@ public class PendingDepositCheckerTest {
} }
@Test @Test
public void testMethod_backloggedTwoDays_onlyWantsLeastRecentDay() { void testMethod_backloggedTwoDays_onlyWantsLeastRecentDay() {
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.advanceOneMilli(); clock.advanceOneMilli();
@ -146,7 +142,7 @@ public class PendingDepositCheckerTest {
} }
@Test @Test
public void testMethod_multipleTldsWithEscrowEnabled_depositsBoth() { void testMethod_multipleTldsWithEscrowEnabled_depositsBoth() {
clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday
createTldWithEscrowEnabled("pal"); createTldWithEscrowEnabled("pal");
clock.advanceOneMilli(); clock.advanceOneMilli();

View file

@ -20,23 +20,20 @@ import static google.registry.xml.ValidationMode.STRICT;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.xml.XmlTestUtils; import google.registry.xml.XmlTestUtils;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link RdeMarshaller}. */ /** Unit tests for {@link RdeMarshaller}. */
@RunWith(JUnit4.class)
public class RdeMarshallerTest { public class RdeMarshallerTest {
private static final String DECLARATION = private static final String DECLARATION =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"; "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
@Test @Test
public void testMarshalRegistrar_validData_producesXmlFragment() throws Exception { void testMarshalRegistrar_validData_producesXmlFragment() throws Exception {
DepositFragment fragment = DepositFragment fragment =
new RdeMarshaller(STRICT).marshalRegistrar(loadRegistrar("TheRegistrar")); new RdeMarshaller(STRICT).marshalRegistrar(loadRegistrar("TheRegistrar"));
assertThat(fragment.type()).isEqualTo(RdeResourceType.REGISTRAR); assertThat(fragment.type()).isEqualTo(RdeResourceType.REGISTRAR);
@ -80,7 +77,7 @@ public class RdeMarshallerTest {
} }
@Test @Test
public void testMarshalRegistrar_unicodeCharacters_dontGetMangled() { void testMarshalRegistrar_unicodeCharacters_dontGetMangled() {
DepositFragment fragment = DepositFragment fragment =
new RdeMarshaller(STRICT).marshalRegistrar(loadRegistrar("TheRegistrar")); new RdeMarshaller(STRICT).marshalRegistrar(loadRegistrar("TheRegistrar"));
assertThat(fragment.xml()).contains("123 Example Bőulevard"); assertThat(fragment.xml()).contains("123 Example Bőulevard");

View file

@ -64,24 +64,21 @@ import java.net.SocketTimeoutException;
import java.util.Map; import java.util.Map;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
/** Unit tests for {@link RdeReportAction}. */ /** Unit tests for {@link RdeReportAction}. */
@RunWith(JUnit4.class)
public class RdeReportActionTest { public class RdeReportActionTest {
private static final ByteSource REPORT_XML = RdeTestData.loadBytes("report.xml"); private static final ByteSource REPORT_XML = RdeTestData.loadBytes("report.xml");
private static final ByteSource IIRDEA_BAD_XML = RdeTestData.loadBytes("iirdea_bad.xml"); private static final ByteSource IIRDEA_BAD_XML = RdeTestData.loadBytes("iirdea_bad.xml");
private static final ByteSource IIRDEA_GOOD_XML = RdeTestData.loadBytes("iirdea_good.xml"); private static final ByteSource IIRDEA_GOOD_XML = RdeTestData.loadBytes("iirdea_good.xml");
@Rule
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Rule @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
private final FakeResponse response = new FakeResponse(); private final FakeResponse response = new FakeResponse();
@ -113,8 +110,8 @@ public class RdeReportActionTest {
return action; return action;
} }
@Before @BeforeEach
public void before() throws Exception { void beforeEach() throws Exception {
PGPPublicKey encryptKey = new FakeKeyringModule().get().getRdeStagingEncryptionKey(); PGPPublicKey encryptKey = new FakeKeyringModule().get().getRdeStagingEncryptionKey();
createTld("test"); createTld("test");
persistResource( persistResource(
@ -125,7 +122,7 @@ public class RdeReportActionTest {
} }
@Test @Test
public void testRun() { void testRun() {
createTld("lol"); createTld("lol");
RdeReportAction action = createAction(); RdeReportAction action = createAction();
action.tld = "lol"; action.tld = "lol";
@ -136,7 +133,7 @@ public class RdeReportActionTest {
} }
@Test @Test
public void testRunWithLock() throws Exception { void testRunWithLock() throws Exception {
when(httpResponse.getResponseCode()).thenReturn(SC_OK); when(httpResponse.getResponseCode()).thenReturn(SC_OK);
when(httpResponse.getContent()).thenReturn(IIRDEA_GOOD_XML.read()); when(httpResponse.getContent()).thenReturn(IIRDEA_GOOD_XML.read());
when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse); when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse);
@ -162,7 +159,7 @@ public class RdeReportActionTest {
} }
@Test @Test
public void testRunWithLock_uploadNotFinished_throws204() { void testRunWithLock_uploadNotFinished_throws204() {
persistResource( persistResource(
Cursor.create(RDE_UPLOAD, DateTime.parse("2006-06-06TZ"), Registry.get("test"))); Cursor.create(RDE_UPLOAD, DateTime.parse("2006-06-06TZ"), Registry.get("test")));
NoContentException thrown = NoContentException thrown =
@ -176,7 +173,7 @@ public class RdeReportActionTest {
} }
@Test @Test
public void testRunWithLock_badRequest_throws500WithErrorInfo() throws Exception { void testRunWithLock_badRequest_throws500WithErrorInfo() throws Exception {
when(httpResponse.getResponseCode()).thenReturn(SC_BAD_REQUEST); when(httpResponse.getResponseCode()).thenReturn(SC_BAD_REQUEST);
when(httpResponse.getContent()).thenReturn(IIRDEA_BAD_XML.read()); when(httpResponse.getContent()).thenReturn(IIRDEA_BAD_XML.read());
when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse); when(urlFetchService.fetch(request.capture())).thenReturn(httpResponse);
@ -188,7 +185,7 @@ public class RdeReportActionTest {
} }
@Test @Test
public void testRunWithLock_fetchFailed_throwsRuntimeException() throws Exception { void testRunWithLock_fetchFailed_throwsRuntimeException() throws Exception {
class ExpectedThrownException extends RuntimeException {} class ExpectedThrownException extends RuntimeException {}
when(urlFetchService.fetch(any(HTTPRequest.class))).thenThrow(new ExpectedThrownException()); when(urlFetchService.fetch(any(HTTPRequest.class))).thenThrow(new ExpectedThrownException());
assertThrows( assertThrows(
@ -196,7 +193,7 @@ public class RdeReportActionTest {
} }
@Test @Test
public void testRunWithLock_socketTimeout_doesRetry() throws Exception { void testRunWithLock_socketTimeout_doesRetry() throws Exception {
when(httpResponse.getResponseCode()).thenReturn(SC_OK); when(httpResponse.getResponseCode()).thenReturn(SC_OK);
when(httpResponse.getContent()).thenReturn(IIRDEA_GOOD_XML.read()); when(httpResponse.getContent()).thenReturn(IIRDEA_GOOD_XML.read());
when(urlFetchService.fetch(request.capture())) when(urlFetchService.fetch(request.capture()))

View file

@ -90,15 +90,12 @@ import org.bouncycastle.openpgp.PGPPublicKey;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants; import org.joda.time.DateTimeConstants;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.junit.Before; import org.junit.jupiter.api.BeforeAll;
import org.junit.BeforeClass; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link RdeStagingAction}. */ /** Unit tests for {@link RdeStagingAction}. */
@RunWith(JUnit4.class)
public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> { public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
private static final GcsFilename XML_FILE = private static final GcsFilename XML_FILE =
@ -106,8 +103,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
private static final GcsFilename LENGTH_FILE = private static final GcsFilename LENGTH_FILE =
new GcsFilename("rde-bucket", "lol_2000-01-01_full_S1_R0.xml.length"); new GcsFilename("rde-bucket", "lol_2000-01-01_full_S1_R0.xml.length");
@Rule @RegisterExtension public final InjectRule inject = new InjectRule();
public final InjectRule inject = new InjectRule();
private final FakeClock clock = new FakeClock(); private final FakeClock clock = new FakeClock();
private final FakeResponse response = new FakeResponse(); private final FakeResponse response = new FakeResponse();
@ -117,16 +113,16 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
private static PGPPublicKey encryptKey; private static PGPPublicKey encryptKey;
private static PGPPrivateKey decryptKey; private static PGPPrivateKey decryptKey;
@BeforeClass @BeforeAll
public static void beforeClass() { static void beforeAll() {
try (Keyring keyring = new FakeKeyringModule().get()) { try (Keyring keyring = new FakeKeyringModule().get()) {
encryptKey = keyring.getRdeStagingEncryptionKey(); encryptKey = keyring.getRdeStagingEncryptionKey();
decryptKey = keyring.getRdeStagingDecryptionKey(); decryptKey = keyring.getRdeStagingDecryptionKey();
} }
} }
@Before @BeforeEach
public void setup() { void beforeEach() {
inject.setStaticField(Ofy.class, "clock", clock); inject.setStaticField(Ofy.class, "clock", clock);
action = new RdeStagingAction(); action = new RdeStagingAction();
action.clock = clock; action.clock = clock;
@ -154,7 +150,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_modeInNonManualMode_throwsException() { void testRun_modeInNonManualMode_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.modeStrings = ImmutableSet.of("full"); action.modeStrings = ImmutableSet.of("full");
@ -162,7 +158,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_tldInNonManualMode_throwsException() { void testRun_tldInNonManualMode_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.tlds = ImmutableSet.of("tld"); action.tlds = ImmutableSet.of("tld");
@ -170,7 +166,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_watermarkInNonManualMode_throwsException() { void testRun_watermarkInNonManualMode_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.watermarks = ImmutableSet.of(clock.nowUtc()); action.watermarks = ImmutableSet.of(clock.nowUtc());
@ -178,7 +174,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_revisionInNonManualMode_throwsException() { void testRun_revisionInNonManualMode_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.revision = Optional.of(42); action.revision = Optional.of(42);
@ -186,14 +182,14 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_noTlds_returns204() { void testRun_noTlds_returns204() {
action.run(); action.run();
assertThat(response.getStatus()).isEqualTo(204); assertThat(response.getStatus()).isEqualTo(204);
assertNoTasksEnqueued("mapreduce"); assertNoTasksEnqueued("mapreduce");
} }
@Test @Test
public void testRun_tldWithoutEscrowEnabled_returns204() { void testRun_tldWithoutEscrowEnabled_returns204() {
createTld("lol"); createTld("lol");
persistResource(Registry.get("lol").asBuilder().setEscrowEnabled(false).build()); persistResource(Registry.get("lol").asBuilder().setEscrowEnabled(false).build());
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
@ -203,7 +199,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_tldWithEscrowEnabled_runsMapReduce() { void testRun_tldWithEscrowEnabled_runsMapReduce() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.run(); action.run();
@ -213,7 +209,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_withinTransactionCooldown_getsExcludedAndReturns204() { void testRun_withinTransactionCooldown_getsExcludedAndReturns204() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01T00:04:59Z")); clock.setTo(DateTime.parse("2000-01-01T00:04:59Z"));
action.transactionCooldown = Duration.standardMinutes(5); action.transactionCooldown = Duration.standardMinutes(5);
@ -223,7 +219,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testRun_afterTransactionCooldown_runsMapReduce() { void testRun_afterTransactionCooldown_runsMapReduce() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01T00:05:00Z")); clock.setTo(DateTime.parse("2000-01-01T00:05:00Z"));
action.transactionCooldown = Duration.standardMinutes(5); action.transactionCooldown = Duration.standardMinutes(5);
@ -232,7 +228,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testManualRun_emptyMode_throwsException() { void testManualRun_emptyMode_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.manual = true; action.manual = true;
@ -244,7 +240,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testManualRun_invalidMode_throwsException() { void testManualRun_invalidMode_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.manual = true; action.manual = true;
@ -256,7 +252,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testManualRun_emptyTld_throwsException() { void testManualRun_emptyTld_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.manual = true; action.manual = true;
@ -268,7 +264,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testManualRun_emptyWatermark_throwsException() { void testManualRun_emptyWatermark_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.manual = true; action.manual = true;
@ -280,7 +276,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testManualRun_nonDayStartWatermark_throwsException() { void testManualRun_nonDayStartWatermark_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.manual = true; action.manual = true;
@ -292,7 +288,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testManualRun_invalidRevision_throwsException() { void testManualRun_invalidRevision_throwsException() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.manual = true; action.manual = true;
@ -305,7 +301,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testManualRun_validParameters_runsMapReduce() { void testManualRun_validParameters_runsMapReduce() {
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
clock.setTo(DateTime.parse("2000-01-01TZ")); clock.setTo(DateTime.parse("2000-01-01TZ"));
action.manual = true; action.manual = true;
@ -320,7 +316,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_bunchOfResources_headerHasCorrectCounts() throws Exception { void testMapReduce_bunchOfResources_headerHasCorrectCounts() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeDomainBase(clock, "lol"); makeDomainBase(clock, "lol");
@ -350,7 +346,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_validHostResources_getPutInDeposit() throws Exception { void testMapReduce_validHostResources_getPutInDeposit() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeHostResource(clock, "ns1.cat.lol", "feed::a:bee"); makeHostResource(clock, "ns1.cat.lol", "feed::a:bee");
@ -393,7 +389,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_defaultTestFixtureRegistrars_getPutInDeposit() throws Exception { void testMapReduce_defaultTestFixtureRegistrars_getPutInDeposit() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeHostResource(clock, "ns1.cat.lol", "feed::a:bee"); makeHostResource(clock, "ns1.cat.lol", "feed::a:bee");
@ -415,7 +411,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_sameDayRdeDeposit_advancesCursorToTomorrow() throws Exception { void testMapReduce_sameDayRdeDeposit_advancesCursorToTomorrow() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeDomainBase(clock, "lol"); makeDomainBase(clock, "lol");
@ -436,7 +432,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_onBrdaDay_advancesBothCursors() throws Exception { void testMapReduce_onBrdaDay_advancesBothCursors() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeDomainBase(clock, "lol"); makeDomainBase(clock, "lol");
@ -457,7 +453,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_onBrdaDay_enqueuesBothTasks() throws Exception { void testMapReduce_onBrdaDay_enqueuesBothTasks() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeDomainBase(clock, "lol"); makeDomainBase(clock, "lol");
@ -478,7 +474,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_noEppResourcesAndWayInPast_depositsRegistrarsOnly() throws Exception { void testMapReduce_noEppResourcesAndWayInPast_depositsRegistrarsOnly() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("fop"); createTldWithEscrowEnabled("fop");
setCursor(Registry.get("fop"), RDE_STAGING, DateTime.parse("1971-01-01TZ")); setCursor(Registry.get("fop"), RDE_STAGING, DateTime.parse("1971-01-01TZ"));
@ -513,7 +509,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_idnTables_goInDeposit() throws Exception { void testMapReduce_idnTables_goInDeposit() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("fop"); createTldWithEscrowEnabled("fop");
makeDomainBase(clock, "fop"); makeDomainBase(clock, "fop");
@ -539,7 +535,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_withDomain_producesExpectedXml() throws Exception { void testMapReduce_withDomain_producesExpectedXml() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeDomainBase(clock, "lol"); makeDomainBase(clock, "lol");
@ -556,7 +552,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_withDomain_producesCorrectLengthFile() throws Exception { void testMapReduce_withDomain_producesCorrectLengthFile() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeDomainBase(clock, "lol"); makeDomainBase(clock, "lol");
@ -571,7 +567,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_withDomain_producesReportXml() throws Exception { void testMapReduce_withDomain_producesReportXml() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
makeDomainBase(clock, "lol"); makeDomainBase(clock, "lol");
@ -588,7 +584,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_twoDomainsDifferentTlds_isolatesDomains() throws Exception { void testMapReduce_twoDomainsDifferentTlds_isolatesDomains() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("boggle"); createTldWithEscrowEnabled("boggle");
makeDomainBase(clock, "boggle"); makeDomainBase(clock, "boggle");
@ -609,7 +605,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_twoHostsDifferentTlds_includedInBothTldDeposits() throws Exception { void testMapReduce_twoHostsDifferentTlds_includedInBothTldDeposits() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("fop"); createTldWithEscrowEnabled("fop");
makeHostResource(clock, "ns1.dein.fop", "a:fed::cafe"); makeHostResource(clock, "ns1.dein.fop", "a:fed::cafe");
@ -630,7 +626,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_rewindCursor_resendsDepositAtHigherRevision() throws Exception { void testMapReduce_rewindCursor_resendsDepositAtHigherRevision() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("fop"); createTldWithEscrowEnabled("fop");
makeHostResource(clock, "ns1.dein.fop", "a:fed::cafe"); makeHostResource(clock, "ns1.dein.fop", "a:fed::cafe");
@ -654,7 +650,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_brdaDeposit_doesntIncludeHostsOrContacts() throws Exception { void testMapReduce_brdaDeposit_doesntIncludeHostsOrContacts() throws Exception {
clock.setTo(DateTime.parse("1999-12-31TZ")); clock.setTo(DateTime.parse("1999-12-31TZ"));
createTldWithEscrowEnabled("xn--q9jyb4c"); createTldWithEscrowEnabled("xn--q9jyb4c");
makeHostResource(clock, "ns1.bofh.みんな", "dead:fed::cafe"); makeHostResource(clock, "ns1.bofh.みんな", "dead:fed::cafe");
@ -676,7 +672,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_catchUpCursor_doesPointInTime() throws Exception { void testMapReduce_catchUpCursor_doesPointInTime() throws Exception {
// Do nothing on the first day. // Do nothing on the first day.
clock.setTo(DateTime.parse("1984-12-17T12:00Z")); clock.setTo(DateTime.parse("1984-12-17T12:00Z"));
createTldWithEscrowEnabled("lol"); createTldWithEscrowEnabled("lol");
@ -794,8 +790,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_manualMode_generatesCorrectDepositsWithoutAdvancingCursors() void testMapReduce_manualMode_generatesCorrectDepositsWithoutAdvancingCursors() throws Exception {
throws Exception {
doManualModeMapReduceTest(0, ImmutableSet.of("lol")); doManualModeMapReduceTest(0, ImmutableSet.of("lol"));
XmlTestUtils.assertXmlEquals( XmlTestUtils.assertXmlEquals(
loadFile(getClass(), "testMapReduce_withDomain_producesExpectedXml.xml"), loadFile(getClass(), "testMapReduce_withDomain_producesExpectedXml.xml"),
@ -810,8 +805,7 @@ public class RdeStagingActionTest extends MapreduceTestCase<RdeStagingAction> {
} }
@Test @Test
public void testMapReduce_manualMode_nonZeroRevisionAndMultipleTlds() void testMapReduce_manualMode_nonZeroRevisionAndMultipleTlds() throws Exception {
throws Exception {
doManualModeMapReduceTest(42, ImmutableSet.of("lol", "slug")); doManualModeMapReduceTest(42, ImmutableSet.of("lol", "slug"));
} }

View file

@ -41,7 +41,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
/** Unit tests for {@link RdeStagingMapper}. */ /** Unit tests for {@link RdeStagingMapper}. */
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class RdeStagingMapperTest { class RdeStagingMapperTest {
private static final Pattern REGISTRAR_NAME_PATTERN = private static final Pattern REGISTRAR_NAME_PATTERN =
Pattern.compile("<rdeRegistrar:name>(.*)</rdeRegistrar:name>"); Pattern.compile("<rdeRegistrar:name>(.*)</rdeRegistrar:name>");
@ -50,7 +50,7 @@ public class RdeStagingMapperTest {
@Mock MapperContext<PendingDeposit, DepositFragment> context; @Mock MapperContext<PendingDeposit, DepositFragment> context;
ArgumentCaptor<DepositFragment> depositFragmentCaptor = private ArgumentCaptor<DepositFragment> depositFragmentCaptor =
ArgumentCaptor.forClass(DepositFragment.class); ArgumentCaptor.forClass(DepositFragment.class);
@RegisterExtension @RegisterExtension

View file

@ -14,13 +14,15 @@
package google.registry.rde; package google.registry.rde;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.platform.suite.api.SuiteDisplayName;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
/** Convenience class to run all RDE tests inside IDE with one keystroke. */ /** Convenience class to run all RDE tests inside IDE with one keystroke. */
@RunWith(Suite.class) @RunWith(JUnitPlatform.class)
@SuiteClasses({ @SuiteDisplayName("RDE tests suite")
@SelectClasses({
DomainBaseToXjcConverterTest.class, DomainBaseToXjcConverterTest.class,
GhostrydeGpgIntegrationTest.class, GhostrydeGpgIntegrationTest.class,
GhostrydeTest.class, GhostrydeTest.class,

View file

@ -83,16 +83,13 @@ import java.net.Socket;
import java.net.URI; import java.net.URI;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.rules.TemporaryFolder; import org.junit.jupiter.api.io.TempDir;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.stubbing.OngoingStubbing; import org.mockito.stubbing.OngoingStubbing;
/** Unit tests for {@link RdeUploadAction}. */ /** Unit tests for {@link RdeUploadAction}. */
@RunWith(JUnit4.class)
public class RdeUploadActionTest { public class RdeUploadActionTest {
private static final int BUFFER_SIZE = 64 * 1024; private static final int BUFFER_SIZE = 64 * 1024;
@ -113,21 +110,21 @@ public class RdeUploadActionTest {
private static final GcsFilename REPORT_R1_FILE = private static final GcsFilename REPORT_R1_FILE =
new GcsFilename("bucket", "tld_2010-10-17_full_S1_R1-report.xml.ghostryde"); new GcsFilename("bucket", "tld_2010-10-17_full_S1_R1-report.xml.ghostryde");
@Rule @RegisterExtension final SftpServerRule sftpd = new SftpServerRule();
public final SftpServerRule sftpd = new SftpServerRule();
@Rule @SuppressWarnings("WeakerAccess")
public final TemporaryFolder folder = new TemporaryFolder(); @TempDir
File folder;
@Rule @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Rule @RegisterExtension
public final GpgSystemCommandRule gpg = new GpgSystemCommandRule( public final GpgSystemCommandRule gpg =
RdeTestData.loadBytes("pgp-public-keyring.asc"), new GpgSystemCommandRule(
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc")); RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc"));
@Rule @RegisterExtension
public final AppEngineRule appEngine = public final AppEngineRule appEngine =
AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build(); AppEngineRule.builder().withDatastoreAndCloudSql().withTaskQueue().build();
@ -178,8 +175,8 @@ public class RdeUploadActionTest {
private GcsService gcsService; private GcsService gcsService;
@Before @BeforeEach
public void before() throws Exception { void beforeEach() throws Exception {
// Force "development" mode so we don't try to really connect to GCS. // Force "development" mode so we don't try to really connect to GCS.
SystemProperty.environment.set(SystemProperty.Environment.Value.Development); SystemProperty.environment.set(SystemProperty.Environment.Value.Development);
gcsService = GcsServiceFactory.createGcsService(); gcsService = GcsServiceFactory.createGcsService();
@ -201,15 +198,15 @@ public class RdeUploadActionTest {
} }
@Test @Test
public void testSocketConnection() throws Exception { void testSocketConnection() throws Exception {
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder);
try (Socket socket = new Socket("localhost", port)) { try (Socket socket = new Socket("localhost", port)) {
assertThat(socket.isConnected()).isTrue(); assertThat(socket.isConnected()).isTrue();
} }
} }
@Test @Test
public void testRun() { void testRun() {
createTld("lol"); createTld("lol");
RdeUploadAction action = createAction(null); RdeUploadAction action = createAction(null);
action.tld = "lol"; action.tld = "lol";
@ -223,8 +220,8 @@ public class RdeUploadActionTest {
} }
@Test @Test
public void testRunWithLock_succeedsOnThirdTry() throws Exception { void testRunWithLock_succeedsOnThirdTry() throws Exception {
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder);
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
@ -236,15 +233,14 @@ public class RdeUploadActionTest {
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8); assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n"); assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n");
assertNoTasksEnqueued("rde-upload"); assertNoTasksEnqueued("rde-upload");
assertThat(folder.getRoot().list()).asList() assertThat(folder.list())
.containsExactly( .asList()
"tld_2010-10-17_full_S1_R0.ryde", .containsExactly("tld_2010-10-17_full_S1_R0.ryde", "tld_2010-10-17_full_S1_R0.sig");
"tld_2010-10-17_full_S1_R0.sig");
} }
@Test @Test
public void testRunWithLock_failsAfterThreeAttempts() throws Exception { void testRunWithLock_failsAfterThreeAttempts() throws Exception {
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder);
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
@ -257,8 +253,8 @@ public class RdeUploadActionTest {
} }
@Test @Test
public void testRunWithLock_copiesOnGcs() throws Exception { void testRunWithLock_copiesOnGcs() throws Exception {
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder);
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
@ -271,17 +267,17 @@ public class RdeUploadActionTest {
// Assert that both files are written to SFTP and GCS, and that the contents are identical. // Assert that both files are written to SFTP and GCS, and that the contents are identical.
String rydeFilename = "tld_2010-10-17_full_S1_R0.ryde"; String rydeFilename = "tld_2010-10-17_full_S1_R0.ryde";
String sigFilename = "tld_2010-10-17_full_S1_R0.sig"; String sigFilename = "tld_2010-10-17_full_S1_R0.sig";
assertThat(folder.getRoot().list()).asList().containsExactly(rydeFilename, sigFilename); assertThat(folder.list()).asList().containsExactly(rydeFilename, sigFilename);
assertThat(readGcsFile(gcsService, new GcsFilename("bucket", rydeFilename))) assertThat(readGcsFile(gcsService, new GcsFilename("bucket", rydeFilename)))
.isEqualTo(Files.toByteArray(new File(folder.getRoot(), rydeFilename))); .isEqualTo(Files.toByteArray(new File(folder, rydeFilename)));
assertThat(readGcsFile(gcsService, new GcsFilename("bucket", sigFilename))) assertThat(readGcsFile(gcsService, new GcsFilename("bucket", sigFilename)))
.isEqualTo(Files.toByteArray(new File(folder.getRoot(), sigFilename))); .isEqualTo(Files.toByteArray(new File(folder, sigFilename)));
} }
@Test @Test
public void testRunWithLock_resend() throws Exception { void testRunWithLock_resend() throws Exception {
tm().transact(() -> RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 1)); tm().transact(() -> RdeRevision.saveRevision("tld", DateTime.parse("2010-10-17TZ"), FULL, 1));
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder);
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
@ -291,16 +287,15 @@ public class RdeUploadActionTest {
assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8); assertThat(response.getContentType()).isEqualTo(PLAIN_TEXT_UTF_8);
assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n"); assertThat(response.getPayload()).isEqualTo("OK tld 2010-10-17T00:00:00.000Z\n");
assertNoTasksEnqueued("rde-upload"); assertNoTasksEnqueued("rde-upload");
assertThat(folder.getRoot().list()).asList() assertThat(folder.list())
.containsExactly( .asList()
"tld_2010-10-17_full_S1_R1.ryde", .containsExactly("tld_2010-10-17_full_S1_R1.ryde", "tld_2010-10-17_full_S1_R1.sig");
"tld_2010-10-17_full_S1_R1.sig");
} }
@Test @Test
public void testRunWithLock_producesValidSignature() throws Exception { void testRunWithLock_producesValidSignature() throws Exception {
assumeTrue(hasCommand("gpg --version")); assumeTrue(hasCommand("gpg --version"));
int port = sftpd.serve("user", "password", folder.getRoot()); int port = sftpd.serve("user", "password", folder);
URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port));
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
@ -308,9 +303,12 @@ public class RdeUploadActionTest {
createAction(uploadUrl).runWithLock(uploadCursor); createAction(uploadUrl).runWithLock(uploadCursor);
// Only verify signature for SFTP versions, since we check elsewhere that the GCS files are // Only verify signature for SFTP versions, since we check elsewhere that the GCS files are
// identical to the ones sent over SFTP. // identical to the ones sent over SFTP.
Process pid = gpg.exec("gpg", "--verify", Process pid =
new File(folder.getRoot(), "tld_2010-10-17_full_S1_R0.sig").toString(), gpg.exec(
new File(folder.getRoot(), "tld_2010-10-17_full_S1_R0.ryde").toString()); "gpg",
"--verify",
new File(folder, "tld_2010-10-17_full_S1_R0.sig").toString(),
new File(folder, "tld_2010-10-17_full_S1_R0.ryde").toString());
String stderr = slurp(pid.getErrorStream()); String stderr = slurp(pid.getErrorStream());
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0); assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
assertThat(stderr).contains("Good signature"); assertThat(stderr).contains("Good signature");
@ -318,7 +316,7 @@ public class RdeUploadActionTest {
} }
@Test @Test
public void testRunWithLock_stagingNotFinished_throws204() { void testRunWithLock_stagingNotFinished_throws204() {
URI url = URI.create("sftp://user:password@localhost:32323/"); URI url = URI.create("sftp://user:password@localhost:32323/");
DateTime stagingCursor = DateTime.parse("2010-10-17TZ"); DateTime stagingCursor = DateTime.parse("2010-10-17TZ");
DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ");
@ -333,7 +331,7 @@ public class RdeUploadActionTest {
} }
@Test @Test
public void testRunWithLock_sftpCooldownNotPassed_throws204() { void testRunWithLock_sftpCooldownNotPassed_throws204() {
RdeUploadAction action = createAction(URI.create("sftp://user:password@localhost:32323/")); RdeUploadAction action = createAction(URI.create("sftp://user:password@localhost:32323/"));
action.sftpCooldown = standardHours(2); action.sftpCooldown = standardHours(2);
DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime stagingCursor = DateTime.parse("2010-10-18TZ");

View file

@ -35,11 +35,9 @@ import google.registry.xjc.rderegistrar.XjcRdeRegistrarPostalInfoType;
import google.registry.xjc.rderegistrar.XjcRdeRegistrarStatusType; import google.registry.xjc.rderegistrar.XjcRdeRegistrarStatusType;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** /**
* Unit tests for {@link RegistrarToXjcConverter}. * Unit tests for {@link RegistrarToXjcConverter}.
@ -47,19 +45,17 @@ import org.junit.runners.JUnit4;
* <p>This tests the mapping between {@link Registrar} and {@link XjcRdeRegistrar} as well as some * <p>This tests the mapping between {@link Registrar} and {@link XjcRdeRegistrar} as well as some
* exceptional conditions. * exceptional conditions.
*/ */
@RunWith(JUnit4.class)
public class RegistrarToXjcConverterTest { public class RegistrarToXjcConverterTest {
@Rule @RegisterExtension
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build(); public final AppEngineRule appEngine = AppEngineRule.builder().withDatastoreAndCloudSql().build();
@Rule @RegisterExtension public final InjectRule inject = new InjectRule();
public final InjectRule inject = new InjectRule();
Registrar registrar; private Registrar registrar;
@Before @BeforeEach
public void init() { void beforeEach() {
registrar = new Registrar.Builder() registrar = new Registrar.Builder()
.setClientId("GoblinMarket") .setClientId("GoblinMarket")
.setRegistrarName("Maids heard the goblins cry: Come buy, come buy:") .setRegistrarName("Maids heard the goblins cry: Come buy, come buy:")
@ -94,7 +90,7 @@ public class RegistrarToXjcConverterTest {
} }
@Test @Test
public void test_convertRegistrar() { void test_convertRegistrar() {
XjcRdeRegistrar bean = convertRegistrar(registrar); XjcRdeRegistrar bean = convertRegistrar(registrar);
assertThat(bean.getId()).isEqualTo("GoblinMarket"); assertThat(bean.getId()).isEqualTo("GoblinMarket");
@ -140,13 +136,13 @@ public class RegistrarToXjcConverterTest {
} }
@Test @Test
public void test_convertRegistrar_disabledStateMeansTerminated() { void test_convertRegistrar_disabledStateMeansTerminated() {
XjcRdeRegistrar bean = convertRegistrar(registrar.asBuilder().setState(State.DISABLED).build()); XjcRdeRegistrar bean = convertRegistrar(registrar.asBuilder().setState(State.DISABLED).build());
assertThat(bean.getStatus()).isEqualTo(XjcRdeRegistrarStatusType.TERMINATED); assertThat(bean.getStatus()).isEqualTo(XjcRdeRegistrarStatusType.TERMINATED);
} }
@Test @Test
public void test_convertRegistrar_handlesAllRegistrarStates() { void test_convertRegistrar_handlesAllRegistrarStates() {
for (State state : Registrar.State.values()) { for (State state : Registrar.State.values()) {
// This will throw an exception if it can't handle the chosen state. // This will throw an exception if it can't handle the chosen state.
convertRegistrar(registrar.asBuilder().setState(state).build()); convertRegistrar(registrar.asBuilder().setState(state).build());
@ -154,7 +150,7 @@ public class RegistrarToXjcConverterTest {
} }
@Test @Test
public void testMarshal() throws Exception { void testMarshal() throws Exception {
marshalStrict(RegistrarToXjcConverter.convert(registrar), new ByteArrayOutputStream(), UTF_8); marshalStrict(RegistrarToXjcConverter.convert(registrar), new ByteArrayOutputStream(), UTF_8);
} }
} }

View file

@ -22,15 +22,13 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) /** Unit tests for {@link RydeCompression} */
public final class RydeCompressionTest { final class RydeCompressionTest {
@Test @Test
public void testCompression_decompression() throws Exception { void testCompression_decompression() throws Exception {
byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8); byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8);
ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();

View file

@ -30,18 +30,16 @@ import java.io.OutputStream;
import java.util.Base64; import java.util.Base64;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPKeyPair;
import org.junit.Rule; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) /** Unit tests for {@link RydeEncryption} */
public final class RydeEncryptionTest { public final class RydeEncryptionTest {
@Rule public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule(); @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Test @Test
public void testSuccess_oneReceiver_decryptWithCorrectKey() throws Exception { void testSuccess_oneReceiver_decryptWithCorrectKey() throws Exception {
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT); PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT);
byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8); byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8);
@ -60,7 +58,7 @@ public final class RydeEncryptionTest {
} }
@Test @Test
public void testFail_oneReceiver_decryptWithWrongKey() throws Exception { void testFail_oneReceiver_decryptWithWrongKey() throws Exception {
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT); PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT);
PGPKeyPair wrongKey = keyringModule.get("rde-unittest-dsa@registry.test", ENCRYPT); PGPKeyPair wrongKey = keyringModule.get("rde-unittest-dsa@registry.test", ENCRYPT);
@ -86,7 +84,7 @@ public final class RydeEncryptionTest {
} }
@Test @Test
public void testSuccess_twoReceivers() throws Exception { void testSuccess_twoReceivers() throws Exception {
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
PGPKeyPair key1 = keyringModule.get("rde-unittest@registry.test", ENCRYPT); PGPKeyPair key1 = keyringModule.get("rde-unittest@registry.test", ENCRYPT);
PGPKeyPair key2 = keyringModule.get("rde-unittest-dsa@registry.test", ENCRYPT); PGPKeyPair key2 = keyringModule.get("rde-unittest-dsa@registry.test", ENCRYPT);
@ -113,7 +111,7 @@ public final class RydeEncryptionTest {
} }
@Test @Test
public void testSuccess_decryptHasntChanged() throws Exception { void testSuccess_decryptHasntChanged() throws Exception {
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT); PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT);
byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8); byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8);
@ -134,7 +132,7 @@ public final class RydeEncryptionTest {
} }
@Test @Test
public void testSuccess_oneReceiver_withIntegrityPacket() throws Exception { void testSuccess_oneReceiver_withIntegrityPacket() throws Exception {
FakeKeyringModule keyringModule = new FakeKeyringModule(); FakeKeyringModule keyringModule = new FakeKeyringModule();
PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT); PGPKeyPair key = keyringModule.get("rde-unittest@registry.test", ENCRYPT);
byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8); byte[] expected = "Testing 1, 2, 3".getBytes(UTF_8);

View file

@ -22,15 +22,13 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) /** Unit tests for {@link RydeFileEncoding}. */
public final class RydeFileEncodingTest { final class RydeFileEncodingTest {
@Test @Test
public void testEncodeDecode() throws Exception { void testEncodeDecode() throws Exception {
byte[] expectedContent = "Testing 1, 2, 3".getBytes(UTF_8); byte[] expectedContent = "Testing 1, 2, 3".getBytes(UTF_8);
String expectedFilename = "myFile.txt"; String expectedFilename = "myFile.txt";
DateTime expectedModified = DateTime.parse("2015-12-25T06:30:00.000Z"); DateTime expectedModified = DateTime.parse("2015-12-25T06:30:00.000Z");

View file

@ -14,13 +14,14 @@
package google.registry.rde; package google.registry.rde;
import static com.google.common.base.Strings.repeat;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.testing.SystemInfo.hasCommand; import static google.registry.testing.SystemInfo.hasCommand;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assume.assumeTrue; import static org.junit.Assume.assumeTrue;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.io.CharStreams; import com.google.common.io.CharStreams;
import google.registry.keyring.api.Keyring; import google.registry.keyring.api.Keyring;
@ -34,75 +35,74 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.stream.Stream;
import org.bouncycastle.openpgp.PGPKeyPair; import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKey;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Rule; import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.experimental.theories.DataPoints; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.experimental.theories.Theories; import org.junit.jupiter.params.provider.Arguments;
import org.junit.experimental.theories.Theory; import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runner.RunWith;
/** GPG combinatorial integration tests for the Ryde classes. */ /** GPG combinatorial integration tests for the Ryde classes. */
@RunWith(Theories.class)
@SuppressWarnings("resource")
public class RydeGpgIntegrationTest { public class RydeGpgIntegrationTest {
private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@Rule @RegisterExtension public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
public final BouncyCastleProviderRule bouncy = new BouncyCastleProviderRule();
@Rule @RegisterExtension
public final GpgSystemCommandRule gpg = new GpgSystemCommandRule( public final GpgSystemCommandRule gpg =
RdeTestData.loadBytes("pgp-public-keyring.asc"), new GpgSystemCommandRule(
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc")); RdeTestData.loadBytes("pgp-public-keyring.asc"),
RdeTestData.loadBytes("pgp-private-keyring-escrow.asc"));
private final FakeKeyringModule keyringFactory = new FakeKeyringModule(); private final FakeKeyringModule keyringFactory = new FakeKeyringModule();
@DataPoints private static final ImmutableList<String> COMMANDS = ImmutableList.of("gpg", "gpg2");
public static GpgCommand[] commands = new GpgCommand[] { private static final ImmutableList<String> CONTENTS =
new GpgCommand("gpg"), ImmutableList.of(
new GpgCommand("gpg2"), "(◕‿◕)",
}; Strings.repeat("Fanatics have their dreams, wherewith they weave\n", 1000),
"\0yolo",
"");
@DataPoints static Stream<Arguments> provideTestCombinations() {
public static Filename[] filenames = new Filename[] { Stream.Builder<Arguments> stream = Stream.builder();
new Filename("sloth"), for (String command : COMMANDS) {
}; for (String content : CONTENTS) {
stream.add(Arguments.of(command, content));
}
}
return stream.build();
}
@DataPoints @ParameterizedTest
public static Content[] contents = new Content[] { @MethodSource("provideTestCombinations")
new Content("(◕‿◕)"), void test(String command, String content) throws Exception {
new Content(repeat("Fanatics have their dreams, wherewith they weave.\n", 1000)), final String filename = "sloth";
new Content("\0yolo"),
new Content(""),
};
@Theory
public void test(GpgCommand cmd, Filename name, Content content)
throws Exception {
assumeTrue(hasCommand("tar")); assumeTrue(hasCommand("tar"));
assumeTrue(hasCommand(cmd.get() + " --version")); assumeTrue(hasCommand(command + " --version"));
Keyring keyring = keyringFactory.get(); Keyring keyring = keyringFactory.get();
PGPKeyPair signingKey = keyring.getRdeSigningKey(); PGPKeyPair signingKey = keyring.getRdeSigningKey();
PGPPublicKey receiverKey = keyring.getRdeReceiverKey(); PGPPublicKey receiverKey = keyring.getRdeReceiverKey();
DateTime modified = DateTime.parse("1984-01-01T00:00:00Z"); DateTime modified = DateTime.parse("1984-01-01T00:00:00Z");
File home = gpg.getCwd(); File home = gpg.getCwd();
File rydeFile = new File(home, name.get() + ".ryde"); File rydeFile = new File(home, filename + ".ryde");
File sigFile = new File(home, name.get() + ".sig"); File sigFile = new File(home, filename + ".sig");
File tarFile = new File(home, name.get() + ".tar"); File tarFile = new File(home, filename + ".tar");
File xmlFile = new File(home, name.get() + ".xml"); File xmlFile = new File(home, filename + ".xml");
byte[] data = content.get().getBytes(UTF_8); byte[] data = content.getBytes(UTF_8);
try (OutputStream rydeOut = new FileOutputStream(rydeFile); try (OutputStream rydeOut = new FileOutputStream(rydeFile);
OutputStream sigOut = new FileOutputStream(sigFile); OutputStream sigOut = new FileOutputStream(sigFile);
RydeEncoder rydeEncoder = new RydeEncoder.Builder() RydeEncoder rydeEncoder =
.setRydeOutput(rydeOut, receiverKey) new RydeEncoder.Builder()
.setSignatureOutput(sigOut, signingKey) .setRydeOutput(rydeOut, receiverKey)
.setFileMetadata(name.get(), data.length, modified) .setSignatureOutput(sigOut, signingKey)
.build()) { .setFileMetadata(filename, data.length, modified)
.build()) {
rydeEncoder.write(data); rydeEncoder.write(data);
} }
@ -123,7 +123,7 @@ public class RydeGpgIntegrationTest {
{ {
Process pid = Process pid =
gpg.exec( gpg.exec(
cmd.get(), command,
"--list-packets", "--list-packets",
"--ignore-mdc-error", "--ignore-mdc-error",
"--keyid-format", "--keyid-format",
@ -149,7 +149,7 @@ public class RydeGpgIntegrationTest {
.contains(":literal data packet:"); .contains(":literal data packet:");
assertWithMessage("Literal data packet does not contain correct filename") assertWithMessage("Literal data packet does not contain correct filename")
.that(stdout) .that(stdout)
.contains("name=\"" + name.get() + ".tar\""); .contains("name=\"" + filename + ".tar\"");
assertWithMessage("Literal data packet should be in BINARY mode") assertWithMessage("Literal data packet should be in BINARY mode")
.that(stdout) .that(stdout)
.contains("mode b "); .contains("mode b ");
@ -168,7 +168,7 @@ public class RydeGpgIntegrationTest {
// gpg: Good signature from <rde-unittest@registry.test> // gpg: Good signature from <rde-unittest@registry.test>
logger.atInfo().log("Running GPG to verify signature..."); logger.atInfo().log("Running GPG to verify signature...");
{ {
Process pid = gpg.exec(cmd.get(), "--verify", sigFile.toString(), rydeFile.toString()); Process pid = gpg.exec(command, "--verify", sigFile.toString(), rydeFile.toString());
String stderr = slurp(pid.getErrorStream()); String stderr = slurp(pid.getErrorStream());
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0); assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
assertThat(stderr).contains("Good signature"); assertThat(stderr).contains("Good signature");
@ -187,7 +187,7 @@ public class RydeGpgIntegrationTest {
logger.atInfo().log("Running GPG to extract tar..."); logger.atInfo().log("Running GPG to extract tar...");
{ {
Process pid = Process pid =
gpg.exec(cmd.get(), "--use-embedded-filename", "--ignore-mdc-error", rydeFile.toString()); gpg.exec(command, "--use-embedded-filename", "--ignore-mdc-error", rydeFile.toString());
String stderr = slurp(pid.getErrorStream()); String stderr = slurp(pid.getErrorStream());
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0); assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
} }
@ -203,7 +203,7 @@ public class RydeGpgIntegrationTest {
assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0); assertWithMessage(stderr).that(pid.waitFor()).isEqualTo(0);
} }
assertWithMessage("tar did not produce expected xml file").that(xmlFile.exists()).isTrue(); assertWithMessage("tar did not produce expected xml file").that(xmlFile.exists()).isTrue();
assertThat(slurp(xmlFile)).isEqualTo(content.get()); assertThat(slurp(xmlFile)).isEqualTo(content);
} }
private String slurp(File file) throws IOException { private String slurp(File file) throws IOException {
@ -213,40 +213,4 @@ public class RydeGpgIntegrationTest {
private String slurp(InputStream is) throws IOException { private String slurp(InputStream is) throws IOException {
return CharStreams.toString(new InputStreamReader(is, UTF_8)); return CharStreams.toString(new InputStreamReader(is, UTF_8));
} }
private static class GpgCommand {
private final String value;
GpgCommand(String value) {
this.value = value;
}
String get() {
return value;
}
}
private static class Filename {
private final String value;
Filename(String value) {
this.value = value;
}
String get() {
return value;
}
}
private static class Content {
private final String value;
Content(String value) {
this.value = value;
}
String get() {
return value;
}
}
} }

View file

@ -22,15 +22,13 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@RunWith(JUnit4.class) /** Unit tests for {@link RydeTar}. */
public final class RydeTarTest { final class RydeTarTest {
@Test @Test
public void testWriteRead() throws Exception { void testWriteRead() throws Exception {
byte[] expectedContent = "Testing 1, 2, 3".getBytes(UTF_8); byte[] expectedContent = "Testing 1, 2, 3".getBytes(UTF_8);
String expectedFilename = "myFile.xml"; String expectedFilename = "myFile.xml";
DateTime expectedModified = DateTime.parse("2015-12-25T06:30:00.000Z"); DateTime expectedModified = DateTime.parse("2015-12-25T06:30:00.000Z");

View file

@ -16,6 +16,9 @@ package google.registry.testing;
import java.security.Security; import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.rules.ExternalResource; import org.junit.rules.ExternalResource;
/** /**
@ -28,7 +31,18 @@ import org.junit.rules.ExternalResource;
* @see org.junit.rules.ExternalResource * @see org.junit.rules.ExternalResource
* @see java.security.Security#addProvider(java.security.Provider) * @see java.security.Security#addProvider(java.security.Provider)
*/ */
public class BouncyCastleProviderRule extends ExternalResource { public class BouncyCastleProviderRule extends ExternalResource
implements BeforeEachCallback, AfterEachCallback {
@Override
public void beforeEach(ExtensionContext context) {
before();
}
@Override
public void afterEach(ExtensionContext context) {
after();
}
@Override @Override
protected void before() { protected void before() {

View file

@ -30,7 +30,9 @@ import java.io.InputStreamReader;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.attribute.PosixFilePermissions; import java.nio.file.attribute.PosixFilePermissions;
import java.util.Objects; import java.util.Objects;
import org.junit.rules.ExternalResource; import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
/** /**
* GnuPG system command JUnit rule. * GnuPG system command JUnit rule.
@ -38,10 +40,8 @@ import org.junit.rules.ExternalResource;
* <p>This rule creates a isolated environment for running the {@code gpg} command inside system * <p>This rule creates a isolated environment for running the {@code gpg} command inside system
* integration tests. It reduces a lot of the boilerplate of setting up the shell environment and * integration tests. It reduces a lot of the boilerplate of setting up the shell environment and
* importing your keyrings into a temporary config folder. * importing your keyrings into a temporary config folder.
*
* @see ExternalResource
*/ */
public final class GpgSystemCommandRule extends ExternalResource { public final class GpgSystemCommandRule implements BeforeEachCallback, AfterEachCallback {
private static final File DEV_NULL = new File("/dev/null"); private static final File DEV_NULL = new File("/dev/null");
private static final String TEMP_FILE_PREFIX = "gpgtest"; private static final String TEMP_FILE_PREFIX = "gpgtest";
@ -83,7 +83,7 @@ public final class GpgSystemCommandRule extends ExternalResource {
} }
@Override @Override
protected void before() throws IOException, InterruptedException { public void beforeEach(ExtensionContext context) throws IOException, InterruptedException {
checkState(Objects.equals(cwd, DEV_NULL)); checkState(Objects.equals(cwd, DEV_NULL));
String tmpRootDirString = System.getenv("TMPDIR"); String tmpRootDirString = System.getenv("TMPDIR");
// Create the working directory for the forked process on Temp file system. Create under the // Create the working directory for the forked process on Temp file system. Create under the
@ -123,7 +123,7 @@ public final class GpgSystemCommandRule extends ExternalResource {
} }
@Override @Override
protected void after() { public void afterEach(ExtensionContext context) {
// TODO(weiminyu): we should delete the cwd tree. // TODO(weiminyu): we should delete the cwd tree.
cwd = DEV_NULL; cwd = DEV_NULL;
conf = DEV_NULL; conf = DEV_NULL;

View file

@ -52,9 +52,16 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule; import org.mockito.junit.MockitoRule;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
/** /**
* Base test class for mapreduces. * Base test class for mapreduces.
@ -67,6 +74,8 @@ import org.mockito.junit.MockitoRule;
* *
* @param <T> The type of the Action class that implements the mapreduce. * @param <T> The type of the Action class that implements the mapreduce.
*/ */
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
public abstract class MapreduceTestCase<T> { public abstract class MapreduceTestCase<T> {
private static final FluentLogger logger = FluentLogger.forEnclosingClass(); private static final FluentLogger logger = FluentLogger.forEnclosingClass();
@ -77,24 +86,25 @@ public abstract class MapreduceTestCase<T> {
private final PipelineServlet pipelineServlet = new PipelineServlet(); private final PipelineServlet pipelineServlet = new PipelineServlet();
private LocalTaskQueue taskQueue; private LocalTaskQueue taskQueue;
@Rule @RegisterExtension @Rule
public final AppEngineRule appEngine = public final AppEngineRule appEngine =
AppEngineRule.builder().withDatastoreAndCloudSql().withLocalModules().withTaskQueue().build(); AppEngineRule.builder().withDatastoreAndCloudSql().withLocalModules().withTaskQueue().build();
@Rule public final MockitoRule mocks = MockitoJUnit.rule(); @Rule public final MockitoRule mocks = MockitoJUnit.rule();
AppEngineServiceUtils appEngineServiceUtils; private AppEngineServiceUtils appEngineServiceUtils;
@Mock ModulesService modulesService; @Mock ModulesService modulesService;
@Before @Before
@BeforeEach
public void setUp() { public void setUp() {
taskQueue = LocalTaskQueueTestConfig.getLocalTaskQueue(); taskQueue = LocalTaskQueueTestConfig.getLocalTaskQueue();
ApiProxyLocal proxy = (ApiProxyLocal) ApiProxy.getDelegate(); ApiProxyLocal proxy = (ApiProxyLocal) ApiProxy.getDelegate();
// Creating files is not allowed in some test execution environments, so don't. // Creating files is not allowed in some test execution environments, so don't.
proxy.setProperty(LocalBlobstoreService.NO_STORAGE_PROPERTY, "true"); proxy.setProperty(LocalBlobstoreService.NO_STORAGE_PROPERTY, "true");
appEngineServiceUtils = new AppEngineServiceUtilsImpl(modulesService); appEngineServiceUtils = new AppEngineServiceUtilsImpl(modulesService);
when(modulesService.getVersionHostname("backend", null)) Mockito.when(modulesService.getVersionHostname("backend", null))
.thenReturn("version.backend.projectid.appspot.com"); .thenReturn("version.backend.projectid.appspot.com");
} }
@ -107,7 +117,7 @@ public abstract class MapreduceTestCase<T> {
return taskQueue.getQueueStateInfo().get(queueName).getTaskInfo(); return taskQueue.getQueueStateInfo().get(queueName).getTaskInfo();
} }
protected void executeTask(String queueName, QueueStateInfo.TaskStateInfo taskStateInfo) private void executeTask(String queueName, QueueStateInfo.TaskStateInfo taskStateInfo)
throws Exception { throws Exception {
logger.atFine().log( logger.atFine().log(
"Executing task %s with URL %s", taskStateInfo.getTaskName(), taskStateInfo.getUrl()); "Executing task %s with URL %s", taskStateInfo.getTaskName(), taskStateInfo.getUrl());
@ -141,9 +151,9 @@ public abstract class MapreduceTestCase<T> {
when(request.getIntHeader(TaskHandler.TASK_RETRY_COUNT_HEADER)).thenReturn(-1); when(request.getIntHeader(TaskHandler.TASK_RETRY_COUNT_HEADER)).thenReturn(-1);
for (HeaderWrapper header : taskStateInfo.getHeaders()) { for (HeaderWrapper header : taskStateInfo.getHeaders()) {
int value = parseAsQuotedInt(header.getValue()); int value = parseAsQuotedInt(header.getValue());
when(request.getIntHeader(header.getKey())).thenReturn(value); Mockito.when(request.getIntHeader(header.getKey())).thenReturn(value);
logger.atFine().log("header: %s=%s", header.getKey(), header.getValue()); logger.atFine().log("header: %s=%s", header.getKey(), header.getValue());
when(request.getHeader(header.getKey())).thenReturn(header.getValue()); Mockito.when(request.getHeader(header.getKey())).thenReturn(header.getValue());
} }
Map<String, String> parameters = decodeParameters(taskStateInfo.getBody()); Map<String, String> parameters = decodeParameters(taskStateInfo.getBody());
@ -201,8 +211,8 @@ public abstract class MapreduceTestCase<T> {
* <p>The maxTasks parameter determines how many tasks (at most) will be run. If maxTasks is * <p>The maxTasks parameter determines how many tasks (at most) will be run. If maxTasks is
* absent(), all tasks are run until the queue is empty. If maxTasks is zero, no tasks are run. * absent(), all tasks are run until the queue is empty. If maxTasks is zero, no tasks are run.
*/ */
protected void executeTasks( private void executeTasks(String queueName, @Nullable FakeClock clock, Optional<Integer> maxTasks)
String queueName, @Nullable FakeClock clock, Optional<Integer> maxTasks) throws Exception { throws Exception {
for (int numTasksDeleted = 0; for (int numTasksDeleted = 0;
!maxTasks.isPresent() || (numTasksDeleted < maxTasks.get()); !maxTasks.isPresent() || (numTasksDeleted < maxTasks.get());
numTasksDeleted++) { numTasksDeleted++) {

View file

@ -21,14 +21,15 @@ import java.io.File;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.apache.ftpserver.FtpServer; import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.ftplet.FtpException; import org.apache.ftpserver.ftplet.FtpException;
import org.junit.rules.ExternalResource; import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
/** /**
* JUnit Rule for creating an in-process {@link TestSftpServer SFTP Server}. * JUnit Rule for creating an in-process {@link TestSftpServer SFTP Server}.
* *
* @see TestSftpServer * @see TestSftpServer
*/ */
public final class SftpServerRule extends ExternalResource { public final class SftpServerRule implements AfterEachCallback {
@Nullable @Nullable
private FtpServer server; private FtpServer server;
@ -46,7 +47,7 @@ public final class SftpServerRule extends ExternalResource {
} }
@Override @Override
protected void after() { public void afterEach(ExtensionContext context) {
if (server != null) { if (server != null) {
server.stop(); server.stop();
server = null; server = null;

View file

@ -23,12 +23,12 @@ org.checkerframework:checker-qual:2.11.1
org.flywaydb:flyway-core:5.2.4 org.flywaydb:flyway-core:5.2.4
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.jetbrains:annotations:19.0.0 org.jetbrains:annotations:19.0.0
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.rnorth.duct-tape:duct-tape:1.0.8 org.rnorth.duct-tape:duct-tape:1.0.8
org.rnorth.visible-assertions:visible-assertions:2.1.2 org.rnorth.visible-assertions:visible-assertions:2.1.2

View file

@ -23,12 +23,12 @@ org.checkerframework:checker-qual:2.11.1
org.flywaydb:flyway-core:5.2.4 org.flywaydb:flyway-core:5.2.4
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.jetbrains:annotations:19.0.0 org.jetbrains:annotations:19.0.0
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.rnorth.duct-tape:duct-tape:1.0.8 org.rnorth.duct-tape:duct-tape:1.0.8
org.rnorth.visible-assertions:visible-assertions:2.1.2 org.rnorth.visible-assertions:visible-assertions:2.1.2

View file

@ -26,12 +26,12 @@ org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r
org.flywaydb:flyway-core:5.2.4 org.flywaydb:flyway-core:5.2.4
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.jetbrains:annotations:19.0.0 org.jetbrains:annotations:19.0.0
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.rnorth.duct-tape:duct-tape:1.0.8 org.rnorth.duct-tape:duct-tape:1.0.8
org.rnorth.visible-assertions:visible-assertions:2.1.2 org.rnorth.visible-assertions:visible-assertions:2.1.2

View file

@ -51,12 +51,12 @@ org.eclipse.jgit:org.eclipse.jgit:4.4.1.201607150455-r
org.flywaydb:flyway-core:5.2.4 org.flywaydb:flyway-core:5.2.4
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.jetbrains:annotations:19.0.0 org.jetbrains:annotations:19.0.0
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.ow2.asm:asm-analysis:8.0.1 org.ow2.asm:asm-analysis:8.0.1
org.ow2.asm:asm-commons:7.1 org.ow2.asm:asm-commons:7.1

View file

@ -104,12 +104,13 @@ ext {
'jline:jline:1.0', 'jline:jline:1.0',
'joda-time:joda-time:2.9.2', 'joda-time:joda-time:2.9.2',
'junit:junit:4.13', 'junit:junit:4.13',
'org.junit.jupiter:junit-jupiter-api:5.6.1', 'org.junit.jupiter:junit-jupiter-api:5.6.2',
'org.junit.jupiter:junit-jupiter-engine:5.6.1', 'org.junit.jupiter:junit-jupiter-engine:5.6.2',
'org.junit.jupiter:junit-jupiter-migrationsupport:5.6.1', 'org.junit.jupiter:junit-jupiter-migrationsupport:5.6.2',
'org.junit.platform:junit-platform-runner:1.6.1', 'org.junit.jupiter:junit-jupiter-params:5.6.2',
'org.junit.platform:junit-platform-suite-api:1.6.1', 'org.junit.platform:junit-platform-runner:1.6.2',
'org.junit.vintage:junit-vintage-engine:5.6.1', 'org.junit.platform:junit-platform-suite-api:1.6.2',
'org.junit.vintage:junit-vintage-engine:5.6.2',
'org.apache.avro:avro:1.8.2', 'org.apache.avro:avro:1.8.2',
'org.apache.beam:beam-runners-direct-java:2.16.0', 'org.apache.beam:beam-runners-direct-java:2.16.0',
'org.apache.beam:beam-runners-google-cloud-dataflow-java:2.16.0', 'org.apache.beam:beam-runners-google-cloud-dataflow-java:2.16.0',

View file

@ -51,11 +51,11 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.yaml:snakeyaml:1.17 org.yaml:snakeyaml:1.17

View file

@ -51,11 +51,11 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.yaml:snakeyaml:1.17 org.yaml:snakeyaml:1.17

View file

@ -53,11 +53,11 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.yaml:snakeyaml:1.17 org.yaml:snakeyaml:1.17

View file

@ -53,11 +53,11 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0
org.yaml:snakeyaml:1.17 org.yaml:snakeyaml:1.17

View file

@ -58,12 +58,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -58,12 +58,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -58,12 +58,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -58,12 +58,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -63,12 +63,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -63,12 +63,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -63,12 +63,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -63,12 +63,12 @@ org.bouncycastle:bcprov-jdk15on:1.61
org.checkerframework:checker-compat-qual:2.5.5 org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -46,12 +46,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-all:1.3 org.hamcrest:hamcrest-all:1.3
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -46,12 +46,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-all:1.3 org.hamcrest:hamcrest-all:1.3
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -48,12 +48,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-all:1.3 org.hamcrest:hamcrest-all:1.3
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0

View file

@ -48,12 +48,12 @@ org.checkerframework:checker-compat-qual:2.5.5
org.checkerframework:checker-qual:2.11.1 org.checkerframework:checker-qual:2.11.1
org.hamcrest:hamcrest-all:1.3 org.hamcrest:hamcrest-all:1.3
org.hamcrest:hamcrest-core:1.3 org.hamcrest:hamcrest-core:1.3
org.junit.jupiter:junit-jupiter-api:5.6.1 org.junit.jupiter:junit-jupiter-api:5.6.2
org.junit.jupiter:junit-jupiter-engine:5.6.1 org.junit.jupiter:junit-jupiter-engine:5.6.2
org.junit.platform:junit-platform-commons:1.6.1 org.junit.platform:junit-platform-commons:1.6.2
org.junit.platform:junit-platform-engine:1.6.1 org.junit.platform:junit-platform-engine:1.6.2
org.junit.vintage:junit-vintage-engine:5.6.1 org.junit.vintage:junit-vintage-engine:5.6.2
org.junit:junit-bom:5.6.1 org.junit:junit-bom:5.6.2
org.mockito:mockito-core:3.3.3 org.mockito:mockito-core:3.3.3
org.objenesis:objenesis:2.6 org.objenesis:objenesis:2.6
org.opentest4j:opentest4j:1.2.0 org.opentest4j:opentest4j:1.2.0