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

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2017-07-16 11:48:47 +0300
committerMikkel Krautz <mikkel@krautz.dk>2017-07-17 11:19:21 +0300
commit6892c8b29abe5e36bcc7a96a34dbeb5bbde4da0e (patch)
treed561aebaca695bc1df726338a61ba8673ff0cb8c /src/tests
parent72e0a78272d37e473f0b34d244e19bb7821393c2 (diff)
src/tests: update tests to initialize and destroy the MumbleSSL module to ensure OpenSSL is properly initialized.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/TestCrypt/TestCrypt.cpp11
-rw-r--r--src/tests/TestCrypt/TestCrypt.pro4
-rw-r--r--src/tests/TestCryptographicHash/TestCryptographicHash.cpp13
-rw-r--r--src/tests/TestCryptographicHash/TestCryptographicHash.pro6
-rw-r--r--src/tests/TestCryptographicRandom/TestCryptographicRandom.cpp12
-rw-r--r--src/tests/TestCryptographicRandom/TestCryptographicRandom.pro6
-rw-r--r--src/tests/TestPasswordGenerator/TestPasswordGenerator.cpp12
-rw-r--r--src/tests/TestPasswordGenerator/TestPasswordGenerator.pro6
-rw-r--r--src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.cpp12
-rw-r--r--src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro4
10 files changed, 76 insertions, 10 deletions
diff --git a/src/tests/TestCrypt/TestCrypt.cpp b/src/tests/TestCrypt/TestCrypt.cpp
index 9d5436193..cfd56997c 100644
--- a/src/tests/TestCrypt/TestCrypt.cpp
+++ b/src/tests/TestCrypt/TestCrypt.cpp
@@ -9,12 +9,15 @@
#include <QtCore>
#include <QtTest>
+#include "SSL.h"
#include "Timer.h"
#include "CryptState.h"
class TestCrypt : public QObject {
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void testvectors();
void authcrypt();
void ivrecovery();
@@ -22,6 +25,14 @@ class TestCrypt : public QObject {
void tamper();
};
+void TestCrypt::initTestCase() {
+ MumbleSSL::initialize();
+}
+
+void TestCrypt::cleanupTestCase() {
+ MumbleSSL::destroy();
+}
+
void TestCrypt::reverserecovery() {
CryptState enc, dec;
enc.genKey();
diff --git a/src/tests/TestCrypt/TestCrypt.pro b/src/tests/TestCrypt/TestCrypt.pro
index 9f2ec26a3..5eea60253 100644
--- a/src/tests/TestCrypt/TestCrypt.pro
+++ b/src/tests/TestCrypt/TestCrypt.pro
@@ -8,5 +8,5 @@ include(../test.pri)
QT *= network
TARGET = TestCrypt
-HEADERS = Timer.h CryptState.h
-SOURCES = TestCrypt.cpp CryptState.cpp Timer.cpp
+HEADERS = SSL.h SSLLocks.h Timer.h CryptState.h
+SOURCES = SSL.cpp SSLLocks.cpp TestCrypt.cpp CryptState.cpp Timer.cpp
diff --git a/src/tests/TestCryptographicHash/TestCryptographicHash.cpp b/src/tests/TestCryptographicHash/TestCryptographicHash.cpp
index bf5657ecf..d0866393e 100644
--- a/src/tests/TestCryptographicHash/TestCryptographicHash.cpp
+++ b/src/tests/TestCryptographicHash/TestCryptographicHash.cpp
@@ -7,11 +7,16 @@
#include <QtTest>
#include <QLatin1String>
+#include "SSL.h"
+
#include "CryptographicHash.h"
class TestCryptographicHash : public QObject {
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
void sha1_data();
void sha1();
@@ -23,6 +28,14 @@ class TestCryptographicHash : public QObject {
void addDataAfterResult();
};
+void TestCryptographicHash::initTestCase() {
+ MumbleSSL::initialize();
+}
+
+void TestCryptographicHash::cleanupTestCase() {
+ MumbleSSL::destroy();
+}
+
/// normalizeHash removes all whitespace from the hex-encoded hash string.
static QString normalizeHash(QString str) {
str.replace(QLatin1String(" "), QLatin1String(""));
diff --git a/src/tests/TestCryptographicHash/TestCryptographicHash.pro b/src/tests/TestCryptographicHash/TestCryptographicHash.pro
index 5de0821f6..73dd5466a 100644
--- a/src/tests/TestCryptographicHash/TestCryptographicHash.pro
+++ b/src/tests/TestCryptographicHash/TestCryptographicHash.pro
@@ -5,6 +5,8 @@
include(../test.pri)
+QT += network
+
TARGET = TestCryptographicHash
-SOURCES = TestCryptographicHash.cpp CryptographicHash.cpp
-HEADERS = CryptographicHash.h
+SOURCES = SSL.cpp SSLLocks.cpp TestCryptographicHash.cpp CryptographicHash.cpp
+HEADERS = SSL.h SSLLocks.h CryptographicHash.h
diff --git a/src/tests/TestCryptographicRandom/TestCryptographicRandom.cpp b/src/tests/TestCryptographicRandom/TestCryptographicRandom.cpp
index 29e3e2715..0ae41e60c 100644
--- a/src/tests/TestCryptographicRandom/TestCryptographicRandom.cpp
+++ b/src/tests/TestCryptographicRandom/TestCryptographicRandom.cpp
@@ -6,6 +6,8 @@
#include <QtCore>
#include <QtTest>
+#include "SSL.h"
+
#include "CryptographicRandom.h"
#include <stdint.h>
@@ -15,11 +17,21 @@
class TestCryptographicRandom : public QObject {
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void fillBuffer();
void uint32();
void uniform();
};
+void TestCryptographicRandom::initTestCase() {
+ MumbleSSL::initialize();
+}
+
+void TestCryptographicRandom::cleanupTestCase() {
+ MumbleSSL::destroy();
+}
+
// Verify the entropy of the data returned by the random source
// by zlib compressing it and ensuring the compressed size is at
// least 99% of the size of the input data.
diff --git a/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro b/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro
index 1e79baaf5..435ecbf5f 100644
--- a/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro
+++ b/src/tests/TestCryptographicRandom/TestCryptographicRandom.pro
@@ -5,9 +5,11 @@
include(../test.pri)
+QT += network
+
TARGET = TestCryptographicRandom
-SOURCES = TestCryptographicRandom.cpp CryptographicRandom.cpp arc4random_uniform.cpp
-HEADERS = CryptographicHash.h
+SOURCES = SSL.cpp SSLLocks.cpp TestCryptographicRandom.cpp CryptographicRandom.cpp arc4random_uniform.cpp
+HEADERS = SSL.h SSLLocks.h CryptographicHash.h
VPATH *= ../../../3rdparty/arc4random-src
INCLUDEPATH *= ../../../3rdparty/arc4random-src
diff --git a/src/tests/TestPasswordGenerator/TestPasswordGenerator.cpp b/src/tests/TestPasswordGenerator/TestPasswordGenerator.cpp
index 8e675d3ca..94c2b4dd8 100644
--- a/src/tests/TestPasswordGenerator/TestPasswordGenerator.cpp
+++ b/src/tests/TestPasswordGenerator/TestPasswordGenerator.cpp
@@ -6,6 +6,8 @@
#include <QtCore>
#include <QtTest>
+#include "SSL.h"
+
#include "PasswordGenerator.h"
// Get the password alphabet from PasswordGenerator.
@@ -14,9 +16,19 @@ extern QVector<QChar> mumble_password_generator_alphabet();
class TestPasswordGenerator : public QObject {
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void random();
};
+void TestPasswordGenerator::initTestCase() {
+ MumbleSSL::initialize();
+}
+
+void TestPasswordGenerator::cleanupTestCase() {
+ MumbleSSL::destroy();
+}
+
void TestPasswordGenerator::random() {
QVector<QChar> alphabet = mumble_password_generator_alphabet();
for (int i = 0; i < 100; i++) {
diff --git a/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro b/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro
index 650b5b0f5..c93fcf03f 100644
--- a/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro
+++ b/src/tests/TestPasswordGenerator/TestPasswordGenerator.pro
@@ -5,9 +5,11 @@
include(../test.pri)
+QT += network
+
TARGET = TestPasswordGenerator
-SOURCES = TestPasswordGenerator.cpp PasswordGenerator.cpp CryptographicRandom.cpp arc4random_uniform.cpp
-HEADERS = PasswordGenerator.h CryptographicHash.h
+SOURCES = SSL.cpp SSLLocks.cpp TestPasswordGenerator.cpp PasswordGenerator.cpp CryptographicRandom.cpp arc4random_uniform.cpp
+HEADERS = SSL.h SSLLocks.h PasswordGenerator.h CryptographicHash.h
VPATH *= ../../../3rdparty/arc4random-src
INCLUDEPATH *= ../../../3rdparty/arc4random-src
diff --git a/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.cpp b/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.cpp
index 814474366..24996d72a 100644
--- a/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.cpp
+++ b/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.cpp
@@ -6,15 +6,27 @@
#include <QtCore>
#include <QtTest>
+#include "SSL.h"
+
#include "SelfSignedCertificate.h"
class TestSelfSignedCertificate : public QObject {
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanupTestCase();
void exerciseClientCert();
void exerciseServerCert();
};
+void TestSelfSignedCertificate::initTestCase() {
+ MumbleSSL::initialize();
+}
+
+void TestSelfSignedCertificate::cleanupTestCase() {
+ MumbleSSL::destroy();
+}
+
void TestSelfSignedCertificate::exerciseClientCert() {
QSslCertificate cert;
QSslKey key;
diff --git a/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro b/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro
index 476765249..0ff3cd76a 100644
--- a/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro
+++ b/src/tests/TestSelfSignedCertificate/TestSelfSignedCertificate.pro
@@ -9,5 +9,5 @@ include(../../../qmake/qt.pri)
QT *= network
TARGET = TestSelfSignedCertificate
-SOURCES = TestSelfSignedCertificate.cpp SelfSignedCertificate.cpp
-HEADERS = SelfSignedCertificate.h
+SOURCES = SSL.cpp SSLLocks.cpp TestSelfSignedCertificate.cpp SelfSignedCertificate.cpp
+HEADERS = SSL.h SSLLocks.h SelfSignedCertificate.h