1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import time
from firefox_puppeteer import PuppeteerMixin
from marionette_driver import By, Wait
from marionette_driver.errors import MarionetteException
from marionette_harness import MarionetteTestCase
class TestSecurityNotification(PuppeteerMixin, MarionetteTestCase):
def setUp(self):
super(TestSecurityNotification, self).setUp()
self.urls = [
# Invalid cert page
'https://ssl-expired.mozqa.com',
# Secure page
'https://ssl-ev.mozqa.com/',
# Insecure page
'http://no-ssl.mozqa.com'
]
self.identity_box = self.browser.navbar.locationbar.identity_box
def test_invalid_cert(self):
with self.marionette.using_context('content'):
# Go to a site that has an invalid (expired) cert
self.assertRaises(MarionetteException, self.marionette.navigate, self.urls[0])
# Wait for the DOM to receive events
time.sleep(1)
# Verify the text in Technical Content contains the page with invalid cert
text = self.marionette.find_element(By.ID, 'badCertTechnicalInfo')
self.assertIn(self.urls[0][8:], text.get_property('textContent'))
# Verify the "Go Back" and "Advanced" buttons appear
self.assertIsNotNone(self.marionette.find_element(By.ID, 'returnButton'))
self.assertIsNotNone(self.marionette.find_element(By.ID, 'advancedButton'))
# Verify the error code is correct
self.assertIn('SEC_ERROR_EXPIRED_CERTIFICATE', text.get_property('textContent'))
def test_secure_website(self):
with self.marionette.using_context('content'):
self.marionette.navigate(self.urls[1])
Wait(self.marionette).until(lambda _: (
self.identity_box.get_property('className') == 'verifiedIdentity')
)
def test_insecure_website(self):
with self.marionette.using_context('content'):
self.marionette.navigate(self.urls[2])
Wait(self.marionette).until(lambda _: (
self.identity_box.get_property('className') == 'unknownIdentity')
)
|