Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/website_settings_model.h" | |
|
wtc
2012/02/15 02:14:29
Nit: I suggest adding a blank line to separate thi
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 6 #include "chrome/test/base/testing_profile.h" | |
| 7 #include "content/public/common/ssl_status.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
|
wtc
2012/02/15 02:14:29
Nit: list in alphabetical order.
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 9 #include "net/base/cert_status_flags.h" | |
| 10 #include "net/base/ssl_connection_status_flags.h" | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 // SSL Cipher Suits like specified in RFC5246 Appendix A.5. | |
|
wtc
2012/02/15 02:14:29
Typo: Suits => Suites
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 15 static int TLS_RSA_WITH_NULL_MD5 = 1; | |
| 16 | |
| 17 int SetSSLVersion(int connection_status, int version) { | |
| 18 // Clear ssl version bits (20, 21, 22); | |
|
Finnur
2012/02/15 08:59:49
nit: period, not semicolon. :) Also: s/ssl/SSL/
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 19 connection_status = connection_status & (3 << 20); | |
|
wtc
2012/02/15 02:14:29
Nit: use the &= operator:
connection_status &= (
markusheintz_
2012/02/15 19:04:18
Done. I am ashamed to death
| |
| 20 int bitmask = version << net::SSL_CONNECTION_VERSION_SHIFT; | |
| 21 return bitmask | connection_status; | |
| 22 } | |
| 23 | |
| 24 int SetSSLCipherSuite(int connection_status, int cipher_suite) { | |
| 25 // Clear cipher suite bits (the 16 lowest bits). | |
| 26 connection_status = connection_status & (~0 << 16); | |
|
wtc
2012/02/15 02:14:29
Nit: I suggest you say
connection_status &= ~net
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 27 int bitmask = 0 | cipher_suite; | |
|
wtc
2012/02/15 02:14:29
Remove "0 | ". Actually you can just say
return
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 28 return bitmask | connection_status; | |
| 29 } | |
| 30 | |
| 31 } // namespace | |
| 32 | |
| 33 TEST(WebsiteSettingsModelTest, HTTPConnection) { | |
| 34 Profile* profile = new TestingProfile(); | |
| 35 GURL url = GURL("http://www.example.com"); | |
| 36 content::SSLStatus ssl; | |
| 37 ssl.security_style = content::SECURITY_STYLE_UNAUTHENTICATED; | |
| 38 | |
| 39 | |
|
Finnur
2012/02/15 08:59:49
nit: Extra line, don't need it.
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 40 scoped_ptr<WebsiteSettingsModel> model; | |
| 41 model.reset(new WebsiteSettingsModel(profile, url, ssl)); | |
| 42 | |
| 43 EXPECT_EQ(WebsiteSettingsModel::SITE_CONNECTION_STATUS_UNENCRYPTED, | |
| 44 model->site_connection_status()); | |
| 45 } | |
| 46 | |
| 47 TEST(WebsiteSettingsModelTest, HTTPSConnection) { | |
| 48 Profile* profile = new TestingProfile(); | |
| 49 GURL url = GURL("http://www.example.com"); | |
| 50 | |
| 51 content::SSLStatus ssl; | |
| 52 ssl.security_style = content::SECURITY_STYLE_AUTHENTICATED; | |
| 53 ssl.cert_id = 1; // Some id other than 0. | |
| 54 ssl.cert_status = 0; // No errors. | |
| 55 | |
| 56 ssl.security_bits = 81; | |
| 57 int status = 0; | |
| 58 status = SetSSLVersion(status, net::SSL_CONNECTION_VERSION_TLS1); | |
| 59 status = SetSSLCipherSuite(status, TLS_RSA_WITH_NULL_MD5); | |
|
wtc
2012/02/15 02:14:29
Nit: TLS_RSA_WITH_NULL_MD5 is a cipher suite that
markusheintz_
2012/02/15 19:04:18
Done. I'm using a different one now. Maybe you wan
| |
| 60 ssl.connection_status = status; | |
| 61 | |
| 62 scoped_ptr<WebsiteSettingsModel> model; | |
| 63 model.reset(new WebsiteSettingsModel(profile, url, ssl)); | |
| 64 | |
| 65 EXPECT_EQ(WebsiteSettingsModel::SITE_CONNECTION_STATUS_ENCRYPTED, | |
| 66 model->site_connection_status()); | |
|
Finnur
2012/02/15 08:59:49
What about site_connection_details, etc?
markusheintz_
2012/02/15 19:04:18
Actually I'd like to change the details from a str
| |
| 67 } | |
| 68 | |
| 69 TEST(WebsiteSettingsModelTest, HTTPSConnectionMixedContent) { | |
| 70 // TODO(markusheintz): Implement | |
|
Finnur
2012/02/15 08:59:49
Look forward to seeing those. Thanks for adding th
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 71 } | |
| 72 | |
| 73 TEST(WebsiteSettingsModelTest, HTTPSConnectionBadCertificate) { | |
| 74 // TODO(markusheintz): Implement | |
| 75 } | |
| 76 | |
| 77 TEST(WebsiteSettingsModelTest, HTTPSConnectionEVCert) { | |
| 78 // TODO(markusheintz): Implement | |
|
Finnur
2012/02/15 08:59:49
nit: indentation (see also above)
markusheintz_
2012/02/15 19:04:18
Done.
| |
| 79 } | |
| OLD | NEW |