mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Deep copy subkeys when cloning CompositeKey.
This commit is contained in:
@@ -103,6 +103,8 @@ add_unit_test(NAME testgroup SOURCES TestGroup.cpp MOCS TestGroup.h LIBS ${TEST_
|
||||
|
||||
add_unit_test(NAME testkeepass2xmlreader SOURCES TestKeePass2XmlReader.cpp MOCS TestKeePass2XmlReader.h LIBS ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testkeys SOURCES TestKeys.cpp MOCS TestKeys.h LIBS ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testkeepass2reader SOURCES TestKeePass2Reader.cpp MOCS TestKeePass2Reader.h LIBS ${TEST_LIBRARIES})
|
||||
|
||||
add_unit_test(NAME testkeepass2writer SOURCES TestKeePass2Writer.cpp MOCS TestKeePass2Writer.h LIBS ${TEST_LIBRARIES})
|
||||
|
||||
53
tests/TestKeys.cpp
Normal file
53
tests/TestKeys.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "TestKeys.h"
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include "crypto/Crypto.h"
|
||||
#include "keys/CompositeKey.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
|
||||
void TestKeys::initTestCase()
|
||||
{
|
||||
Crypto::init();
|
||||
}
|
||||
|
||||
void TestKeys::testComposite()
|
||||
{
|
||||
CompositeKey* compositeKey1 = new CompositeKey();
|
||||
PasswordKey* passwordKey1 = new PasswordKey();
|
||||
PasswordKey* passwordKey2 = new PasswordKey("test");
|
||||
|
||||
compositeKey1->addKey(*passwordKey1);
|
||||
compositeKey1->addKey(*passwordKey2);
|
||||
delete passwordKey1;
|
||||
delete passwordKey2;
|
||||
|
||||
QVERIFY(compositeKey1->transform(QByteArray(32, '\0'), 1).size() == 32);
|
||||
|
||||
// make sure the subkeys are copied
|
||||
CompositeKey* compositeKey2 = compositeKey1->clone();
|
||||
delete compositeKey1;
|
||||
|
||||
QVERIFY(compositeKey2->transform(QByteArray(32, '\0'), 1).size() == 32);
|
||||
|
||||
delete compositeKey2;
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestKeys);
|
||||
32
tests/TestKeys.h
Normal file
32
tests/TestKeys.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_TESTKEYS_H
|
||||
#define KEEPASSX_TESTKEYS_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
class TestKeys : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testComposite();
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_TESTKEYS_H
|
||||
Reference in New Issue
Block a user