From: Marcin Siodelski Date: Tue, 19 Mar 2019 12:53:10 +0000 (+0100) Subject: [#103,!277] Implemented CBControlBase::reset function. X-Git-Tag: Kea-1.6.0-beta~326 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67eaad645f91cae997319f0e7f1b92aaa2cf4e1f;p=thirdparty%2Fkea.git [#103,!277] Implemented CBControlBase::reset function. --- diff --git a/src/lib/process/cb_ctl_base.h b/src/lib/process/cb_ctl_base.h index 8547cacc97..f5215cdc57 100644 --- a/src/lib/process/cb_ctl_base.h +++ b/src/lib/process/cb_ctl_base.h @@ -94,6 +94,15 @@ public: databaseConfigDisconnect(); } + /// @brief Resets the state of this object. + /// + /// Disconnects the configuration backends resets the recorded last + /// audit entry time. + void reset() { + databaseConfigDisconnect(); + last_audit_entry_time_ = getInitialAuditEntryTime(); + } + /// @brief (Re)connects to the specified configuration backends. /// /// This method disconnects from any existing configuration backends diff --git a/src/lib/process/tests/cb_ctl_base_unittests.cc b/src/lib/process/tests/cb_ctl_base_unittests.cc index 19a07a879c..9f971ae985 100644 --- a/src/lib/process/tests/cb_ctl_base_unittests.cc +++ b/src/lib/process/tests/cb_ctl_base_unittests.cc @@ -381,6 +381,14 @@ TEST_F(CBControlBaseTest, getMgr) { EXPECT_EQ(TEST_INSTANCE_ID, mgr.getInstanceId()); } +// This test verifies that last audit entry time is reset upon the +// call to CBControlBase::reset(). +TEST_F(CBControlBaseTest, reset) { + cb_ctl_.setLastAuditEntryTime(timestamps_["tomorrow"]); + cb_ctl_.reset(); + EXPECT_EQ(cb_ctl_.getInitialAuditEntryTime(), cb_ctl_.getLastAuditEntryTime()); +} + // This test verifies that it is correctly determined whether the // server should fetch the particular configuration element. TEST_F(CBControlBaseTest, fetchConfigElement) {