Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for standard test vectors. #127

Merged
merged 2 commits into from
Oct 8, 2019
Merged

Add support for standard test vectors. #127

merged 2 commits into from
Oct 8, 2019

Conversation

SalusaSecondus
Copy link
Contributor

Description of changes:
Now handles standard test vectors when the ZIP containing them is
pointed to by the testVectorZip system property.

Example:
mvn install -Dgpg.skip=true '-DtestVectorZip=https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-1.3.8.zip'

This also adds them to our standard travis build.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Check any applicable:

  • Were any files moved? Moving files changes their URL, which breaks all hyperlinks to the files.

Now handles standard test vectors when the ZIP containing them is
pointed to by the testVectorZip system property.

Example:
`mvn install -Dgpg.skip=true '-DtestVectorZip=https://github.com/awslabs/aws-encryption-sdk-test-vectors/raw/master/vectors/awses-decrypt/python-1.3.8.zip'`

This also adds them to our standard travis build.
@SalusaSecondus SalusaSecondus reopened this Oct 4, 2019
@SalusaSecondus SalusaSecondus marked this pull request as ready for review October 4, 2019 21:49
import java.util.zip.ZipEntry;

@RunWith(Parameterized.class)
public class NewCompatTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason the class name is abbreviated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just was matching the pattern of the existing XCompatDecryptTest. I'll rename it. You're right.

byte[] plaintext = crypto.decryptData(testCase.mkp, cachedData.get(testCase.ciphertextPath)).getResult();
final byte[] expectedPlaintext = cachedData.get(testCase.plaintextPath);

Assert.assertArrayEquals(expectedPlaintext, plaintext);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to always statically import Assert methods for readability

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally do if they're used more than once. As there is only a single use of this method, I (mildly) prefer to leave it fully-qualified.

}
}

@SuppressWarnings("unchecked")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this suppression is necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed by a prior iteration of this method. Removed.

}

@SuppressWarnings("unchecked")
private static Map<String, KeyEntry> parseKeyManifest(final Map<String, Object> keysManifest) throws IOException, GeneralSecurityException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IOException isn't thrown in this method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

final JarURLConnection jarConnection = (JarURLConnection) new URL("jar:" + zipPath + "!/").openConnection();

try (JarFile jar = jarConnection.getJarFile()) {
final ObjectMapper mapper = new ObjectMapper();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see mapper being used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed by a prior version of this method. Removed.

Assert.assertArrayEquals(expectedPlaintext, plaintext);
}

@Parameterized.Parameters(name="Compatability Test: {0}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "Compatibility"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I can never spell this word on my first try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants