refactor: port net/SecureUtilsTest to QtTests
This commit is contained in:
parent
ae37543a37
commit
e512125595
3 changed files with 33 additions and 6 deletions
|
|
@ -5,6 +5,14 @@ if(WIN32)
|
|||
set(extra_libs version)
|
||||
endif()
|
||||
|
||||
create_test(
|
||||
NAME SecureUtilsTests
|
||||
DEPENDS net
|
||||
LIBS base arch mt io ${extra_libs}
|
||||
SOURCE SecureUtilsTests.cpp
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/src/lib/net"
|
||||
)
|
||||
|
||||
create_test(
|
||||
NAME FingerprintDatabaseTests
|
||||
DEPENDS net
|
||||
|
|
|
|||
|
|
@ -5,26 +5,28 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#include "net/SecureUtils.h"
|
||||
#include "SecureUtilsTests.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "../../lib/net/SecureUtils.h"
|
||||
|
||||
TEST(SecureUtilsTest, formatSSLFingerprints_fromHex_withSeperators)
|
||||
using namespace deskflow;
|
||||
|
||||
void SecureUtilsTests::checkHex()
|
||||
{
|
||||
std::vector<uint8_t> fingerprint = {40, 253, 10, 152, 138, 14, 161, 108, 215, 232, 108, 167, 238, 88, 65, 113,
|
||||
202, 178, 142, 73, 37, 148, 144, 37, 38, 5, 141, 175, 99, 237, 46, 48};
|
||||
|
||||
ASSERT_EQ(
|
||||
QCOMPARE(
|
||||
deskflow::formatSSLFingerprint(fingerprint, true),
|
||||
"28:FD:0A:98:8A:0E:A1:6C:D7:E8:6C:A7:EE:58:41:71:CA:B2:8E:49:25:94:90:25:26:05:8D:AF:63:ED:2E:30"
|
||||
);
|
||||
}
|
||||
|
||||
TEST(SecureUtilsTest, createFingerprintArt)
|
||||
void SecureUtilsTests::checkArt()
|
||||
{
|
||||
std::vector<uint8_t> fingerprint = {40, 253, 10, 152, 138, 14, 161, 108, 215, 232, 108, 167, 238, 88, 65, 113,
|
||||
202, 178, 142, 73, 37, 148, 144, 37, 38, 5, 141, 175, 99, 237, 46, 48};
|
||||
ASSERT_EQ(
|
||||
QCOMPARE(
|
||||
deskflow::generateFingerprintArt(fingerprint), "╔═════════════════╗\n"
|
||||
"║*X+. . ║\n"
|
||||
"║*oo + ║\n"
|
||||
|
|
@ -38,3 +40,5 @@ TEST(SecureUtilsTest, createFingerprintArt)
|
|||
"╚═════════════════╝"
|
||||
);
|
||||
}
|
||||
|
||||
QTEST_MAIN(SecureUtilsTests)
|
||||
15
src/unittests/net/SecureUtilsTests.h
Normal file
15
src/unittests/net/SecureUtilsTests.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
|
||||
class SecureUtilsTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void checkHex();
|
||||
void checkArt();
|
||||
};
|
||||
Loading…
Reference in a new issue