Commit 0044f585 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Chromium LUCI CQ

[iOS] Add SSL tests

Add tests to load bad SSL pages and navigate back/forward/proceed.

Bug: none
Change-Id: I69ca6998a4477515ac63ad201ef7bc6491c8ddeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2618138
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841555}
parent 7dcc72b3
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/earl_grey_test.h" #import "ios/testing/earl_grey/earl_grey_test.h"
#include "ios/testing/embedded_test_server_handlers.h" #include "ios/testing/embedded_test_server_handlers.h"
...@@ -38,11 +39,7 @@ ...@@ -38,11 +39,7 @@
_HTTPSServer = std::make_unique<net::test_server::EmbeddedTestServer>( _HTTPSServer = std::make_unique<net::test_server::EmbeddedTestServer>(
net::test_server::EmbeddedTestServer::TYPE_HTTPS); net::test_server::EmbeddedTestServer::TYPE_HTTPS);
RegisterDefaultHandlers(_HTTPSServer.get()); RegisterDefaultHandlers(_HTTPSServer.get());
}
// Test loading a page with a bad SSL certificate from the NTP, to avoid
// https://crbug.com/1067250 from regressing.
- (void)testBadSSLOnNTP {
GREYAssertTrue(_HTTPSServer->Start(), @"Test server failed to start."); GREYAssertTrue(_HTTPSServer->Start(), @"Test server failed to start.");
const GURL pageURL = _HTTPSServer->GetURL("/echo"); const GURL pageURL = _HTTPSServer->GetURL("/echo");
...@@ -52,17 +49,43 @@ ...@@ -52,17 +49,43 @@
IDS_SSL_V2_HEADING)]; IDS_SSL_V2_HEADING)];
} }
// Test loading a page with a bad SSL certificate during session restore, to // Tests loading a bad ssl page and tapping "proceed".
// avoid regressing https://crbug.com/1050808. - (void)testProceedToBadSSL {
- (void)testBadSSLInSessionRestore { // Tap on the "Proceed" link and verify that we go to the unsafe page.
GREYAssertTrue(_HTTPSServer->Start(), @"Test server failed to start."); [ChromeEarlGrey tapWebStateElementWithID:@"details-button"];
[ChromeEarlGrey tapWebStateElementWithID:@"proceed-link"];
[ChromeEarlGrey waitForWebStateContainingText:"Echo"];
}
// Tests loading a bad ssl page and tapping "Back to safety". The bad ssl page
// is loaded from the NTP to prevent https://crbug.com/1067250 from regressing.
- (void)testBackToSafetyFromBadSSL {
// Tap on the "Back to safety" link and verify that we go to the NTP.
[ChromeEarlGrey tapWebStateElementWithID:@"primary-button"];
[[EarlGrey selectElementWithMatcher:chrome_test_util::FakeOmnibox()]
assertWithMatcher:grey_sufficientlyVisible()];
}
// Tests loading a BadSSL URL then a good URL then pressing back to navigates
// back to the BadSSL URL is showing the warning.
- (void)testNavigateBackToBadSSL {
// Load a server without SSL issues.
GREYAssertTrue(self.testServer->Start(), @"Test server failed to start.");
GURL pageURL = _HTTPSServer->GetURL("/echo"); const GURL pageURL = self.testServer->GetURL("/echo");
[ChromeEarlGrey loadURL:pageURL]; [ChromeEarlGrey loadURL:pageURL];
[ChromeEarlGrey waitForWebStateContainingText:"Echo"];
// Navigate back to the bad SSL page.
[ChromeEarlGrey goBack];
[ChromeEarlGrey waitForWebStateContainingText:l10n_util::GetStringUTF8( [ChromeEarlGrey waitForWebStateContainingText:l10n_util::GetStringUTF8(
IDS_SSL_V2_HEADING)]; IDS_SSL_V2_HEADING)];
}
// Test loading a page with a bad SSL certificate during session restore, to
// avoid regressing https://crbug.com/1050808.
- (void)testBadSSLInSessionRestore {
[ChromeEarlGrey triggerRestoreViaTabGridRemoveAllUndo]; [ChromeEarlGrey triggerRestoreViaTabGridRemoveAllUndo];
[ChromeEarlGrey waitForWebStateContainingText:l10n_util::GetStringUTF8( [ChromeEarlGrey waitForWebStateContainingText:l10n_util::GetStringUTF8(
IDS_SSL_V2_HEADING)]; IDS_SSL_V2_HEADING)];
......
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