Repository navigation
Conversation
|
Compatibility and security notes:
Tests' coverage includes standard and legacy chains, two intermediates, persistence, malformed input, expiry, CRL, and embedded-root isolation |
|
@IdelsTak thanks. The improvements look great. As for the implementation, I have a concern about single-chain certs / OutOfBoundsException. I've left a code comment about that. The unit tests are very comprehensive, thank you. I will give you time to reply to my code comments before making any changes myself. Some cosmetic changes...
|
| "ca-root.crt", true); | ||
| } | ||
|
|
||
| private void assertNames(String resource, String... expected) throws Exception { |
There was a problem hiding this comment.
| private void assertNames(String resource, String... expected) throws Exception { | |
| private void assertNames(String resource, String... expectedCns) throws Exception { |
| List<X509Certificate> certificates = Certificate.parseCertificates(read(resource)); | ||
|
|
||
| Assert.assertEquals(certificates.size(), expected.length); | ||
| for(int i = 0; i < expected.length; i++) { |
There was a problem hiding this comment.
This will still pass under the following 'failure' scenarios:
- when only one
expectedvalue is sent - when the certificates contain more values than the
expectedvalues
| } | ||
|
|
||
| private void assertTrust(String certificateData, String rootResource, | ||
| boolean trusted) throws Exception { |
There was a problem hiding this comment.
| boolean trusted) throws Exception { | |
| boolean trustExpected) throws Exception { |
|
|
||
| public class CertificateSerializationTests { | ||
| @Test | ||
| public void testStandard() throws Exception { |
There was a problem hiding this comment.
This is called testStandard() however the standard and most common workflow is for an existing trusted certificate (such as our demo cert) to be tested against the rootCA that's built into Certificate.java. Do we have coverage for this? If so, do you think we should have that as the standard test?
|
|
||
| @Test | ||
| public void testSelfSigned() throws Exception { | ||
| assertTrust(read("leaf-self-signed.crt"), "ca-root.crt", false); |
There was a problem hiding this comment.
Can you explain why this is a negative test? Our most common use-case for self-signed is more like this:
| assertTrust(read("leaf-self-signed.crt"), "ca-root.crt", false); | |
| assertTrust(read("leaf-self-signed.crt"), "leaf-self-signed.crt", true); |
| } | ||
|
|
||
| @Test | ||
| public void testUnrelated() throws Exception { |
There was a problem hiding this comment.
Hmm.... these may make more sense to just make an overload that uses the default caCert with explicit clear() and setTrustBuiltIn(). We should explicitly add setTrustBuiltIn() coverage anyway per https://github.com/qzind/tray/pull/1561/changes#r4425314285.
|
Thanks for the improvements. Code is perfect but unit tests still need some work. Left more feedback. |
| } | ||
|
|
||
| @Test | ||
| public void testDuplicate() throws Exception { |
There was a problem hiding this comment.
Can you please explain what this unit-test does?
| } | ||
|
|
||
| @Test | ||
| public void testReversed() throws Exception { |
There was a problem hiding this comment.
Hmm... what is this testing exactly? Seems cursed and the fact that it's expected to pass is even stranger. I understand detecting and failing this scenario is a bit more nuanced, but let's at least leave a code comment that this is cursed behavior so that if we ever guard against this in the future it's clear from the unit tests comments that it's not expected to pass, just sort of does accidentally.
@tresf, this pr is meant to close #803