void DeferredTrust::finalize(Active& active)
{
- if (active.packet_was_dropped())
+ if (active.session_was_blocked())
clear();
else if (TRUST_DEFER_DO_TRUST == deferred_trust && active.session_was_allowed())
active.set_trust();
CHECK_TEXT(active.session_was_allowed(), "Session was not allowed while deferring trust");
}
+/* Stub implementation for the test below to avoid linking */
+void Active::drop_packet(const Packet*, bool)
+{
+ active_action = ACT_DROP;
+}
+
+TEST(deferred_trust_test, finalize_clear)
+{
+ Active active{};
+
+ deferred_trust.clear();
+ // Enable
+ deferred_trust.set_deferred_trust(1, true);
+ CHECK_TEXT(deferred_trust.is_active(), "Deferred trust should be active");
+ active.block_again();
+ // finalize should clear deferred_trust
+ deferred_trust.finalize(active);
+ CHECK_TEXT(!deferred_trust.is_active(), "Deferred trust should not be active");
+
+ deferred_trust.clear();
+ // Enable
+ deferred_trust.set_deferred_trust(1, true);
+ CHECK_TEXT(deferred_trust.is_active(), "Deferred trust should be active");
+ active.drop_packet(nullptr, true);
+ // finalize should NOT clear deferred_trust
+ deferred_trust.finalize(active);
+ CHECK_TEXT(deferred_trust.is_active(), "Deferred trust should still be active");
+}
int main(int argc, char** argv)
{