1/****************************************************************************
2**
3** Copyright (C) 2016 Kurt Pattyn <pattyn.kurt@gmail.com>.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28#include <QtTest/QtTest>
29#include <QtTest/qtestcase.h>
30#include <QtCore/QDebug>
31#include <QtCore/QByteArray>
32#include <QtCore/QtEndian>
33
34#include "QtWebSockets/qwebsocketcorsauthenticator.h"
35
36QT_USE_NAMESPACE
37
38class tst_QWebSocketCorsAuthenticator : public QObject
39{
40 Q_OBJECT
41
42public:
43 tst_QWebSocketCorsAuthenticator();
44
45private Q_SLOTS:
46 void initTestCase();
47 void cleanupTestCase();
48 void init();
49 void cleanup();
50
51 void tst_initialization();
52};
53
54tst_QWebSocketCorsAuthenticator::tst_QWebSocketCorsAuthenticator()
55{}
56
57void tst_QWebSocketCorsAuthenticator::initTestCase()
58{
59}
60
61void tst_QWebSocketCorsAuthenticator::cleanupTestCase()
62{}
63
64void tst_QWebSocketCorsAuthenticator::init()
65{
66}
67
68void tst_QWebSocketCorsAuthenticator::cleanup()
69{
70}
71
72void tst_QWebSocketCorsAuthenticator::tst_initialization()
73{
74 {
75 QWebSocketCorsAuthenticator authenticator((QString()));
76
77 QCOMPARE(authenticator.allowed(), true);
78 QCOMPARE(authenticator.origin(), QString());
79 }
80 {
81 QWebSocketCorsAuthenticator authenticator(QStringLiteral("com.somesite"));
82
83 QCOMPARE(authenticator.allowed(), true);
84 QCOMPARE(authenticator.origin(), QStringLiteral("com.somesite"));
85
86 QWebSocketCorsAuthenticator other(authenticator);
87 QCOMPARE(other.origin(), authenticator.origin());
88 QCOMPARE(other.allowed(), authenticator.allowed());
89
90 authenticator.setAllowed(false);
91 QVERIFY(!authenticator.allowed());
92 QCOMPARE(other.allowed(), true); //make sure other is a real copy
93
94 authenticator.setAllowed(true);
95 QVERIFY(authenticator.allowed());
96
97 authenticator.setAllowed(false);
98 other = authenticator;
99 QCOMPARE(other.origin(), authenticator.origin());
100 QCOMPARE(other.allowed(), authenticator.allowed());
101 }
102}
103
104QTEST_MAIN(tst_QWebSocketCorsAuthenticator)
105
106#include "tst_qwebsocketcorsauthenticator.moc"
107
108

source code of qtwebsockets/tests/auto/websockets/qwebsocketcorsauthenticator/tst_qwebsocketcorsauthenticator.cpp