diff options
Diffstat (limited to 'tests/auto/quick/certificateerror')
6 files changed, 0 insertions, 323 deletions
diff --git a/tests/auto/quick/certificateerror/WebView.qml b/tests/auto/quick/certificateerror/WebView.qml deleted file mode 100644 index 97abdfb98..000000000 --- a/tests/auto/quick/certificateerror/WebView.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtWebEngine 1.4 -import QtQuick.Window 2.0 -import QtTest 1.0 -import io.qt.tester 1.0 - -Window { - width: 50 - height: 50 - visible: true - - TestHandler { - id: handler - onLoadPage: function(url) { - view.url = url - } - } - - WebEngineView { - id: view - anchors.fill: parent - onLoadingChanged: function(request) { - if (request.status === WebEngineView.LoadSucceededStatus) { - handler.loadSuccess = true - } else if (request.status === WebEngineView.LoadFailedStatus) { - handler.loadSuccess = false - } - } - onCertificateError: function(error) { - handler.certificateError = error - } - Component.onCompleted: { - view.settings.errorPageEnabled = false - } - } -} diff --git a/tests/auto/quick/certificateerror/certificateerror.pro b/tests/auto/quick/certificateerror/certificateerror.pro deleted file mode 100644 index 27d5a3cc1..000000000 --- a/tests/auto/quick/certificateerror/certificateerror.pro +++ /dev/null @@ -1,7 +0,0 @@ -include(../tests.pri) -include(../../shared/https.pri) -QT *= webenginecore-private webengine webengine-private -HEADERS += $$PWD/testhandler.h -SOURCES += $$PWD/testhandler.cpp -RESOURCES += certificateerror.qrc - diff --git a/tests/auto/quick/certificateerror/certificateerror.qrc b/tests/auto/quick/certificateerror/certificateerror.qrc deleted file mode 100644 index bfc3013e7..000000000 --- a/tests/auto/quick/certificateerror/certificateerror.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>WebView.qml</file> - </qresource> -</RCC> diff --git a/tests/auto/quick/certificateerror/testhandler.cpp b/tests/auto/quick/certificateerror/testhandler.cpp deleted file mode 100644 index cb6710aa3..000000000 --- a/tests/auto/quick/certificateerror/testhandler.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "testhandler.h" - -TestHandler::TestHandler(QObject *parent) : QObject(parent) -{ - setObjectName(QStringLiteral("TestListner")); -} - -void TestHandler::load(const QUrl &page) -{ - emit loadPage(page); -} - -void TestHandler::setLoadSuccess(bool success) -{ - if (m_loadSuccess != success) { - m_loadSuccess = success; - emit loadSuccessChanged(); - } -} - -bool TestHandler::loadSuccess() const -{ - return m_loadSuccess; -} - -QWebEngineCertificateError TestHandler::certificateError() const -{ - return *m_error; -} - -void TestHandler::setCertificateError(QWebEngineCertificateError error) -{ - m_error = new QWebEngineCertificateError(error); - emit certificateErrorChanged(); -} diff --git a/tests/auto/quick/certificateerror/testhandler.h b/tests/auto/quick/certificateerror/testhandler.h deleted file mode 100644 index a6d95d9a9..000000000 --- a/tests/auto/quick/certificateerror/testhandler.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef TESTHANDLER_H -#define TESTHANDLER_H - -#include <QWebEngineCertificateError> - -class TestHandler : public QObject -{ - Q_OBJECT - Q_PROPERTY(QWebEngineCertificateError certificateError READ certificateError WRITE - setCertificateError NOTIFY certificateErrorChanged) - Q_PROPERTY(bool loadSuccess READ loadSuccess WRITE setLoadSuccess NOTIFY loadSuccessChanged) -public: - explicit TestHandler(QObject *parent = nullptr); - QWebEngineCertificateError certificateError() const; - - void setCertificateError(QWebEngineCertificateError error); - void setLoadSuccess(bool success); - bool loadSuccess() const; - void load(const QUrl &page); - -signals: - void loadPage(const QUrl &page); - void certificateErrorChanged(); - void loadSuccessChanged(); - -private: - QWebEngineCertificateError *m_error = nullptr; - bool m_loadSuccess = false; -}; - -#endif // TESTHANDLER_H diff --git a/tests/auto/quick/certificateerror/tst_certificateerror.cpp b/tests/auto/quick/certificateerror/tst_certificateerror.cpp deleted file mode 100644 index 3e2dc85fb..000000000 --- a/tests/auto/quick/certificateerror/tst_certificateerror.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "testhandler.h" -#include <httpsserver.h> -#include <util.h> -#include <QWebEngineCertificateError> -#include <QQuickWebEngineProfile> -#include <QQmlApplicationEngine> -#include <QQuickWindow> -#include <QtTest/QtTest> - -class tst_CertificateError : public QObject -{ - Q_OBJECT -public: - tst_CertificateError() { } - -private Q_SLOTS: - void initTestCase(); - void handleError_data(); - void handleError(); - -private: - QScopedPointer<QQmlApplicationEngine> m_engine; - QQuickWindow *m_widnow = nullptr; - TestHandler *m_handler = nullptr; -}; - -void tst_CertificateError::initTestCase() -{ - QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true); - qmlRegisterType<TestHandler>("io.qt.tester", 1, 0, "TestHandler"); - m_engine.reset(new QQmlApplicationEngine()); - m_engine->load(QUrl(QStringLiteral("qrc:/WebView.qml"))); - m_widnow = qobject_cast<QQuickWindow *>(m_engine->rootObjects().first()); - Q_ASSERT(m_widnow); - m_handler = m_widnow->findChild<TestHandler *>(QStringLiteral("TestListner")); - Q_ASSERT(m_handler); -} - -void tst_CertificateError::handleError_data() -{ - QTest::addColumn<bool>("deferError"); - QTest::addColumn<bool>("acceptCertificate"); - QTest::addColumn<QString>("expectedContent"); - QTest::addRow("Reject") << false << false << QString(); - QTest::addRow("DeferReject") << true << false << QString(); - QTest::addRow("DeferAccept") << true << true << "TEST"; -} - -void tst_CertificateError::handleError() -{ - HttpsServer server; - server.setExpectError(true); - QVERIFY(server.start()); - - connect(&server, &HttpsServer::newRequest, [&](HttpReqRep *rr) { - rr->setResponseBody(QByteArrayLiteral("<html><body>TEST</body></html>")); - rr->sendResponse(); - }); - - QFETCH(bool, deferError); - QFETCH(bool, acceptCertificate); - QFETCH(QString, expectedContent); - - QSignalSpy certificateErrorSpy(m_handler, &TestHandler::certificateErrorChanged); - m_handler->load(server.url()); - QTRY_COMPARE(certificateErrorSpy.count(), 1); - QWebEngineCertificateError error = m_handler->certificateError(); - - if (deferError) { - error.defer(); - return; - } - - if (acceptCertificate) - error.acceptCertificate(); - else - error.rejectCertificate(); - - QVERIFY(error.isOverridable()); - auto chain = error.certificateChain(); - QCOMPARE(chain.size(), 2); - QCOMPARE(chain[0].serialNumber(), "3b:dd:1a:b7:2f:40:32:3b:c1:bf:37:d4:86:bd:56:c1:d0:6b:2a:43"); - QCOMPARE(chain[1].serialNumber(), "6d:52:fb:b4:57:3b:b2:03:c8:62:7b:7e:44:45:5c:d3:08:87:74:17"); - - if (deferError) { - QVERIFY(!m_handler->loadSuccess()); - - if (acceptCertificate) - error.acceptCertificate(); - else - error.rejectCertificate(); - } - QTRY_COMPARE_WITH_TIMEOUT(m_handler->loadSuccess(), acceptCertificate, 3000); -} - -static QByteArrayList params; -W_QTEST_MAIN(tst_CertificateError, params) -#include <tst_certificateerror.moc> |