EnterLeaveDeviceGroup testing done.
1.1 --- a/test/include/EnterLeaveDeviceGroupTests.h Wed Apr 03 17:18:55 2019 +0200
1.2 +++ b/test/include/EnterLeaveDeviceGroupTests.h Wed Apr 03 17:52:41 2019 +0200
1.3 @@ -24,6 +24,11 @@
1.4 void check_enter_device_group_many_own_one();
1.5 void check_enter_device_group_many_own_many();
1.6 void check_enter_device_group_many_own_many_w_not_me();
1.7 + void check_leave_device_group_empty();
1.8 + void check_leave_device_group_sole();
1.9 + void check_leave_device_group_one_in_one_out();
1.10 + void check_leave_device_group_three_in();
1.11 + void check_leave_device_group_two_in_one_out();
1.12 };
1.13
1.14 #endif
2.1 --- a/test/src/engine_tests/EnterLeaveDeviceGroupTests.cc Wed Apr 03 17:18:55 2019 +0200
2.2 +++ b/test/src/engine_tests/EnterLeaveDeviceGroupTests.cc Wed Apr 03 17:52:41 2019 +0200
2.3 @@ -39,6 +39,16 @@
2.4 static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many)));
2.5 add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many_w_not_me"),
2.6 static_cast<Func>(&EnterLeaveDeviceGroupTests::check_enter_device_group_many_own_many_w_not_me)));
2.7 + add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_leave_device_group_empty"),
2.8 + static_cast<Func>(&EnterLeaveDeviceGroupTests::check_leave_device_group_empty)));
2.9 + add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_leave_device_group_sole"),
2.10 + static_cast<Func>(&EnterLeaveDeviceGroupTests::check_leave_device_group_sole)));
2.11 + add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_leave_device_group_one_in_one_out"),
2.12 + static_cast<Func>(&EnterLeaveDeviceGroupTests::check_leave_device_group_one_in_one_out)));
2.13 + add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_leave_device_group_three_in"),
2.14 + static_cast<Func>(&EnterLeaveDeviceGroupTests::check_leave_device_group_three_in)));
2.15 + add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("EnterLeaveDeviceGroupTests::check_leave_device_group_two_in_one_out"),
2.16 + static_cast<Func>(&EnterLeaveDeviceGroupTests::check_leave_device_group_two_in_one_out)));
2.17 }
2.18
2.19 void EnterLeaveDeviceGroupTests::check_enter_device_group_no_own() {
2.20 @@ -744,3 +754,216 @@
2.21 free_identity(alice_id2);
2.22 free_identity(alice_id3);
2.23 }
2.24 +
2.25 +void EnterLeaveDeviceGroupTests::check_leave_device_group_empty() {
2.26 + PEP_STATUS status = leave_device_group(session);
2.27 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.28 +}
2.29 +
2.30 +void EnterLeaveDeviceGroupTests::check_leave_device_group_sole() {
2.31 + pEp_identity* alice_id = NULL;
2.32 + TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));
2.33 + PEP_STATUS status = set_up_ident_from_scratch(session,
2.34 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.35 + "pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.36 + "ALICE", "Alice in Wonderland", &alice_id, true
2.37 + );
2.38 +
2.39 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.40 + status = myself(session, alice_id);
2.41 +
2.42 + TEST_ASSERT(alice_id->me);
2.43 + TEST_ASSERT(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
2.44 + identity_list* ids_to_group = new_identity_list(alice_id);
2.45 + status = enter_device_group(session, ids_to_group);
2.46 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.47 +
2.48 + status = myself(session, alice_id);
2.49 + TEST_ASSERT(status == PEP_STATUS_OK);
2.50 + TEST_ASSERT_MSG(alice_id->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id->flags).c_str());
2.51 +
2.52 + status = leave_device_group(session);
2.53 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.54 + status = myself(session, alice_id);
2.55 + TEST_ASSERT(status == PEP_STATUS_OK);
2.56 + TEST_ASSERT_MSG(!(alice_id->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id->flags).c_str());
2.57 +
2.58 + free_identity_list(ids_to_group);
2.59 +}
2.60 +
2.61 +void EnterLeaveDeviceGroupTests::check_leave_device_group_one_in_one_out() {
2.62 + pEp_identity* alice_id = NULL;
2.63 + TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));
2.64 + PEP_STATUS status = set_up_ident_from_scratch(session,
2.65 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.66 + "pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.67 + "ALICE", "Alice in Wonderland", &alice_id, true
2.68 + );
2.69 +
2.70 + pEp_identity* alice_id2 = NULL;
2.71 + status = set_up_ident_from_scratch(session,
2.72 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.73 + "pep.test.alice_2@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.74 + "ALICE", "Bob is Alice", &alice_id2, true
2.75 + );
2.76 +
2.77 + identity_list* ids_to_group = new_identity_list(alice_id);
2.78 + status = enter_device_group(session, ids_to_group);
2.79 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.80 +
2.81 + status = myself(session, alice_id);
2.82 + TEST_ASSERT(status == PEP_STATUS_OK);
2.83 + TEST_ASSERT_MSG(alice_id->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id->flags).c_str());
2.84 +
2.85 + status = myself(session, alice_id2);
2.86 + TEST_ASSERT(status == PEP_STATUS_OK);
2.87 + TEST_ASSERT_MSG(!(alice_id2->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id2->flags).c_str());
2.88 +
2.89 + status = leave_device_group(session);
2.90 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.91 +
2.92 + status = myself(session, alice_id);
2.93 + TEST_ASSERT(status == PEP_STATUS_OK);
2.94 + TEST_ASSERT_MSG(!(alice_id->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id->flags).c_str());
2.95 +
2.96 + status = myself(session, alice_id2);
2.97 + TEST_ASSERT(status == PEP_STATUS_OK);
2.98 + TEST_ASSERT_MSG(!(alice_id2->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id2->flags).c_str());
2.99 +
2.100 + free_identity_list(ids_to_group);
2.101 + free_identity(alice_id2);
2.102 +}
2.103 +
2.104 +void EnterLeaveDeviceGroupTests::check_leave_device_group_three_in() {
2.105 + pEp_identity* alice_id = NULL;
2.106 + TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));
2.107 + PEP_STATUS status = set_up_ident_from_scratch(session,
2.108 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.109 + "pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.110 + "ALICE", "Alice in Wonderland", &alice_id, true
2.111 + );
2.112 +
2.113 + pEp_identity* alice_id2 = NULL;
2.114 + status = set_up_ident_from_scratch(session,
2.115 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.116 + "pep.test.alice_2@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.117 + "ALICE", "Barbara is Alice", &alice_id2, true
2.118 + );
2.119 +
2.120 + pEp_identity* alice_id3 = NULL;
2.121 + status = set_up_ident_from_scratch(session,
2.122 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.123 + "pep.test.alice_3@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.124 + "ALICE", "Carol is Alice", &alice_id3, true
2.125 + );
2.126 +
2.127 + status = enter_device_group(session, NULL);
2.128 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.129 +
2.130 + status = myself(session, alice_id);
2.131 + TEST_ASSERT(status == PEP_STATUS_OK);
2.132 + TEST_ASSERT_MSG(alice_id->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id->flags).c_str());
2.133 +
2.134 + status = myself(session, alice_id2);
2.135 + TEST_ASSERT(status == PEP_STATUS_OK);
2.136 + TEST_ASSERT_MSG(alice_id2->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id2->flags).c_str());
2.137 +
2.138 + status = myself(session, alice_id3);
2.139 + TEST_ASSERT(status == PEP_STATUS_OK);
2.140 + TEST_ASSERT_MSG(alice_id3->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id3->flags).c_str());
2.141 +
2.142 + status = leave_device_group(session);
2.143 + TEST_ASSERT(status == PEP_STATUS_OK);
2.144 +
2.145 + status = myself(session, alice_id);
2.146 + TEST_ASSERT(status == PEP_STATUS_OK);
2.147 + TEST_ASSERT_MSG(!(alice_id->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id->flags).c_str());
2.148 +
2.149 + status = myself(session, alice_id2);
2.150 + TEST_ASSERT(status == PEP_STATUS_OK);
2.151 + TEST_ASSERT_MSG(!(alice_id2->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id2->flags).c_str());
2.152 +
2.153 + status = myself(session, alice_id3);
2.154 + TEST_ASSERT(status == PEP_STATUS_OK);
2.155 + TEST_ASSERT_MSG(!(alice_id3->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id3->flags).c_str());
2.156 +
2.157 +
2.158 + free_identity(alice_id);
2.159 + free_identity(alice_id2);
2.160 + free_identity(alice_id3);
2.161 +}
2.162 +
2.163 +void EnterLeaveDeviceGroupTests::check_leave_device_group_two_in_one_out() {
2.164 + pEp_identity* alice_id = NULL;
2.165 + TEST_ASSERT(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));
2.166 + PEP_STATUS status = set_up_ident_from_scratch(session,
2.167 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.168 + "pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.169 + "ALICE", "Alice in Wonderland", &alice_id, true
2.170 + );
2.171 +
2.172 + pEp_identity* alice_id2 = NULL;
2.173 + status = set_up_ident_from_scratch(session,
2.174 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.175 + "pep.test.alice_2@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.176 + "ALICE", "Barbara is Alice", &alice_id2, true
2.177 + );
2.178 +
2.179 + pEp_identity* alice_id3 = NULL;
2.180 + status = set_up_ident_from_scratch(session,
2.181 + "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
2.182 + "pep.test.alice_3@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97",
2.183 + "ALICE", "Carol is Alice", &alice_id3, true
2.184 + );
2.185 +
2.186 + status = myself(session, alice_id);
2.187 + TEST_ASSERT(status == PEP_STATUS_OK);
2.188 +
2.189 + status = myself(session, alice_id2);
2.190 + TEST_ASSERT(status == PEP_STATUS_OK);
2.191 +
2.192 + status = myself(session, alice_id3);
2.193 + TEST_ASSERT(status == PEP_STATUS_OK);
2.194 +
2.195 + identity_list* ids_to_group = new_identity_list(alice_id);
2.196 + identity_list_add(ids_to_group, alice_id2);
2.197 + status = enter_device_group(session, ids_to_group);
2.198 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.199 +
2.200 + status = myself(session, alice_id);
2.201 + TEST_ASSERT(status == PEP_STATUS_OK);
2.202 + TEST_ASSERT_MSG(alice_id->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id->flags).c_str());
2.203 +
2.204 + status = enter_device_group(session, ids_to_group);
2.205 + TEST_ASSERT_MSG(status == PEP_STATUS_OK, tl_status_string(status));
2.206 +
2.207 + status = myself(session, alice_id);
2.208 + TEST_ASSERT(status == PEP_STATUS_OK);
2.209 + TEST_ASSERT_MSG(alice_id->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id->flags).c_str());
2.210 +
2.211 + status = myself(session, alice_id2);
2.212 + TEST_ASSERT(status == PEP_STATUS_OK);
2.213 + TEST_ASSERT_MSG(alice_id2->flags & PEP_idf_devicegroup, tl_ident_flags_String(alice_id2->flags).c_str());
2.214 +
2.215 + status = myself(session, alice_id3);
2.216 + TEST_ASSERT(status == PEP_STATUS_OK);
2.217 + TEST_ASSERT_MSG(!(alice_id3->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id3->flags).c_str());
2.218 +
2.219 + status = leave_device_group(session);
2.220 + TEST_ASSERT(status == PEP_STATUS_OK);
2.221 +
2.222 + status = myself(session, alice_id);
2.223 + TEST_ASSERT(status == PEP_STATUS_OK);
2.224 + TEST_ASSERT_MSG(!(alice_id->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id->flags).c_str());
2.225 +
2.226 + status = myself(session, alice_id2);
2.227 + TEST_ASSERT(status == PEP_STATUS_OK);
2.228 + TEST_ASSERT_MSG(!(alice_id2->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id2->flags).c_str());
2.229 +
2.230 + status = myself(session, alice_id3);
2.231 + TEST_ASSERT(status == PEP_STATUS_OK);
2.232 + TEST_ASSERT_MSG(!(alice_id3->flags & PEP_idf_devicegroup), tl_ident_flags_String(alice_id3->flags).c_str());
2.233 +
2.234 + free_identity_list(ids_to_group);
2.235 + free_identity(alice_id3);
2.236 +}