Commit 4fd13395 authored by rsleevi@chromium.org's avatar rsleevi@chromium.org

Revert 126777 - Broke 'win' trybot (shared + all = fails linking pyautolib due to over swigging)

Exposed GetSecurityState and GetPageType to pyAuto.

The GetSecurityState retrieves different security states for the current tab.
The GetPageType returns the type of page showing (normal, interstitial, error).

Added additional tests that uses the exposed hooks.
 - testSSLCertOK
 - testSSLCertIsExpiredAndCertNameMismatches
 - testSSLCertAuthorityOK

TEST=none
BUG=none
Review URL: https://chromiumcodereview.appspot.com/9535022

TBR=dyu@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9705052

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126848 0039d316-1c4b-4281-b951-d872f2087c98
parent 6e289c72
...@@ -13,11 +13,6 @@ ...@@ -13,11 +13,6 @@
'test/automation/browser_proxy.h', 'test/automation/browser_proxy.h',
'test/automation/tab_proxy.cc', 'test/automation/tab_proxy.cc',
'test/automation/tab_proxy.h', 'test/automation/tab_proxy.h',
'../content/public/common/page_type.h',
'../content/public/common/security_style.h',
# Must come before cert_status_flags.h
'../net/base/net_export.h',
'../net/base/cert_status_flags.h',
], ],
'pyautolib_libraries': [ 'pyautolib_libraries': [
], ],
......
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -90,46 +90,6 @@ class SSLTest(pyauto.PyUITest): ...@@ -90,46 +90,6 @@ class SSLTest(pyauto.PyUITest):
self.assertEqual(self.GetActiveTabTitle(), first_page_title, self.assertEqual(self.GetActiveTabTitle(), first_page_title,
msg="Did not go back to previous page correctly.") msg="Did not go back to previous page correctly.")
def testSSLCertOK(self):
"""Verify Certificate OK does not display interstitial page.
This test also asserts that the page type is normal.
"""
url = self._https_server_ok.GetURL('google.html').spec()
self.NavigateToURL(url)
tab_proxy = self.GetBrowserWindow(0).GetTab(0)
result_dict = tab_proxy.GetPageType()
self.assertTrue(result_dict, msg='Could not determine the type of the page')
self.assertEqual(
result_dict['page_type'], pyauto.PAGE_TYPE_NORMAL,
msg="Cert OK displayed page type %s." % result_dict['page_type'])
def testSSLCertIsExpiredAndCertNameMismatches(self):
"""Verify Certificate Expiration and Certificate Mismatched name."""
for server, cert_status_flag, msg in zip(
(self._https_server_expired, self._https_server_mismatched),
(pyauto.CERT_STATUS_DATE_INVALID,
pyauto.CERT_STATUS_COMMON_NAME_INVALID),
('Cert has not expired', 'Cert name does not mismatch')):
self.NavigateToURL(server.GetURL('google.html').spec())
result_dict = self.GetBrowserWindow(0).GetTab(0).GetSecurityState()
self.assertTrue(result_dict, msg='Could not get security state info')
self.assertTrue(
result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer(
cert_status_flag).value(),
msg=msg)
def testSSLCertAuthorityOK(self):
"""Verify Certificate OK is valid."""
self.NavigateToURL(
self._https_server_mismatched.GetURL('google.html').spec())
result_dict = self.GetBrowserWindow(0).GetTab(0).GetSecurityState()
self.assertTrue(result_dict, msg='Could not get security state info')
self.assertFalse(
result_dict['ssl_cert_status'] & pyauto.uint32_ptr.frompointer(
pyauto.CERT_STATUS_AUTHORITY_INVALID).value(),
msg='Cert OK is invalid')
if __name__ == '__main__': if __name__ == '__main__':
pyauto_functional.Main() pyauto_functional.Main()
...@@ -17,10 +17,8 @@ ...@@ -17,10 +17,8 @@
%module(docstring="Python interface to Automation Proxy.") pyautolib %module(docstring="Python interface to Automation Proxy.") pyautolib
%feature("autodoc", "1"); %feature("autodoc", "1");
%include <cpointer.i>
%include <std_string.i>
%include <std_wstring.i> %include <std_wstring.i>
%include <typemaps.i> %include <std_string.i>
%include "chrome/test/pyautolib/argc_argv.i" %include "chrome/test/pyautolib/argc_argv.i"
...@@ -32,11 +30,6 @@ ...@@ -32,11 +30,6 @@
%include "chrome/app/chrome_dll_resource.h" %include "chrome/app/chrome_dll_resource.h"
%include "chrome/common/automation_constants.h" %include "chrome/common/automation_constants.h"
%include "chrome/common/pref_names.h" %include "chrome/common/pref_names.h"
%include "content/public/common/page_type.h"
%include "content/public/common/security_style.h"
// Must come before cert_status_flags.h
%include "net/base/net_export.h"
%include "net/base/cert_status_flags.h"
%{ %{
#include "chrome/common/automation_constants.h" #include "chrome/common/automation_constants.h"
...@@ -154,42 +147,6 @@ class TabProxy { ...@@ -154,42 +147,6 @@ class TabProxy {
"button, if false to 'Take me out of there' button.") "button, if false to 'Take me out of there' button.")
TakeActionOnSSLBlockingPage; TakeActionOnSSLBlockingPage;
bool TakeActionOnSSLBlockingPage(bool proceed); bool TakeActionOnSSLBlockingPage(bool proceed);
%extend {
%feature("docstring", "Retrieves the different security states for the "
"current tab.")
GetSecurityState;
PyObject* GetSecurityState() {
content::SecurityStyle security_style;
net::CertStatus ssl_cert_status;
int insecure_content_status;
PyObject* result_dict = PyDict_New();
if ($self->GetSecurityState(
&security_style, &ssl_cert_status, &insecure_content_status)) {
PyDict_SetItem(result_dict, PyString_FromString("security_style"),
PyInt_FromLong(security_style));
PyDict_SetItem(result_dict, PyString_FromString("ssl_cert_status"),
PyInt_FromLong(ssl_cert_status));
PyDict_SetItem(result_dict,
PyString_FromString("insecure_content_status"),
PyInt_FromLong(insecure_content_status));
}
return result_dict;
}
};
%extend {
%feature("docstring", "Returns the type of page currently showing "
"(normal, interstitial, error.")
GetPageType;
PyObject* GetPageType() {
content::PageType page_type;
PyObject* result_dict = PyDict_New();
if ($self->GetPageType(&page_type)) {
PyDict_SetItem(result_dict, PyString_FromString("page_type"),
PyInt_FromLong(page_type));
}
return result_dict;
}
};
// HTTP Auth // HTTP Auth
%feature("docstring", %feature("docstring",
...@@ -518,6 +475,3 @@ struct HTTPSOptions { ...@@ -518,6 +475,3 @@ struct HTTPSOptions {
%{ %{
typedef net::TestServer::HTTPSOptions HTTPSOptions; typedef net::TestServer::HTTPSOptions HTTPSOptions;
%} %}
%pointer_class(int, int_ptr);
%pointer_class(uint32, uint32_ptr);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment