Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TestSelfSignedCertificate.cpp « TestSelfSignedCertificate « tests « src - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 814474366d419fc65151c1c98cad7b7c3ff4e670 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2005-2017 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include <QtCore>
#include <QtTest>

#include "SelfSignedCertificate.h"

class TestSelfSignedCertificate : public QObject {
		Q_OBJECT
	private slots:
		void exerciseClientCert();
		void exerciseServerCert();
};

void TestSelfSignedCertificate::exerciseClientCert() {
	QSslCertificate cert;
	QSslKey key;
	
	bool ok = SelfSignedCertificate::generateMumbleCertificate(QLatin1String("Test"), QLatin1String("test@test.test"), cert, key);
	QCOMPARE(ok, true);
	QCOMPARE(cert.isNull(), false);
	QCOMPARE(cert.isNull(), false);

	ok = SelfSignedCertificate::generateMumbleCertificate(QString(), QString(), cert, key);
	QCOMPARE(ok, false);
	QCOMPARE(cert.isNull(), true);
	QCOMPARE(cert.isNull(), true);
}

void TestSelfSignedCertificate::exerciseServerCert() {
	QSslCertificate cert;
	QSslKey key;
	
	bool ok = SelfSignedCertificate::generateMurmurV2Certificate(cert, key);
	QCOMPARE(ok, true);
	QCOMPARE(cert.isNull(), false);
	QCOMPARE(cert.isNull(), false);
}

QTEST_MAIN(TestSelfSignedCertificate)
#include "TestSelfSignedCertificate.moc"