Automating SSL client-side certificates in Firefox and Selenium testing -
is possible test client side ssl certificates selenium , browser? e.g. can create web driver , give dummy certificates it? or use prepared firefox profile?
creating selenium firefox test profile ssl client-side certificates
you need prepare selenium's webdriver firefox profile whichh has client certificates imported in.
first launch webdriver following configuration in test code:
# pre-seeded firefox profile directory profile_diretory = os.path.join(os.path.dirname(__file__), "..", "..", "certs", "firefox-client-ssl-profile") self.asserttrue(os.path.exists(profile_diretory)) profile = firefoxprofile(profile_diretory) # make sure client side cert seletion not interrupt test # xxx: happens in other language versions? profile.set_preference("security.default_personal_cert", "select automatically") self.driver = webdriver(firefox_profile=profile) self.selenium_helper = seleniumhelper(self, self.driver) self.selenium_helper.driver = self.driver start unit tests , drive them point zope test server up. stop tests "import pdb ; pdb.set_trace()"
you should have selenium's "webdriver" firefox instance on screen.
import client side certificate. preferences > advanced > encryption > view certificates. import "client.p12" client-side certificate supply.
visit in url triggering client-side certificate dialog in webdriver's firefox::
https://yourservevr/triggers-client-side-certificate-ssl-handshake this should prompt accept client side certificate against test server. accept manually.
visit in menu > troubleshooting information > application basics > show in finder. opens temporary directory holding webdriver's active profile files.
copy firefox profile files cert8.db , key3.db unit test package webdriver's firefox profile's seed folder. folder selenium picks seeds firefox web driver when test starts firefox-client-ssl-profile.
interrupt tests. restart tests. run until pause again. in webdriver's firefox see in settings contains certificates did approve on last run in preferences > advanced > encryption > view certificates.
more info
Comments
Post a Comment