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

Unified Diff: components/security_state/core/security_state_unittest.cc

Issue 2761333002: Add a DevTools warning for a missing subjectAltName (Closed)
Patch Set: Feedback & fixes Created 3 years, 9 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 | « components/security_state/core/security_state.cc ('k') | components/security_state_strings.grdp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/security_state/core/security_state_unittest.cc
diff --git a/components/security_state/core/security_state_unittest.cc b/components/security_state/core/security_state_unittest.cc
index 9b9ddad894a6df426d871fa68b6ac28045053ed2..5a9bbc7cc30c6dcfa43f725e21da7de687366535 100644
--- a/components/security_state/core/security_state_unittest.cc
+++ b/components/security_state/core/security_state_unittest.cc
@@ -51,6 +51,9 @@ class TestSecurityStateHelper {
displayed_credit_card_field_on_http_(false) {}
virtual ~TestSecurityStateHelper() {}
+ void SetCertificate(scoped_refptr<net::X509Certificate> cert) {
+ cert_ = std::move(cert);
+ }
void set_connection_status(int connection_status) {
connection_status_ = connection_status;
}
@@ -107,7 +110,7 @@ class TestSecurityStateHelper {
private:
GURL url_;
- const scoped_refptr<net::X509Certificate> cert_;
+ scoped_refptr<net::X509Certificate> cert_;
int connection_status_;
net::CertStatus cert_status_;
bool displayed_mixed_content_;
@@ -366,4 +369,24 @@ TEST(SecurityStateTest, MarkHttpAsStatusHistogram) {
histograms.ExpectUniqueSample(kHistogramName, 2 /* HTTP_SHOW_WARNING */, 2);
}
+TEST(SecurityStateTest, DetectSubjectAltName) {
+ TestSecurityStateHelper helper;
+
+ // Ensure subjectAltName is detected as present when the cert includes it.
+ SecurityInfo san_security_info;
+ helper.GetSecurityInfo(&san_security_info);
+ EXPECT_FALSE(san_security_info.cert_missing_subject_alt_name);
+
+ // Ensure subjectAltName is detected as missing when the cert doesn't
+ // include it.
+ scoped_refptr<net::X509Certificate> cert = net::ImportCertFromFile(
+ net::GetTestCertsDirectory(), "salesforce_com_test.pem");
+ ASSERT_TRUE(cert);
+ helper.SetCertificate(std::move(cert));
+
+ SecurityInfo no_san_security_info;
+ helper.GetSecurityInfo(&no_san_security_info);
+ EXPECT_TRUE(no_san_security_info.cert_missing_subject_alt_name);
+}
+
} // namespace security_state
« no previous file with comments | « components/security_state/core/security_state.cc ('k') | components/security_state_strings.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698