Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
Martchus | ea0503ce62 | |
Martchus | 8efa6461fe | |
Martchus | e3e7f731bf | |
Martchus | acdc1d80ba | |
Martchus | 3cb0812c62 | |
Martchus | 17f6d4cfe5 | |
Martchus | fd5c19dd9f | |
Martchus | 2e1d9a700b | |
Martchus | 9f134725c7 | |
Martchus | 3da25a39a4 | |
Martchus | 7d8d837cb1 |
|
@ -10,7 +10,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
|||
set(META_APP_DESCRIPTION "C++ library to read/write passwords from/to encrypted files")
|
||||
set(META_VERSION_MAJOR 5)
|
||||
set(META_VERSION_MINOR 0)
|
||||
set(META_VERSION_PATCH 9)
|
||||
set(META_VERSION_PATCH 12)
|
||||
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
||||
|
||||
# add project files
|
||||
|
@ -46,7 +46,7 @@ endif ()
|
|||
set(CONFIGURATION_PACKAGE_SUFFIX
|
||||
""
|
||||
CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities")
|
||||
find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
|
||||
find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.14.0 REQUIRED)
|
||||
use_cpp_utilities(VISIBILITY PUBLIC)
|
||||
|
||||
# find 3rd party libraries
|
||||
|
|
|
@ -9,6 +9,6 @@ The passwordfile library depends on c++utilities and is built in the same way.
|
|||
It also depends on OpenSSL and zlib.
|
||||
|
||||
## Copyright notice and license
|
||||
Copyright © 2015-2023 Marius Kittler
|
||||
Copyright © 2015-2024 Marius Kittler
|
||||
|
||||
All code is licensed under [GPL-2-or-later](LICENSE).
|
||||
|
|
1
global.h
1
global.h
|
@ -4,6 +4,7 @@
|
|||
#ifndef PASSWORD_FILE_GLOBAL
|
||||
#define PASSWORD_FILE_GLOBAL
|
||||
|
||||
#include "passwordfile-definitions.h"
|
||||
#include <c++utilities/application/global.h>
|
||||
|
||||
#ifdef PASSWORD_FILE_STATIC
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <c++utilities/conversion/stringbuilder.h>
|
||||
#include <c++utilities/conversion/stringconversion.h>
|
||||
#include <c++utilities/io/path.h>
|
||||
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/err.h>
|
||||
|
@ -390,9 +391,10 @@ std::uint32_t PasswordFile::mininumVersion(PasswordFileSaveFlags options) const
|
|||
/*!
|
||||
* \brief Writes the current root entry to the file under path() replacing its previous contents.
|
||||
* \param options Specify the features (like encryption and compression) to be used.
|
||||
* \throws Throws ios_base::failure when an IO error occurs.
|
||||
* \throws Throws runtime_error when no root entry is present or a compression error occurs.
|
||||
* \throws Throws std::ios_base::failure when an IO error occurs.
|
||||
* \throws Throws std::filesystem::filesystem_error when a filesystem error occurs.
|
||||
* \throws Throws Io::CryptoException when an encryption error occurs.
|
||||
* \throws Throws std::runtime_error when no root entry is present or a compression error occurs.
|
||||
*/
|
||||
void PasswordFile::save(PasswordFileSaveFlags options)
|
||||
{
|
||||
|
@ -429,16 +431,16 @@ void PasswordFile::save(PasswordFileSaveFlags options)
|
|||
const auto newSize = static_cast<std::size_t>(m_file.tellp());
|
||||
if (fileSize && newSize < fileSize) {
|
||||
m_file.close();
|
||||
std::filesystem::resize_file(m_path, newSize);
|
||||
std::filesystem::resize_file(makeNativePath(m_path), newSize);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Writes the current root entry to the file which is assumed to be opened and writeable.
|
||||
* \param options Specify the features (like encryption and compression) to be used.
|
||||
* \throws Throws ios_base::failure when an IO error occurs.
|
||||
* \throws Throws runtime_error when no root entry is present or a compression error occurs.
|
||||
* \throws Throws std::ios_base::failure when an IO error occurs.
|
||||
* \throws Throws Io::CryptoException when an encryption error occurs.
|
||||
* \throws Throws std::runtime_error when no root entry is present, a compression error occurs.
|
||||
*/
|
||||
void PasswordFile::write(PasswordFileSaveFlags options)
|
||||
{
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
#include "./utils.h"
|
||||
|
||||
#include <c++utilities/tests/testutils.h>
|
||||
using namespace CppUtilities;
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
|
|
@ -3,9 +3,6 @@
|
|||
|
||||
#include "./utils.h"
|
||||
|
||||
#include <c++utilities/tests/testutils.h>
|
||||
using namespace CppUtilities;
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "../util/opensslrandomdevice.h"
|
||||
|
||||
#include <c++utilities/tests/testutils.h>
|
||||
#include "./utils.h"
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "../io/entry.h"
|
||||
#include "../io/passwordfile.h"
|
||||
|
||||
#include <c++utilities/tests/testutils.h>
|
||||
#include "./utils.h"
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
@ -84,7 +84,7 @@ void PasswordFileTests::testReading(const string &context, const string &testfil
|
|||
CPPUNIT_ASSERT(
|
||||
static_cast<AccountEntry *>(rootEntry->children()[0])->fields().at(0).tiedAccount() == static_cast<AccountEntry *>(rootEntry->children()[0]));
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(context, FieldType::Normal, static_cast<AccountEntry *>(rootEntry->children()[0])->fields().at(1).type());
|
||||
CPPUNIT_ASSERT_THROW_MESSAGE(context, static_cast<AccountEntry *>(rootEntry->children()[0])->fields().at(2), out_of_range);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(context, 2_st, static_cast<AccountEntry *>(rootEntry->children()[0])->fields().size());
|
||||
|
||||
// test testaccount2
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(context, "testaccount2"s, rootEntry->children()[1]->label());
|
||||
|
@ -231,7 +231,7 @@ void PasswordFileTests::testExtendedWriting()
|
|||
CPPUNIT_ASSERT_LESS(fileSize, file.size());
|
||||
file.load();
|
||||
|
||||
auto path = std::list<std::string>{"newAccount"};
|
||||
auto path = std::list<std::string>{ "newAccount" };
|
||||
CPPUNIT_ASSERT(file.rootEntry());
|
||||
CPPUNIT_ASSERT(!file.rootEntry()->entryByPath(path));
|
||||
}
|
||||
|
|
|
@ -23,4 +23,8 @@ inline std::ostream &operator<<(std::ostream &out, const Io::Field *field)
|
|||
|
||||
} // namespace CppUtilities
|
||||
|
||||
#include <c++utilities/tests/testutils.h>
|
||||
|
||||
using namespace CppUtilities;
|
||||
|
||||
#endif // PASSWORDFILE_TESTS_UTILS_H
|
||||
|
|
Loading…
Reference in New Issue