26
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
* This is the source file for testing EAP Configuration Interface.
|
|
16 |
*/
|
|
17 |
|
|
18 |
/*
|
|
19 |
* %version: 8 %
|
|
20 |
*/
|
|
21 |
|
|
22 |
#ifdef INCLUDE_UI_CASES
|
|
23 |
#warning UI cases included, cases cannot be run in Emulator textshell.
|
|
24 |
#endif
|
|
25 |
|
|
26 |
// System includes
|
|
27 |
#include <QtCore>
|
|
28 |
#include <QTest>
|
|
29 |
#include <cmmanager_shim.h>
|
|
30 |
#include <cmmanagerdefines_shim.h>
|
|
31 |
#include <cmconnectionmethod_shim.h>
|
|
32 |
#include <eapqtconfiginterface.h>
|
|
33 |
#include <eapqtplugininfo.h>
|
|
34 |
#include <eapqtvalidator.h>
|
|
35 |
#include <eapqtpluginhandle.h>
|
|
36 |
#include <eapqtexpandedeaptype.h>
|
|
37 |
#include <eapqtcertificateinfo.h>
|
|
38 |
|
|
39 |
#ifdef INCLUDE_UI_CASES
|
|
40 |
#include <cpbasesettingview.h>
|
|
41 |
#endif
|
|
42 |
|
|
43 |
// User includes
|
|
44 |
#include "testqtconfigutils.h"
|
|
45 |
|
|
46 |
// External function prototypes
|
|
47 |
|
|
48 |
// Local constants
|
|
49 |
static const int global_pluginOrder = 10;
|
|
50 |
static const char global_wpsType[] = { 0xfe, 0x00, 0x37, 0x2a, 0x00, 0x00, 0x00, 0x01 };
|
|
51 |
static const int global_invalidIap = 9999;
|
|
52 |
static int global_undefinedIap = EapQtConfigInterface::IapIdUndefined;
|
|
53 |
static int global_wlanIap = -2;
|
|
54 |
|
|
55 |
// ======== LOCAL FUNCTIONS ========
|
|
56 |
|
|
57 |
// ======== MEMBER FUNCTIONS ========
|
|
58 |
|
|
59 |
// ---------------------------------------------------------
|
|
60 |
// FRAMEWORK FUNCTIONS
|
|
61 |
// ---------------------------------------------------------
|
|
62 |
|
|
63 |
/**
|
|
64 |
* This function will be called before the first test function is executed.
|
|
65 |
*/
|
|
66 |
void TestQtConfigUtils::initTestCase()
|
|
67 |
{
|
|
68 |
mEapConfigIf = new EapQtConfigInterface(EapQtConfigInterface::EapBearerTypeWlan,
|
|
69 |
global_undefinedIap);
|
|
70 |
|
|
71 |
mCmm = new CmManagerShim();
|
|
72 |
mCmmShim = mCmm->createConnectionMethod(CMManagerShim::BearerTypeWlan);
|
|
73 |
mCmmShim->setStringAttribute(CMManagerShim::CmName, QString("EAP unit test"));
|
|
74 |
mCmmShim->update();
|
|
75 |
global_wlanIap = mCmmShim->getIntAttribute(CMManagerShim::CmIapId);
|
|
76 |
}
|
|
77 |
|
|
78 |
/**
|
|
79 |
* This function will be called after the last test function was executed.
|
|
80 |
*/
|
|
81 |
void TestQtConfigUtils::cleanupTestCase()
|
|
82 |
{
|
|
83 |
qDebug("calling mEapConfigIf->setConfigurationReference(global_wlanIap)");
|
|
84 |
mEapConfigIf->setConfigurationReference(global_wlanIap);
|
|
85 |
|
|
86 |
qDebug("calling mEapConfigIf->deleteConfiguration()");
|
|
87 |
mEapConfigIf->deleteConfiguration();
|
|
88 |
|
|
89 |
qDebug("calling delete mEapConfigIf");
|
|
90 |
delete mEapConfigIf;
|
|
91 |
|
|
92 |
qDebug("calling mCmmShim->deleteConnectionMethod()");
|
|
93 |
|
|
94 |
int error;
|
|
95 |
try {
|
|
96 |
mCmmShim->deleteConnectionMethod();
|
|
97 |
} catch (const std::exception &ex) {
|
|
98 |
error = qt_symbian_exception2Error(ex);
|
|
99 |
qDebug("mCmmShim->deleteConnectionMethod() failed with error: %d", error);
|
|
100 |
}
|
|
101 |
|
|
102 |
qDebug("calling delete mCmmShim");
|
|
103 |
try {
|
|
104 |
delete mCmmShim;
|
|
105 |
} catch (const std::exception &ex) {
|
|
106 |
error = qt_symbian_exception2Error(ex);
|
|
107 |
qDebug("delete mCmmShim failed with error: ", error);
|
|
108 |
}
|
|
109 |
|
|
110 |
delete mCmm;
|
|
111 |
}
|
|
112 |
|
|
113 |
/**
|
|
114 |
* This function will be called before each test function is executed.
|
|
115 |
*/
|
|
116 |
void TestQtConfigUtils::init()
|
|
117 |
{
|
|
118 |
|
|
119 |
}
|
|
120 |
|
|
121 |
/**
|
|
122 |
* This function will be called after each test function is executed.
|
|
123 |
*/
|
|
124 |
void TestQtConfigUtils::cleanup()
|
|
125 |
{
|
|
126 |
|
|
127 |
}
|
|
128 |
|
|
129 |
// ---------------------------------------------------------
|
|
130 |
// TEST CASES
|
|
131 |
// ---------------------------------------------------------
|
|
132 |
|
|
133 |
// ---------------------------------------------------------
|
|
134 |
// test EapQtPluginInfo
|
|
135 |
// ---------------------------------------------------------
|
|
136 |
#if 1
|
|
137 |
void TestQtConfigUtils::testEapQtPluginInfoPluginUndefined()
|
|
138 |
{
|
|
139 |
QString pluginName("PluginUndefined");
|
|
140 |
EapQtPluginInfo info(EapQtPluginHandle::PluginUndefined, pluginName, global_pluginOrder);
|
|
141 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginUndefined);
|
|
142 |
QVERIFY(info.localizationId() == pluginName);
|
|
143 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
144 |
}
|
|
145 |
|
|
146 |
void TestQtConfigUtils::testEapQtPluginInfoPluginEapAka()
|
|
147 |
{
|
|
148 |
QString pluginName("PluginEapAka");
|
|
149 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapAka, pluginName, global_pluginOrder);
|
|
150 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapAka);
|
|
151 |
QVERIFY(info.localizationId() == pluginName);
|
|
152 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
153 |
}
|
|
154 |
|
|
155 |
void TestQtConfigUtils::testEapQtPluginInfoPluginEapFast()
|
|
156 |
{
|
|
157 |
QString pluginName("PluginEapFast");
|
|
158 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapFast, pluginName, global_pluginOrder);
|
|
159 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapFast);
|
|
160 |
QVERIFY(info.localizationId() == pluginName);
|
|
161 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
162 |
}
|
|
163 |
|
|
164 |
void TestQtConfigUtils::testEapQtPluginInfoPluginEapGtc()
|
|
165 |
{
|
|
166 |
QString pluginName("PluginEapGtc");
|
|
167 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapGtc, pluginName, global_pluginOrder);
|
|
168 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapGtc);
|
|
169 |
QVERIFY(info.localizationId() == pluginName);
|
|
170 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
171 |
}
|
|
172 |
|
|
173 |
void TestQtConfigUtils::testEapQtPluginInfoPluginLeap()
|
|
174 |
{
|
|
175 |
QString pluginName("PluginLeap");
|
|
176 |
EapQtPluginInfo info(EapQtPluginHandle::PluginLeap, pluginName, global_pluginOrder);
|
|
177 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginLeap);
|
|
178 |
QVERIFY(info.localizationId() == pluginName);
|
|
179 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
180 |
}
|
|
181 |
|
|
182 |
void TestQtConfigUtils::testEapQtPluginInfoPluginEapMschapv2()
|
|
183 |
{
|
|
184 |
QString pluginName("PluginEapMschapv2");
|
|
185 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapMschapv2, pluginName, global_pluginOrder);
|
|
186 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapMschapv2);
|
|
187 |
QVERIFY(info.localizationId() == pluginName);
|
|
188 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
189 |
}
|
|
190 |
|
|
191 |
void TestQtConfigUtils::testEapQtPluginInfoPluginPeap()
|
|
192 |
{
|
|
193 |
QString pluginName("PluginPeap");
|
|
194 |
EapQtPluginInfo info(EapQtPluginHandle::PluginPeap, pluginName, global_pluginOrder);
|
|
195 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginPeap);
|
|
196 |
QVERIFY(info.localizationId() == pluginName);
|
|
197 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
198 |
}
|
|
199 |
|
|
200 |
void TestQtConfigUtils::testEapQtPluginInfoPluginEapSim()
|
|
201 |
{
|
|
202 |
QString pluginName("PluginEapSim");
|
|
203 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapSim, pluginName, global_pluginOrder);
|
|
204 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapSim);
|
|
205 |
QVERIFY(info.localizationId() == pluginName);
|
|
206 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
207 |
}
|
|
208 |
|
|
209 |
void TestQtConfigUtils::testEapQtPluginInfoPluginEapTls()
|
|
210 |
{
|
|
211 |
QString pluginName("PluginEapTls");
|
|
212 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapTls, pluginName, global_pluginOrder);
|
|
213 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapTls);
|
|
214 |
QVERIFY(info.localizationId() == pluginName);
|
|
215 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
216 |
}
|
|
217 |
|
|
218 |
void TestQtConfigUtils::testEapQtPluginInfoPluginEapTtls()
|
|
219 |
{
|
|
220 |
QString pluginName("PluginEapTtls");
|
|
221 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapTtls, pluginName, global_pluginOrder);
|
|
222 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapTtls);
|
|
223 |
QVERIFY(info.localizationId() == pluginName);
|
|
224 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
225 |
}
|
|
226 |
|
|
227 |
void TestQtConfigUtils::testEapQtPluginInfoPluginPap()
|
|
228 |
{
|
|
229 |
QString pluginName("PluginPap");
|
|
230 |
EapQtPluginInfo info(EapQtPluginHandle::PluginPap, pluginName, global_pluginOrder);
|
|
231 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginPap);
|
|
232 |
QVERIFY(info.localizationId() == pluginName);
|
|
233 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
234 |
}
|
|
235 |
|
|
236 |
void TestQtConfigUtils::testEapQtPluginInfoPluginPlainMschapv2()
|
|
237 |
{
|
|
238 |
QString pluginName("PluginPlainMschapv2");
|
|
239 |
EapQtPluginInfo info(EapQtPluginHandle::PluginPlainMschapv2, pluginName, global_pluginOrder);
|
|
240 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginPlainMschapv2);
|
|
241 |
QVERIFY(info.localizationId() == pluginName);
|
|
242 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
243 |
}
|
|
244 |
|
|
245 |
void TestQtConfigUtils::testEapQtPluginInfoAssignment()
|
|
246 |
{
|
|
247 |
QString pluginName1("PluginPlainMschapv2");
|
|
248 |
QString pluginName2("PluginEapTtls");
|
|
249 |
|
|
250 |
EapQtPluginInfo info1(EapQtPluginHandle::PluginPlainMschapv2, pluginName1, global_pluginOrder);
|
|
251 |
EapQtPluginInfo info2(EapQtPluginHandle::PluginEapTtls, pluginName2, global_pluginOrder + 1);
|
|
252 |
|
|
253 |
info1 = info2;
|
|
254 |
|
|
255 |
QVERIFY(info1.pluginHandle() == info2.pluginHandle());
|
|
256 |
QVERIFY(info1.localizationId() == info2.localizationId());
|
|
257 |
QVERIFY(info1.orderNumber() == info2.orderNumber());
|
|
258 |
}
|
|
259 |
|
|
260 |
void TestQtConfigUtils::testEapQtPluginInfoSelfAssignment()
|
|
261 |
{
|
|
262 |
QString pluginName("PluginEapSim");
|
|
263 |
EapQtPluginInfo info(EapQtPluginHandle::PluginEapSim, pluginName, global_pluginOrder);
|
|
264 |
info = info;
|
|
265 |
|
|
266 |
QVERIFY(info.pluginHandle() == EapQtPluginHandle::PluginEapSim);
|
|
267 |
QVERIFY(info.localizationId() == pluginName);
|
|
268 |
QVERIFY(info.orderNumber() == global_pluginOrder);
|
|
269 |
}
|
|
270 |
|
|
271 |
// ---------------------------------------------------------
|
|
272 |
// test EapQtPluginHandle
|
|
273 |
// ---------------------------------------------------------
|
|
274 |
|
|
275 |
void TestQtConfigUtils::testEapQtPluginHandleDefaultConstructor()
|
|
276 |
{
|
|
277 |
EapQtPluginHandle handle;
|
|
278 |
QVERIFY(handle == EapQtPluginHandle::PluginUndefined);
|
|
279 |
}
|
|
280 |
|
|
281 |
void TestQtConfigUtils::testEapQtPluginHandlePluginLastConstructor()
|
|
282 |
{
|
|
283 |
EapQtPluginHandle handle(EapQtPluginHandle::PluginLast);
|
|
284 |
QVERIFY(handle.pluginId() == EapQtPluginHandle::PluginUndefined);
|
|
285 |
}
|
|
286 |
|
|
287 |
void TestQtConfigUtils::testEapQtPluginHandleEapTypeConstructor()
|
|
288 |
{
|
|
289 |
EapQtPluginHandle handle(EapQtExpandedEapType::TypeEapAka);
|
|
290 |
QVERIFY(handle.pluginId() == EapQtPluginHandle::PluginEapAka);
|
|
291 |
}
|
|
292 |
|
|
293 |
void TestQtConfigUtils::testEapQtPluginHandleEapTypeUidConstructor()
|
|
294 |
{
|
|
295 |
int uid(0x12345678);
|
|
296 |
EapQtPluginHandle handle(EapQtExpandedEapType::TypePeap, uid);
|
|
297 |
QVERIFY(handle.pluginId() == EapQtPluginHandle::PluginPeap);
|
|
298 |
QVERIFY(handle.protocolImplementationUid() == uid);
|
|
299 |
}
|
|
300 |
|
|
301 |
void TestQtConfigUtils::testEapQtPluginHandleSelfAssignment()
|
|
302 |
{
|
|
303 |
EapQtPluginHandle handle(EapQtPluginHandle::PluginEapTls);
|
|
304 |
handle = handle;
|
|
305 |
QVERIFY(handle.pluginId() == EapQtPluginHandle::PluginEapTls);
|
|
306 |
}
|
|
307 |
|
|
308 |
// ---------------------------------------------------------
|
|
309 |
// test EapQtExpandedEapType
|
|
310 |
// ---------------------------------------------------------
|
|
311 |
|
|
312 |
void TestQtConfigUtils::testEapQtExpandedEapTypeDefaultConstructor()
|
|
313 |
{
|
|
314 |
EapQtExpandedEapType eapType;
|
|
315 |
QVERIFY(eapType.type() == EapQtExpandedEapType::TypeUndefined);
|
|
316 |
QVERIFY(eapType.eapExpandedData().count() == 0);
|
|
317 |
}
|
|
318 |
|
|
319 |
void TestQtConfigUtils::testEapQtExpandedEapTypeLastConstructor()
|
|
320 |
{
|
|
321 |
EapQtExpandedEapType eapType(EapQtExpandedEapType::TypeLast);
|
|
322 |
QVERIFY(eapType.type() == EapQtExpandedEapType::TypeUndefined);
|
|
323 |
}
|
|
324 |
|
|
325 |
void TestQtConfigUtils::testEapQtExpandedEapTypeConstructorWpsType()
|
|
326 |
{
|
|
327 |
EapQtExpandedEapType eapType(EapQtExpandedEapType::TypeProtectedSetup);
|
|
328 |
QVERIFY(eapType.type() == EapQtExpandedEapType::TypeProtectedSetup);
|
|
329 |
QVERIFY(eapType.eapExpandedData() == QByteArray(global_wpsType, sizeof(global_wpsType)));
|
|
330 |
}
|
|
331 |
|
|
332 |
void TestQtConfigUtils::testEapQtExpandedEapTypeConstructorWpsByteArray()
|
|
333 |
{
|
|
334 |
QByteArray wpsArray(global_wpsType, sizeof(global_wpsType));
|
|
335 |
EapQtExpandedEapType eapType(wpsArray);
|
|
336 |
|
|
337 |
QVERIFY(eapType.type() == EapQtExpandedEapType::TypeProtectedSetup);
|
|
338 |
QVERIFY(eapType.eapExpandedData() == wpsArray);
|
|
339 |
}
|
|
340 |
|
|
341 |
void TestQtConfigUtils::testEapQtExpandedEapTypeAssignment()
|
|
342 |
{
|
|
343 |
EapQtExpandedEapType eapType1;
|
|
344 |
EapQtExpandedEapType eapType2(EapQtExpandedEapType::TypePlainMschapv2);
|
|
345 |
eapType1 = eapType2;
|
|
346 |
|
|
347 |
QVERIFY(eapType1.type() == eapType2.type());
|
|
348 |
QVERIFY(eapType1.eapExpandedData() == eapType2.eapExpandedData());
|
|
349 |
QVERIFY(eapType1 == eapType2);
|
|
350 |
}
|
|
351 |
|
|
352 |
void TestQtConfigUtils::testEapQtExpandedEapTypeSelfAssignment()
|
|
353 |
{
|
|
354 |
EapQtExpandedEapType eapType(EapQtExpandedEapType::TypeEapTtls);
|
|
355 |
eapType = eapType;
|
|
356 |
|
|
357 |
QVERIFY(eapType == EapQtExpandedEapType::TypeEapTtls);
|
|
358 |
// to test != operator as well
|
|
359 |
QVERIFY(eapType != EapQtExpandedEapType::TypeUndefined);
|
|
360 |
}
|
|
361 |
|
|
362 |
// ---------------------------------------------------------
|
|
363 |
// test EapQtConfigInterface
|
|
364 |
// ---------------------------------------------------------
|
|
365 |
|
|
366 |
void TestQtConfigUtils::testDefaultConstructor()
|
|
367 |
{
|
|
368 |
EapQtConfigInterface localEapConfigIf;
|
|
369 |
|
|
370 |
QScopedPointer<EapQtValidator> val(localEapConfigIf.validatorEap(
|
|
371 |
EapQtExpandedEapType::TypeEapAka, EapQtConfig::Username));
|
|
372 |
|
|
373 |
EapQtValidator::Status status = val->validate(QString("test"));
|
|
374 |
QVERIFY(status == EapQtValidator::StatusOk);
|
|
375 |
|
|
376 |
status = val->validate(QString());
|
|
377 |
QVERIFY(status == EapQtValidator::StatusOk);
|
|
378 |
|
|
379 |
status = val->validate(QByteArray());
|
|
380 |
QVERIFY(status == EapQtValidator::StatusInvalid);
|
|
381 |
|
|
382 |
status = val->validate(QString("pwd@realm"));
|
|
383 |
QVERIFY(status == EapQtValidator::StatusInvalidCharacters);
|
|
384 |
|
|
385 |
status = val->validate(QString("@"));
|
|
386 |
QVERIFY(status == EapQtValidator::StatusInvalidCharacters);
|
|
387 |
|
|
388 |
status = val->validate(QString("X"));
|
|
389 |
QVERIFY(status == EapQtValidator::StatusOk);
|
|
390 |
|
|
391 |
status = val->validate(QString("uSerNäme"));
|
|
392 |
QVERIFY(status == EapQtValidator::StatusOk);
|
|
393 |
|
|
394 |
status = val->validate(QString("as0d7fg9µ8a&&¤%GSB*^ü~||><:M;_-§][6{]{[]£"));
|
|
395 |
QVERIFY(status == EapQtValidator::StatusOk);
|
|
396 |
|
|
397 |
QString veryLong(254, QChar('Z'));
|
|
398 |
|
|
399 |
status = val->validate(veryLong);
|
|
400 |
QVERIFY(status == EapQtValidator::StatusOk);
|
|
401 |
|
|
402 |
veryLong.append("}");
|
|
403 |
|
|
404 |
status = val->validate(veryLong);
|
|
405 |
QVERIFY(status == EapQtValidator::StatusOk);
|
|
406 |
|
|
407 |
veryLong.append("K");
|
|
408 |
|
|
409 |
status = val->validate(veryLong);
|
|
410 |
QVERIFY(status == EapQtValidator::StatusTooLong);
|
|
411 |
|
|
412 |
// this one should throw since not supported for validator instance
|
|
413 |
bool pass(false);
|
|
414 |
try {
|
|
415 |
localEapConfigIf.setConfigurationReference(global_wlanIap);
|
|
416 |
} catch (const std::exception&) {
|
|
417 |
pass = true;
|
|
418 |
}
|
|
419 |
QVERIFY(pass == true);
|
|
420 |
}
|
|
421 |
|
|
422 |
void TestQtConfigUtils::testParallelInstances()
|
|
423 |
{
|
|
424 |
EapQtConfigInterface localEapConfigIf(EapQtConfigInterface::EapBearerTypeWlan,
|
|
425 |
global_undefinedIap);
|
|
426 |
QVERIFY(localEapConfigIf.isSupportedOuterType(EapQtPluginHandle::PluginEapAka) == true);
|
|
427 |
QVERIFY(mEapConfigIf->isSupportedOuterType(EapQtPluginHandle::PluginPeap) == true);
|
|
428 |
}
|
|
429 |
|
|
430 |
void TestQtConfigUtils::testConstructorThrowing()
|
|
431 |
{
|
|
432 |
// this one should throw since IAP id is invalid
|
|
433 |
bool pass(false);
|
|
434 |
try {
|
|
435 |
EapQtConfigInterface localEapConfigIf(EapQtConfigInterface::EapBearerTypeWlan,
|
|
436 |
global_invalidIap);
|
|
437 |
} catch (const std::exception&) {
|
|
438 |
pass = true;
|
|
439 |
}
|
|
440 |
QVERIFY(pass == true);
|
|
441 |
}
|
|
442 |
|
|
443 |
void TestQtConfigUtils::testSetConfigurationReferenceUndefinedAgain()
|
|
444 |
{
|
|
445 |
// set the same again (global_undefinedIap)
|
|
446 |
QVERIFY(mEapConfigIf->setConfigurationReference(global_undefinedIap) == true);
|
|
447 |
}
|
|
448 |
|
|
449 |
void TestQtConfigUtils::testSetConfigurationReferenceFailure()
|
|
450 |
{
|
|
451 |
// fails since referred IAP does not exist
|
|
452 |
QVERIFY(mEapConfigIf->setConfigurationReference(global_invalidIap) == false);
|
|
453 |
// change back to correct
|
|
454 |
QVERIFY(mEapConfigIf->setConfigurationReference(global_undefinedIap) == true);
|
|
455 |
}
|
|
456 |
|
|
457 |
void TestQtConfigUtils::testCertificateAuthorityCertificates()
|
|
458 |
{
|
|
459 |
mCaCertInfo = mEapConfigIf->certificateAuthorityCertificates();
|
|
460 |
QVERIFY(mCaCertInfo.count() > 0);
|
|
461 |
}
|
|
462 |
|
|
463 |
void TestQtConfigUtils::testUserCertificates()
|
|
464 |
{
|
|
465 |
mUserCertInfo = mEapConfigIf->userCertificates();
|
|
466 |
QEXPECT_FAIL("", "No user certificates installed?", Continue);
|
|
467 |
QVERIFY(mUserCertInfo.count() > 0);
|
|
468 |
}
|
|
469 |
|
|
470 |
void TestQtConfigUtils::testSupportedOuterTypes()
|
|
471 |
{
|
|
472 |
QList<EapQtPluginInfo> plugins;
|
|
473 |
plugins = mEapConfigIf->supportedOuterTypes();
|
|
474 |
|
|
475 |
QVERIFY(plugins.count() > 0);
|
|
476 |
|
|
477 |
QList<EapQtPluginHandle> handles;
|
|
478 |
for (int i = 0; i < plugins.count(); i++) {
|
|
479 |
handles.append(plugins[i].pluginHandle());
|
|
480 |
}
|
|
481 |
|
|
482 |
// check that handles contain outer types
|
|
483 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapAka) == true);
|
|
484 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginPeap) == true);
|
|
485 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapSim) == true);
|
|
486 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapTls) == true);
|
|
487 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapTtls) == true);
|
|
488 |
|
|
489 |
// and no inner types
|
|
490 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapGtc) == false);
|
|
491 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapMschapv2) == false);
|
|
492 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginPap) == false);
|
|
493 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginPlainMschapv2) == false);
|
|
494 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginUndefined) == false);
|
|
495 |
}
|
|
496 |
|
|
497 |
void TestQtConfigUtils::testSupportedInnerTypesPeap()
|
|
498 |
{
|
|
499 |
QList<EapQtPluginInfo> plugins;
|
|
500 |
plugins = mEapConfigIf->supportedInnerTypes(EapQtPluginHandle::PluginPeap);
|
|
501 |
|
|
502 |
QVERIFY(plugins.count() > 0);
|
|
503 |
|
|
504 |
QList<EapQtPluginHandle> handles;
|
|
505 |
for (int i = 0; i < plugins.count(); i++) {
|
|
506 |
handles.append(plugins[i].pluginHandle());
|
|
507 |
}
|
|
508 |
|
|
509 |
// check that handles contain correct types
|
|
510 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapAka) == true);
|
|
511 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapGtc) == true);
|
|
512 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapMschapv2) == true);
|
|
513 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapSim) == true);
|
|
514 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapTls) == true);
|
|
515 |
|
|
516 |
// and other types
|
|
517 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginUndefined) == false);
|
|
518 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginPeap) == false);
|
|
519 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginEapTtls) == false);
|
|
520 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginPap) == false);
|
|
521 |
QVERIFY(handles.contains(EapQtPluginHandle::PluginPlainMschapv2) == false);
|
|
522 |
}
|
|
523 |
|
|
524 |
void TestQtConfigUtils::testIsSupportedOuterTypePeap()
|
|
525 |
{
|
|
526 |
QVERIFY(mEapConfigIf->isSupportedOuterType(EapQtPluginHandle::PluginPeap) == true);
|
|
527 |
}
|
|
528 |
|
|
529 |
void TestQtConfigUtils::testIsSupportedInnerTypePeap()
|
|
530 |
{
|
|
531 |
QVERIFY(mEapConfigIf->isSupportedInnerType(EapQtPluginHandle::PluginPeap,
|
|
532 |
EapQtPluginHandle::PluginPeap) == false);
|
|
533 |
QVERIFY(mEapConfigIf->isSupportedInnerType(EapQtPluginHandle::PluginPeap,
|
|
534 |
EapQtPluginHandle::PluginEapGtc) == true);
|
|
535 |
}
|
|
536 |
|
|
537 |
void TestQtConfigUtils::testSetConfigurationReferenceValidWlanIap()
|
|
538 |
{
|
|
539 |
QVERIFY(mEapConfigIf->setConfigurationReference(global_wlanIap) == true);
|
|
540 |
}
|
|
541 |
|
|
542 |
void TestQtConfigUtils::testTestAgainForValidWlanIap()
|
|
543 |
{
|
|
544 |
testCertificateAuthorityCertificates();
|
|
545 |
testUserCertificates();
|
|
546 |
testSupportedOuterTypes();
|
|
547 |
testSupportedInnerTypesPeap();
|
|
548 |
testIsSupportedOuterTypePeap();
|
|
549 |
testIsSupportedInnerTypePeap();
|
|
550 |
}
|
|
551 |
|
|
552 |
void TestQtConfigUtils::testSelectedOuterTypes()
|
|
553 |
{
|
|
554 |
QList<EapQtPluginHandle> outers;
|
|
555 |
outers = mEapConfigIf->selectedOuterTypes();
|
|
556 |
|
|
557 |
QVERIFY(outers.count() == 0);
|
|
558 |
|
|
559 |
outers.clear();
|
|
560 |
outers.append(EapQtPluginHandle::PluginPeap);
|
|
561 |
outers.append(EapQtPluginHandle::PluginEapTls);
|
|
562 |
// this must not be set when reading again
|
|
563 |
outers.append(EapQtPluginHandle::PluginEapGtc);
|
|
564 |
|
|
565 |
QVERIFY(mEapConfigIf->setSelectedOuterTypes(outers) == true);
|
|
566 |
|
|
567 |
outers.clear();
|
|
568 |
outers = mEapConfigIf->selectedOuterTypes();
|
|
569 |
|
|
570 |
QVERIFY(outers.count() == 2);
|
|
571 |
|
|
572 |
QVERIFY(outers.contains(EapQtPluginHandle::PluginPeap) == true);
|
|
573 |
QVERIFY(outers.contains(EapQtPluginHandle::PluginEapTls) == true);
|
|
574 |
QVERIFY(outers.contains(EapQtPluginHandle::PluginEapGtc) == false);
|
|
575 |
}
|
|
576 |
|
|
577 |
void TestQtConfigUtils::testIsSupportedTypeNewInstance()
|
|
578 |
{
|
|
579 |
EapQtConfigInterface localEapConfigIf1(EapQtConfigInterface::EapBearerTypeWlan, global_wlanIap);
|
|
580 |
QVERIFY(localEapConfigIf1.isSupportedOuterType(EapQtPluginHandle::PluginEapAka) == true);
|
|
581 |
QVERIFY(localEapConfigIf1.isSupportedInnerType(EapQtPluginHandle::PluginEapTtls, EapQtPluginHandle::PluginEapAka) == true);
|
|
582 |
|
|
583 |
EapQtConfigInterface localEapConfigIf2(EapQtConfigInterface::EapBearerTypeWlan, global_wlanIap);
|
|
584 |
QVERIFY(localEapConfigIf2.isSupportedInnerType(EapQtPluginHandle::PluginPeap, EapQtPluginHandle::PluginEapMschapv2) == true);
|
|
585 |
QVERIFY(localEapConfigIf2.isSupportedOuterType(EapQtPluginHandle::PluginEapMschapv2) == false);
|
|
586 |
}
|
|
587 |
|
|
588 |
void TestQtConfigUtils::testSaveConfigurationFull()
|
|
589 |
{
|
|
590 |
int i = 0;
|
|
591 |
|
|
592 |
QString peap_user("testuser");
|
|
593 |
QString peap_pwd("testpwd");
|
|
594 |
QString peap_realm("testrealm.org");
|
|
595 |
QString peap_pacref("testpacgroupreference");
|
|
596 |
uint peap_validity_time(15);
|
|
597 |
|
|
598 |
QList<uint> peap_ciphers;
|
|
599 |
peap_ciphers.append(0x0004);
|
|
600 |
peap_ciphers.append(0x002F);
|
|
601 |
peap_ciphers.append(0x0033);
|
|
602 |
peap_ciphers.append(0x0034);
|
|
603 |
|
|
604 |
QString peap_subject("Test PEAP subject");
|
|
605 |
QString peap_issuer("Test PEAP subject");
|
|
606 |
QString peap_serialnum("Test PEAP subject");
|
|
607 |
QString peap_label("Test PEAP label");
|
|
608 |
QString peap_thumbprint("Test PEAP subject");
|
|
609 |
QByteArray peap_subjectkey =
|
|
610 |
mCaCertInfo[0].value(EapQtCertificateInfo::SubjectKeyId).toByteArray();
|
|
611 |
|
|
612 |
EapQtCertificateInfo peap_ca_cert;
|
|
613 |
peap_ca_cert.setValue(EapQtCertificateInfo::SubjectName, peap_subject);
|
|
614 |
peap_ca_cert.setValue(EapQtCertificateInfo::IssuerName, peap_issuer);
|
|
615 |
peap_ca_cert.setValue(EapQtCertificateInfo::SerialNumber, peap_serialnum);
|
|
616 |
peap_ca_cert.setValue(EapQtCertificateInfo::SubjectKeyId, peap_subjectkey);
|
|
617 |
peap_ca_cert.setValue(EapQtCertificateInfo::ThumbPrint, peap_thumbprint);
|
|
618 |
peap_ca_cert.setValue(EapQtCertificateInfo::CertificateLabel, peap_label);
|
|
619 |
|
|
620 |
QString peap_subject_user("Test PEAP user subject");
|
|
621 |
QString peap_issuer_user("Test PEAP user subject");
|
|
622 |
QString peap_serialnum_user("Test PEAP user subject");
|
|
623 |
QString peap_label_user("Test PEAP user label");
|
|
624 |
QString peap_thumbprint_user("Test PEAP user subject");
|
|
625 |
QByteArray peap_subjectkey_user =
|
|
626 |
mCaCertInfo[1].value(EapQtCertificateInfo::SubjectKeyId).toByteArray();
|
|
627 |
|
|
628 |
EapQtCertificateInfo peap_user_cert;
|
|
629 |
peap_user_cert.setValue(EapQtCertificateInfo::SubjectName, peap_subject_user);
|
|
630 |
peap_user_cert.setValue(EapQtCertificateInfo::IssuerName, peap_issuer_user);
|
|
631 |
peap_user_cert.setValue(EapQtCertificateInfo::SerialNumber, peap_serialnum_user);
|
|
632 |
peap_user_cert.setValue(EapQtCertificateInfo::SubjectKeyId, peap_subjectkey_user);
|
|
633 |
peap_user_cert.setValue(EapQtCertificateInfo::ThumbPrint, peap_thumbprint_user);
|
|
634 |
peap_user_cert.setValue(EapQtCertificateInfo::CertificateLabel, peap_label_user);
|
|
635 |
|
|
636 |
EapQtPluginHandle handle_peap(EapQtPluginHandle::PluginPeap);
|
|
637 |
EapQtPluginHandle handle_gtc(EapQtPluginHandle::PluginEapGtc);
|
|
638 |
EapQtPluginHandle handle_mschap(EapQtPluginHandle::PluginEapMschapv2);
|
|
639 |
EapQtPluginHandle handle_undef(EapQtPluginHandle::PluginUndefined);
|
|
640 |
|
|
641 |
// **** config outer type (PEAP)
|
|
642 |
EapQtConfig peap_config;
|
|
643 |
peap_config.setValue(EapQtConfig::UsernameAutomatic, true);
|
|
644 |
peap_config.setValue(EapQtConfig::Username, peap_user);
|
|
645 |
peap_config.setValue(EapQtConfig::PasswordPrompt, true);
|
|
646 |
peap_config.setValue(EapQtConfig::Password, peap_pwd);
|
|
647 |
peap_config.setValue(EapQtConfig::PasswordStored, false);
|
|
648 |
peap_config.setValue(EapQtConfig::RealmAutomatic, true);
|
|
649 |
peap_config.setValue(EapQtConfig::Realm, peap_realm);
|
|
650 |
peap_config.setValue(EapQtConfig::UsePseudonyms, true);
|
|
651 |
peap_config.setValue(EapQtConfig::VerifyServerRealm, true);
|
|
652 |
peap_config.setValue(EapQtConfig::SessionValidityTime, peap_validity_time);
|
|
653 |
peap_config.setValue(EapQtConfig::PeapVersion0Allowed, true);
|
|
654 |
peap_config.setValue(EapQtConfig::PeapVersion1Allowed, true);
|
|
655 |
peap_config.setValue(EapQtConfig::PeapVersion2Allowed, true);
|
|
656 |
peap_config.setValue(EapQtConfig::ProvisioningModeAuthenticated, true);
|
|
657 |
peap_config.setValue(EapQtConfig::ProvisioningModeUnauthenticated, true);
|
|
658 |
peap_config.setValue(EapQtConfig::PACGroupReference, peap_pacref);
|
|
659 |
peap_config.setValue(EapQtConfig::WarnADHPNoPAC, true);
|
|
660 |
peap_config.setValue(EapQtConfig::WarnADHPNoMatchingPAC, true);
|
|
661 |
peap_config.setValue(EapQtConfig::WarnNotDefaultServer, true);
|
|
662 |
peap_config.setValue(EapQtConfig::UseIdentityPrivacy, true);
|
|
663 |
peap_config.setValue(EapQtConfig::AuthorityCertificateAutomatic, true);
|
|
664 |
peap_config.setValue(EapQtConfig::ClientAuthenticationRequired, true);
|
|
665 |
|
|
666 |
QList<QVariant> varList;
|
|
667 |
for (i = 0; i < peap_ciphers.count(); i++) {
|
|
668 |
varList.append(peap_ciphers[i]);
|
|
669 |
}
|
|
670 |
peap_config.setValue(EapQtConfig::CipherSuites, varList);
|
|
671 |
varList.clear();
|
|
672 |
|
|
673 |
varList.append(qVariantFromValue(peap_ca_cert));
|
|
674 |
peap_config.setValue(EapQtConfig::AuthorityCertificate, varList);
|
|
675 |
varList.clear();
|
|
676 |
|
|
677 |
varList.append(qVariantFromValue(peap_user_cert));
|
|
678 |
peap_config.setValue(EapQtConfig::UserCertificate, varList);
|
|
679 |
varList.clear();
|
|
680 |
|
|
681 |
// activate inner types (EAP-GTC & EAP-MSCHAPv2)
|
|
682 |
varList.append(qVariantFromValue(handle_gtc));
|
|
683 |
varList.append(qVariantFromValue(handle_mschap));
|
|
684 |
peap_config.setValue(EapQtConfig::InnerType, varList);
|
|
685 |
|
|
686 |
// OuterType is unset, i.e. QVariant::Invalid
|
|
687 |
|
|
688 |
bool ok(false);
|
|
689 |
ok = mEapConfigIf->saveConfiguration(handle_peap, peap_config);
|
|
690 |
QVERIFY(ok);
|
|
691 |
|
|
692 |
// *** config gtc
|
|
693 |
QString gtc_user("testgtcuser");
|
|
694 |
QString gtc_pwd("testgtcpwd");
|
|
695 |
|
|
696 |
EapQtConfig gtc_config;
|
|
697 |
|
|
698 |
gtc_config.setValue(EapQtConfig::Username, gtc_user);
|
|
699 |
gtc_config.setValue(EapQtConfig::PasswordPrompt, true);
|
|
700 |
gtc_config.setValue(EapQtConfig::Password, gtc_pwd);
|
|
701 |
gtc_config.setValue(EapQtConfig::PasswordStored, false);
|
|
702 |
gtc_config.setValue(EapQtConfig::OuterType, qVariantFromValue(handle_peap));
|
|
703 |
|
|
704 |
// InnerType is unset, i.e. QVariant::Invalid
|
|
705 |
|
|
706 |
ok = mEapConfigIf->saveConfiguration(handle_gtc, gtc_config);
|
|
707 |
QVERIFY(ok);
|
|
708 |
|
|
709 |
// *** config mschapv2
|
|
710 |
QString mschap_user("testmschapuser");
|
|
711 |
QString mschap_pwd("testmschappwd");
|
|
712 |
|
|
713 |
EapQtConfig mschap_config;
|
|
714 |
mschap_config.setValue(EapQtConfig::Username, mschap_user);
|
|
715 |
mschap_config.setValue(EapQtConfig::PasswordPrompt, false);
|
|
716 |
mschap_config.setValue(EapQtConfig::Password, mschap_pwd);
|
|
717 |
mschap_config.setValue(EapQtConfig::PasswordStored, false);
|
|
718 |
mschap_config.setValue(EapQtConfig::OuterType, qVariantFromValue(handle_peap));
|
|
719 |
|
|
720 |
// InnerType is unset, i.e. QVariant::Invalid
|
|
721 |
|
|
722 |
ok = mEapConfigIf->saveConfiguration(handle_mschap, mschap_config);
|
|
723 |
QVERIFY(ok);
|
|
724 |
|
|
725 |
// *****************************************
|
|
726 |
// read back the values to check correctness
|
|
727 |
// *****************************************
|
|
728 |
|
|
729 |
// *** gtc
|
|
730 |
EapQtPluginHandle read_handle;
|
|
731 |
EapQtConfig read_config;
|
|
732 |
ok = mEapConfigIf->readConfiguration(handle_peap, handle_gtc, read_config);
|
|
733 |
QVERIFY(ok);
|
|
734 |
|
|
735 |
QVERIFY(false == read_config.value(EapQtConfig::UsernameAutomatic).toBool());
|
|
736 |
QVERIFY(gtc_config.value(EapQtConfig::Username) == read_config.value(EapQtConfig::Username));
|
|
737 |
QVERIFY(gtc_config.value(EapQtConfig::PasswordPrompt) == read_config.value(EapQtConfig::PasswordPrompt));
|
|
738 |
QVERIFY(true == read_config.value(EapQtConfig::PasswordStored).toBool());
|
|
739 |
|
|
740 |
QVariant tmp = read_config.value(EapQtConfig::OuterType);
|
|
741 |
read_handle = tmp.value<EapQtPluginHandle> ();
|
|
742 |
QVERIFY(handle_peap == read_handle);
|
|
743 |
|
|
744 |
// *** mschap
|
|
745 |
read_config.clear();
|
|
746 |
|
|
747 |
ok = mEapConfigIf->readConfiguration(handle_peap, handle_mschap, read_config);
|
|
748 |
QVERIFY(ok);
|
|
749 |
|
|
750 |
QVERIFY(false == read_config.value(EapQtConfig::UsernameAutomatic).toBool());
|
|
751 |
QVERIFY(mschap_config.value(EapQtConfig::Username) == read_config.value(EapQtConfig::Username));
|
|
752 |
QVERIFY(mschap_config.value(EapQtConfig::PasswordPrompt) == read_config.value(EapQtConfig::PasswordPrompt));
|
|
753 |
QVERIFY(true == read_config.value(EapQtConfig::PasswordStored).toBool());
|
|
754 |
|
|
755 |
tmp = read_config.value(EapQtConfig::OuterType);
|
|
756 |
read_handle = tmp.value<EapQtPluginHandle> ();
|
|
757 |
QVERIFY(handle_peap == read_handle);
|
|
758 |
|
|
759 |
// *** PEAP
|
|
760 |
read_config.clear();
|
|
761 |
|
|
762 |
ok = mEapConfigIf->readConfiguration(handle_undef, handle_peap, read_config);
|
|
763 |
QVERIFY(ok);
|
|
764 |
|
|
765 |
// check only the valid PEAP parameters
|
|
766 |
QVERIFY(peap_config.value(EapQtConfig::UsernameAutomatic) == read_config.value(EapQtConfig::UsernameAutomatic));
|
|
767 |
QVERIFY(peap_config.value(EapQtConfig::Username) == read_config.value(EapQtConfig::Username));
|
|
768 |
QVERIFY(peap_config.value(EapQtConfig::RealmAutomatic) == read_config.value(EapQtConfig::RealmAutomatic));
|
|
769 |
QVERIFY(peap_config.value(EapQtConfig::Realm) == read_config.value(EapQtConfig::Realm));
|
|
770 |
QVERIFY(peap_config.value(EapQtConfig::VerifyServerRealm) == read_config.value(EapQtConfig::VerifyServerRealm));
|
|
771 |
QVERIFY(peap_config.value(EapQtConfig::SessionValidityTime) == read_config.value(EapQtConfig::SessionValidityTime));
|
|
772 |
QVERIFY(peap_config.value(EapQtConfig::PeapVersion0Allowed) == read_config.value(EapQtConfig::PeapVersion0Allowed));
|
|
773 |
QVERIFY(peap_config.value(EapQtConfig::PeapVersion1Allowed) == read_config.value(EapQtConfig::PeapVersion1Allowed));
|
|
774 |
QVERIFY(peap_config.value(EapQtConfig::PeapVersion2Allowed) == read_config.value(EapQtConfig::PeapVersion2Allowed));
|
|
775 |
QVERIFY(peap_config.value(EapQtConfig::UseIdentityPrivacy) == read_config.value(EapQtConfig::UseIdentityPrivacy));
|
|
776 |
QVERIFY(peap_config.value(EapQtConfig::AuthorityCertificateAutomatic) == read_config.value(EapQtConfig::AuthorityCertificateAutomatic));
|
|
777 |
QVERIFY(peap_config.value(EapQtConfig::ClientAuthenticationRequired) == read_config.value(EapQtConfig::ClientAuthenticationRequired));
|
|
778 |
QVERIFY(peap_config.value(EapQtConfig::OuterType) == QVariant::Invalid);
|
|
779 |
|
|
780 |
// ciphers
|
|
781 |
QList<QVariant> varListWrite = peap_config.value(EapQtConfig::CipherSuites).toList();
|
|
782 |
QList<QVariant> varListRead = read_config.value(EapQtConfig::CipherSuites).toList();
|
|
783 |
|
|
784 |
QVERIFY(varListRead.count() == varListWrite.count());
|
|
785 |
|
|
786 |
for (i = 0; i < peap_ciphers.count(); i++) {
|
|
787 |
QVERIFY(varListRead.contains(varListWrite[i]) == true);
|
|
788 |
}
|
|
789 |
|
|
790 |
// ca cert
|
|
791 |
varListWrite = peap_config.value(EapQtConfig::AuthorityCertificate).toList();
|
|
792 |
varListRead = read_config.value(EapQtConfig::AuthorityCertificate).toList();
|
|
793 |
|
|
794 |
QVERIFY(varListRead.count() == varListWrite.count() == 1);
|
|
795 |
|
|
796 |
QVERIFY(peap_ca_cert.value(EapQtCertificateInfo::SubjectName) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::SubjectName));
|
|
797 |
QVERIFY(peap_ca_cert.value(EapQtCertificateInfo::SerialNumber) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::SerialNumber));
|
|
798 |
QVERIFY(peap_ca_cert.value(EapQtCertificateInfo::SubjectKeyId) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::SubjectKeyId));
|
|
799 |
QVERIFY(peap_ca_cert.value(EapQtCertificateInfo::ThumbPrint) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::ThumbPrint));
|
|
800 |
// label is not stored, hence invalid in read
|
|
801 |
QVERIFY(QVariant::Invalid == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::CertificateLabel));
|
|
802 |
|
|
803 |
// user cert
|
|
804 |
varListWrite = peap_config.value(EapQtConfig::UserCertificate).toList();
|
|
805 |
varListRead = read_config.value(EapQtConfig::UserCertificate).toList();
|
|
806 |
|
|
807 |
QVERIFY(varListRead.count() == varListWrite.count() == 1);
|
|
808 |
|
|
809 |
QVERIFY(peap_user_cert.value(EapQtCertificateInfo::SubjectName) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::SubjectName));
|
|
810 |
QVERIFY(peap_user_cert.value(EapQtCertificateInfo::SerialNumber) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::SerialNumber));
|
|
811 |
QVERIFY(peap_user_cert.value(EapQtCertificateInfo::SubjectKeyId) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::SubjectKeyId));
|
|
812 |
QVERIFY(peap_user_cert.value(EapQtCertificateInfo::ThumbPrint) == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::ThumbPrint));
|
|
813 |
// label is not stored, hence invalid in read
|
|
814 |
QVERIFY(QVariant::Invalid == (varListRead[0].value<EapQtCertificateInfo>()).value(EapQtCertificateInfo::CertificateLabel));
|
|
815 |
|
|
816 |
// inner types
|
|
817 |
varListWrite = peap_config.value(EapQtConfig::InnerType).toList();
|
|
818 |
varListRead = read_config.value(EapQtConfig::InnerType).toList();
|
|
819 |
QVERIFY(varListRead.count() == varListWrite.count() == 2);
|
|
820 |
|
|
821 |
QList<EapQtPluginHandle> read_handle_list;
|
|
822 |
read_handle_list.append(varListRead[0].value<EapQtPluginHandle> ());
|
|
823 |
read_handle_list.append(varListRead[1].value<EapQtPluginHandle> ());
|
|
824 |
|
|
825 |
QVERIFY(read_handle_list.contains(handle_mschap) && read_handle_list.contains(handle_gtc));
|
|
826 |
}
|
|
827 |
|
|
828 |
void TestQtConfigUtils::testSaveConfigurationEapTtls()
|
|
829 |
{
|
|
830 |
// EAP-TTLS/MSCHAPv2
|
|
831 |
}
|
|
832 |
#endif
|
|
833 |
|
|
834 |
void TestQtConfigUtils::testUiInstance()
|
|
835 |
{
|
|
836 |
#ifdef INCLUDE_UI_CASES
|
|
837 |
|
|
838 |
QVERIFY(mEapConfigIf->setConfigurationReference(global_wlanIap) == true);
|
|
839 |
|
|
840 |
// make sure there is a stored state in mEapConfigIf (EAP IF plugins loaded)
|
|
841 |
mEapConfigIf->isSupportedInnerType(EapQtPluginHandle::PluginPeap,
|
|
842 |
EapQtPluginHandle::PluginPeap) == false;
|
|
843 |
mEapConfigIf->isSupportedInnerType(EapQtPluginHandle::PluginPeap,
|
|
844 |
EapQtPluginHandle::PluginEapGtc) == true;
|
|
845 |
|
|
846 |
QScopedPointer<CpBaseSettingView> ui(NULL);
|
|
847 |
|
|
848 |
qDebug("creating AKA UI");
|
|
849 |
ui.reset(mEapConfigIf->uiInstance(EapQtPluginHandle::PluginUndefined, EapQtPluginHandle::PluginEapAka));
|
|
850 |
qDebug("AKA UI created");
|
|
851 |
QVERIFY(!ui.isNull());
|
|
852 |
|
|
853 |
qDebug("creating SIM UI");
|
|
854 |
ui.reset(mEapConfigIf->uiInstance(EapQtPluginHandle::PluginUndefined, EapQtPluginHandle::PluginEapSim));
|
|
855 |
qDebug("SIM UI created");
|
|
856 |
QVERIFY(!ui.isNull());
|
|
857 |
|
|
858 |
qDebug("creating LEAP UI");
|
|
859 |
ui.reset(mEapConfigIf->uiInstance(EapQtPluginHandle::PluginUndefined, EapQtPluginHandle::PluginLeap));
|
|
860 |
qDebug("LEAP UI created");
|
|
861 |
QVERIFY(!ui.isNull());
|
|
862 |
|
|
863 |
qDebug("creating 1");
|
|
864 |
ui.reset(mEapConfigIf->uiInstance(EapQtPluginHandle::PluginUndefined, EapQtPluginHandle::PluginUndefined));
|
|
865 |
qDebug("created 1");
|
|
866 |
QVERIFY(ui.isNull());
|
|
867 |
|
|
868 |
qDebug("creating 2");
|
|
869 |
ui.reset(mEapConfigIf->uiInstance(EapQtPluginHandle::PluginEapAka, EapQtPluginHandle::PluginEapSim));
|
|
870 |
qDebug("created 2");
|
|
871 |
QVERIFY(ui.isNull());
|
|
872 |
|
|
873 |
qDebug("creating 3");
|
|
874 |
ui.reset(mEapConfigIf->uiInstance(EapQtPluginHandle::PluginEapSim, EapQtPluginHandle::PluginEapAka));
|
|
875 |
qDebug("created 3");
|
|
876 |
QVERIFY(ui.isNull());
|
|
877 |
|
|
878 |
qDebug("creating 4");
|
|
879 |
ui.reset(mEapConfigIf->uiInstance(EapQtPluginHandle::PluginEapAka, EapQtPluginHandle::PluginEapAka));
|
|
880 |
qDebug("created 4");
|
|
881 |
QVERIFY(ui.isNull());
|
|
882 |
|
|
883 |
#else
|
|
884 |
QWARN("UI cases not included");
|
|
885 |
#endif
|
|
886 |
}
|
|
887 |
|
|
888 |
// Create main function using QTest marco.
|
|
889 |
QTEST_MAIN( TestQtConfigUtils)
|