OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 | 7 |
8 import pyauto_functional # Must be imported before pyauto | 8 import pyauto_functional # Must be imported before pyauto |
9 import pyauto | 9 import pyauto |
10 import pyauto_paths | 10 import pyauto_paths |
11 | 11 |
12 class HTTPSTest(pyauto.PyUITest): | 12 class HTTPSTest(pyauto.PyUITest): |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 first_page_title = self.GetActiveTabTitle() | 83 first_page_title = self.GetActiveTabTitle() |
84 self.NavigateToURL( | 84 self.NavigateToURL( |
85 server.GetURL('google.html').spec()) | 85 server.GetURL('google.html').spec()) |
86 tab_proxy = self.GetBrowserWindow(0).GetTab(0) | 86 tab_proxy = self.GetBrowserWindow(0).GetTab(0) |
87 # Equivalent to clicking 'back to safety' button. | 87 # Equivalent to clicking 'back to safety' button. |
88 self.assertTrue(tab_proxy.TakeActionOnSSLBlockingPage(False), | 88 self.assertTrue(tab_proxy.TakeActionOnSSLBlockingPage(False), |
89 msg="Was not able to go back from the interstitial page.") | 89 msg="Was not able to go back from the interstitial page.") |
90 self.assertEqual(self.GetActiveTabTitle(), first_page_title, | 90 self.assertEqual(self.GetActiveTabTitle(), first_page_title, |
91 msg="Did not go back to previous page correctly.") | 91 msg="Did not go back to previous page correctly.") |
92 | 92 |
| 93 def testSSLCertOK(self): |
| 94 """Verify Certificate OK does not display interstitial page. |
| 95 |
| 96 This test also asserts that the page type is normal. |
| 97 """ |
| 98 url = self._https_server_ok.GetURL('google.html').spec() |
| 99 self.NavigateToURL(url) |
| 100 tab_proxy = self.GetBrowserWindow(0).GetTab(0) |
| 101 result_dict = tab_proxy.GetPageType() |
| 102 self.assertTrue(result_dict, msg='Could not determine the type of the page') |
| 103 self.assertNotEqual(result_dict['page_type'], pyauto.PAGE_TYPE_INTERSTITIAL, |
| 104 msg="Cert OK displayed interstitial page.") |
| 105 self.assertEqual( |
| 106 result_dict['page_type'], pyauto.PAGE_TYPE_NORMAL, |
| 107 msg="Cert OK displayed error page %s." % result_dict['page_type']) |
| 108 |
| 109 def testSSLCertIsExpiredAndCertNameMismatches(self): |
| 110 """Verify Certificate Expiration and Certificate Mismatched name.""" |
| 111 for server, cert_status_flag, msg in zip( |
| 112 (self._https_server_expired, self._https_server_mismatched), |
| 113 (pyauto.CERT_STATUS_DATE_INVALID, |
| 114 pyauto.CERT_STATUS_COMMON_NAME_INVALID), |
| 115 ('Cert has not expired', 'Cert name does not mismatch')): |
| 116 self.NavigateToURL(server.GetURL('google.html').spec()) |
| 117 result_dict = self.GetBrowserWindow(0).GetTab(0).GetSecurityState() |
| 118 self.assertTrue(result_dict, msg='Could not get security state info') |
| 119 self.assertTrue( |
| 120 result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer( |
| 121 cert_status_flag).value(), |
| 122 msg=msg) |
| 123 |
| 124 def testSSLCertAuthorityOK(self): |
| 125 """Verify Certificate OK is valid.""" |
| 126 self.NavigateToURL( |
| 127 self._https_server_mismatched.GetURL('google.html').spec()) |
| 128 result_dict = self.GetBrowserWindow(0).GetTab(0).GetSecurityState() |
| 129 self.assertTrue(result_dict, msg='Could not get security state info') |
| 130 self.assertFalse( |
| 131 result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer( |
| 132 pyauto.CERT_STATUS_AUTHORITY_INVALID).value(), |
| 133 msg='Cert OK is invalid') |
| 134 |
93 | 135 |
94 if __name__ == '__main__': | 136 if __name__ == '__main__': |
95 pyauto_functional.Main() | 137 pyauto_functional.Main() |
OLD | NEW |