* @brief Confirms the monotonic floor pins now to a previously observed future time. */
| 140 | * @brief Confirms the monotonic floor pins now to a previously observed future time. |
| 141 | */ |
| 142 | [[nodiscard]] static int runClockRewindCheck() |
| 143 | { |
| 144 | QSettings settings(QStringLiteral("SerialStudioSelfTest"), QStringLiteral("OfflineClock")); |
| 145 | settings.clear(); |
| 146 | |
| 147 | Licensing::SimpleCrypt crypt(0x0123456789abcdefULL); |
| 148 | crypt.setIntegrityProtectionMode(Licensing::SimpleCrypt::ProtectionHash); |
| 149 | |
| 150 | const auto future = QDateTime::currentDateTime().addYears(5); |
| 151 | settings.beginGroup("licensing"); |
| 152 | settings.setValue("lastSeen", crypt.encryptToString(future.toString(Qt::RFC2822Date))); |
| 153 | settings.endGroup(); |
| 154 | |
| 155 | const auto floored = Licensing::MonotonicClock::nowFloored(settings, crypt); |
| 156 | settings.clear(); |
| 157 | |
| 158 | return expect("clock floored to previously observed future (rewind blocked)", |
| 159 | floored >= future.addSecs(-60)); |
| 160 | } |
| 161 | |
| 162 | //-------------------------------------------------------------------------------------------------- |
| 163 | // Entry point |
no test coverage detected