CTS test for SslCertificate.getX509Certificate

Bug: 111696337
Bug: 36984840
Test: cts -m CtsNetTestCases -t android.net.http
Change-Id: I778a18fd3636efc1e60d61e6d2b78685635c07f8
This commit is contained in:
Adam Vartanian
2018-07-27 11:44:06 +01:00
parent 2ab9867d51
commit 679ee7cbe7

View File

@@ -230,6 +230,19 @@ public class SslCertificateTest extends TestCase {
final String EXPECTED = "Issued to: c=ccc,o=testOName,ou=testUName,cn=testCName;\n"
+ "Issued by: e=aeei,c=adb,o=testOName,ou=testUName,cn=testCName;\n";
assertEquals(EXPECTED, ssl.toString());
assertNull(ssl.getX509Certificate());
}
public void testGetX509Certificate() {
final String TO = "c=ccc,o=testOName,ou=testUName,cn=testCName";
final String BY = "e=aeei,c=adb,o=testOName,ou=testUName,cn=testCName";
Date validNotBefore = new Date(System.currentTimeMillis() - 1000);
Date validNotAfter = new Date(System.currentTimeMillis());
SslCertificate ssl = new SslCertificate(TO, BY, validNotBefore, validNotAfter);
assertNull(ssl.getX509Certificate());
X509Certificate cert = new MockX509Certificate();
ssl = new SslCertificate(cert);
assertSame(cert, ssl.getX509Certificate());
}
}