56 const string &testfile2password,
bool testfilesMod,
bool extendedHeaderMod)
62 file.
open(PasswordFileOpenFlags::ReadOnly);
64 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, !testfile1password.empty(), file.
isEncryptionUsed());
67 if (!testfile1password.empty()) {
75 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"testfile1"s, rootEntry->
label());
76 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, 4_st, rootEntry->
children().size());
79 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"testaccount1"s, rootEntry->
children()[0]->label());
80 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, EntryType::Account, rootEntry->
children()[0]->type());
82 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"123456"s,
static_cast<AccountEntry *
>(rootEntry->
children()[0])->
fields().at(0).value());
83 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, FieldType::Password,
static_cast<AccountEntry *
>(rootEntry->
children()[0])->
fields().at(0).type());
86 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, FieldType::Normal,
static_cast<AccountEntry *
>(rootEntry->
children()[0])->
fields().at(1).type());
90 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"testaccount2"s, rootEntry->
children()[1]->label());
91 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, EntryType::Account, rootEntry->
children()[1]->type());
95 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"testcategory1"s, rootEntry->
children()[2]->label());
96 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, EntryType::Node, rootEntry->
children()[2]->type());
98 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, 3_st, category->
children().size());
99 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, EntryType::Node, category->
children()[2]->type());
103 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"testaccount3"s, rootEntry->
children()[3]->label());
107 }
else if (extendedHeaderMod) {
108 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"foo"s, file.
extendedHeader());
111 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
""s, file.
extendedHeader());
118 file.
open(PasswordFileOpenFlags::ReadOnly);
120 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, !testfile2password.empty(), file.
isEncryptionUsed());
125 if (extendedHeaderMod) {
126 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
static_cast<std::uint32_t
>(6), file.
version());
129 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
static_cast<std::uint32_t
>(3), file.
version());
132 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"testfile2 - modified"s, rootEntry2->
label());
133 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, 2_st, rootEntry2->
children().size());
134 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"newAccount"s, rootEntry2->
children()[1]->label());
136 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
static_cast<std::uint32_t
>(3), file.
version());
137 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"testfile2"s, rootEntry2->
label());
138 CPPUNIT_ASSERT_EQUAL_MESSAGE(context, 1_st, rootEntry2->
children().size());
140 if (extendedHeaderMod) {
141 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
"foo"s, file.
extendedHeader());
145 CPPUNIT_ASSERT_EQUAL_MESSAGE(context,
""s, file.
extendedHeader());
The exception that is thrown when a parsing error occurs.
const std::vector< Field > & fields() const
void setLabel(const std::string &label)
Sets the label.
const std::string & label() const
Returns the label.
The NodeEntry class acts as parent for other entries.
Entry * entryByPath(std::list< std::string > &path, bool includeThis=true, const EntryType *creationType=nullptr)
Returns an entry specified by the provided path.
const std::vector< Entry * > & children() const