summaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2019-04-03 15:16:35 +0200
committerMichal Klocek <michal.klocek@qt.io>2019-04-04 16:38:51 +0000
commit320c7316b75be22112cb4802187c3873c9934eab (patch)
tree9b0ade0d4fa7bb7d23a13f63a77d1a3887308883 /tests/auto/quick
parentded7536c90023fdf5f643a180ced405643ba7ab5 (diff)
Fix tst_Dialogs::authenticationDialogRequested
Chromium returns unexpected proxy reply if localhost is used. Since proxy resolver works now, the workaround to trigger dialog with "localhost proxy" can be skipped. Change-Id: I26d88c43779809e4f481101266e6b8784a6b196d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/dialogs/BLACKLIST2
-rw-r--r--tests/auto/quick/dialogs/server.cpp13
-rw-r--r--tests/auto/quick/dialogs/server.h2
-rw-r--r--tests/auto/quick/dialogs/tst_dialogs.cpp17
4 files changed, 21 insertions, 13 deletions
diff --git a/tests/auto/quick/dialogs/BLACKLIST b/tests/auto/quick/dialogs/BLACKLIST
deleted file mode 100644
index 19380e01e..000000000
--- a/tests/auto/quick/dialogs/BLACKLIST
+++ /dev/null
@@ -1,2 +0,0 @@
-[authenticationDialogRequested:Proxy Authentication Dialog]
-*
diff --git a/tests/auto/quick/dialogs/server.cpp b/tests/auto/quick/dialogs/server.cpp
index dc9cfe582..dfc7c97ad 100644
--- a/tests/auto/quick/dialogs/server.cpp
+++ b/tests/auto/quick/dialogs/server.cpp
@@ -33,7 +33,6 @@
Server::Server(QObject *parent) : QObject(parent)
{
- m_data.clear();
connect(&m_server, &QTcpServer::newConnection, this, &Server::handleNewConnection);
}
@@ -42,6 +41,11 @@ bool Server::isListening()
return m_server.isListening();
}
+void Server::setReply(const QByteArray &reply)
+{
+ m_reply = reply;
+}
+
void Server::run()
{
if (!m_server.listen(QHostAddress::LocalHost, 5555))
@@ -69,12 +73,7 @@ void Server::handleReadReady()
if (!m_data.endsWith("\r\n\r\n"))
return;
- if (m_data.contains(QByteArrayLiteral("OPEN_AUTH")))
- socket->write("HTTP/1.1 401 Unauthorized\nWWW-Authenticate: "
- "Basic realm=\"Very Restricted Area\"\r\n\r\n");
- if (m_data.contains(QByteArrayLiteral("OPEN_PROXY")))
- socket->write("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: "
- "Basic realm=\"Proxy requires authentication\"\r\n\r\n");
+ socket->write(m_reply);
m_data.clear();
socket->disconnectFromHost();
}
diff --git a/tests/auto/quick/dialogs/server.h b/tests/auto/quick/dialogs/server.h
index 24da47523..fa9a73811 100644
--- a/tests/auto/quick/dialogs/server.h
+++ b/tests/auto/quick/dialogs/server.h
@@ -40,6 +40,7 @@ public:
explicit Server(QObject *parent = nullptr);
bool isListening();
+ void setReply(const QByteArray &reply);
public slots:
void run();
@@ -50,6 +51,7 @@ private slots:
private:
QByteArray m_data;
+ QByteArray m_reply;
QTcpServer m_server;
};
diff --git a/tests/auto/quick/dialogs/tst_dialogs.cpp b/tests/auto/quick/dialogs/tst_dialogs.cpp
index cecea1831..26a0fe034 100644
--- a/tests/auto/quick/dialogs/tst_dialogs.cpp
+++ b/tests/auto/quick/dialogs/tst_dialogs.cpp
@@ -145,12 +145,19 @@ void tst_Dialogs::authenticationDialogRequested_data()
QTest::addColumn<QUrl>("url");
QTest::addColumn<QQuickWebEngineAuthenticationDialogRequest::AuthenticationType>("type");
QTest::addColumn<QString>("realm");
- QTest::newRow("Http Authentication Dialog") << QUrl("http://localhost:5555/OPEN_AUTH")
+ QTest::addColumn<QByteArray>("reply");
+ QTest::newRow("Http Authentication Dialog") << QUrl("http://localhost:5555/")
<< QQuickWebEngineAuthenticationDialogRequest::AuthenticationTypeHTTP
- << QStringLiteral("Very Restricted Area");
- QTest::newRow("Proxy Authentication Dialog") << QUrl("http://localhost.:5555/OPEN_PROXY")
+ << QStringLiteral("Very Restricted Area")
+ << QByteArrayLiteral("HTTP/1.1 401 Unauthorized\nWWW-Authenticate: "
+ "Basic realm=\"Very Restricted Area\"\r\n\r\n");
+ QTest::newRow("Proxy Authentication Dialog")<< QUrl("http://qt.io/")
<< QQuickWebEngineAuthenticationDialogRequest::AuthenticationTypeProxy
- << QStringLiteral("Proxy requires authentication");
+ << QStringLiteral("Proxy requires authentication")
+ << QByteArrayLiteral("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: "
+ "Basic realm=\"Proxy requires authentication\"\r\n"
+ "content-length: 0\r\n\r\n");
+
}
void tst_Dialogs::authenticationDialogRequested()
@@ -159,7 +166,9 @@ void tst_Dialogs::authenticationDialogRequested()
QFETCH(QQuickWebEngineAuthenticationDialogRequest::AuthenticationType, type);
QFETCH(QString, realm);
+ QFETCH(QByteArray, reply);
Server server;
+ server.setReply(reply);
server.run();
QTRY_VERIFY2(server.isListening(), "Could not setup authentication server");