Skip to content

Commit

Permalink
Fix info/members key lists when loading from dump
Browse files Browse the repository at this point in the history
The key lists weren't being set properly when loading a Keys object from
a dump; these sets the key lists properly.
  • Loading branch information
jagerman committed Sep 6, 2023
1 parent 2adb20c commit f61bc4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/config/groups/keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Keys::Keys(

if (dumped) {
load_dump(*dumped);
auto key_list = group_keys();
members.replace_keys(key_list, /*dirty=*/false);
info.replace_keys(key_list, /*dirty=*/false);
} else if (admin()) {
rekey(info, members);
}
Expand Down
16 changes: 16 additions & 0 deletions tests/test_group_keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,22 @@ TEST_CASE("Group Keys - C++ API", "[config][groups][keys][cpp]") {
CHECK(m.members.size() == 5);
CHECK(m.keys.current_hashes() == std::unordered_set{{"keyhash6"s, "keyhash7"s}});
}

// Make sure keys propagate on dump restore to info/members:
pseudo_client admin1b{
admin1_seed,
true,
group_pk.data(),
group_sk.data(),
admin1.info.dump(),
admin1.members.dump(),
admin1.keys.dump()};
admin1b.info.set_name("Test New Name");
CHECK_NOTHROW(admin1b.info.push());
admin1b.members.set(
admin1b.members.get_or_construct("05124076571076017981235497801235098712093870981273590"
"8746387172343"));
CHECK_NOTHROW(admin1b.members.push());
}

TEST_CASE("Group Keys - C API", "[config][groups][keys][c]") {
Expand Down

0 comments on commit f61bc4a

Please sign in to comment.