Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4946)

Unified Diff: chrome/common/net/x509_certificate_model_unittest.cc

Issue 288053003: x509_certificate_model_openssl: implement GetCertNameOrNickname, GetTitle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exclude unittest on android too Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/net/x509_certificate_model_openssl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/net/x509_certificate_model_unittest.cc
diff --git a/chrome/common/net/x509_certificate_model_unittest.cc b/chrome/common/net/x509_certificate_model_unittest.cc
index 58350d07e4a50226fe5d8578cf990aff0e19cddc..dc1a5787abd011e71df0f969f2998bd4f86e26a9 100644
--- a/chrome/common/net/x509_certificate_model_unittest.cc
+++ b/chrome/common/net/x509_certificate_model_unittest.cc
@@ -14,6 +14,59 @@
#include "net/cert/nss_cert_database.h"
#endif
+TEST(X509CertificateModelTest, GetCertNameOrNicknameAndGetTitle) {
+ scoped_refptr<net::X509Certificate> cert(
+ net::ImportCertFromFile(net::GetTestCertsDirectory(),
+ "root_ca_cert.pem"));
+ ASSERT_TRUE(cert.get());
+ EXPECT_EQ(
+ "Test Root CA",
+ x509_certificate_model::GetCertNameOrNickname(cert->os_cert_handle()));
+
+ scoped_refptr<net::X509Certificate> punycode_cert(
+ net::ImportCertFromFile(net::GetTestCertsDirectory(),
+ "punycodetest.der"));
+ ASSERT_TRUE(punycode_cert.get());
+ EXPECT_EQ("xn--wgv71a119e.com (日本語.com)",
+ x509_certificate_model::GetCertNameOrNickname(
+ punycode_cert->os_cert_handle()));
+
+ scoped_refptr<net::X509Certificate> no_cn_cert(
+ net::ImportCertFromFile(net::GetTestCertsDirectory(),
+ "no_subject_common_name_cert.pem"));
+ ASSERT_TRUE(no_cn_cert.get());
+#if defined(USE_OPENSSL)
+ EXPECT_EQ("emailAddress=wtc@google.com",
+ x509_certificate_model::GetCertNameOrNickname(
+ no_cn_cert->os_cert_handle()));
+#else
+ // Temp cert has no nickname.
+ EXPECT_EQ("",
+ x509_certificate_model::GetCertNameOrNickname(
+ no_cn_cert->os_cert_handle()));
+#endif
+
+ EXPECT_EQ("xn--wgv71a119e.com",
+ x509_certificate_model::GetTitle(
+ punycode_cert->os_cert_handle()));
+
+#if defined(USE_OPENSSL)
+ EXPECT_EQ("emailAddress=wtc@google.com",
+ x509_certificate_model::GetTitle(
+ no_cn_cert->os_cert_handle()));
+#else
+ EXPECT_EQ("E=wtc@google.com",
+ x509_certificate_model::GetTitle(
+ no_cn_cert->os_cert_handle()));
+#endif
+
+ scoped_refptr<net::X509Certificate> no_cn_cert2(net::ImportCertFromFile(
+ net::GetTestCertsDirectory(), "ct-test-embedded-cert.pem"));
+ ASSERT_TRUE(no_cn_cert2.get());
+ EXPECT_EQ("L=Erw Wen,ST=Wales,O=Certificate Transparency,C=GB",
+ x509_certificate_model::GetTitle(no_cn_cert2->os_cert_handle()));
+}
+
TEST(X509CertificateModelTest, GetTypeCA) {
scoped_refptr<net::X509Certificate> cert(
net::ImportCertFromFile(net::GetTestCertsDirectory(),
« no previous file with comments | « chrome/common/net/x509_certificate_model_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698