M module-services/service-desktop/endpoints/include/endpoints/JsonKeyNames.hpp => module-services/service-desktop/endpoints/include/endpoints/JsonKeyNames.hpp +8 -7
@@ 108,13 108,14 @@ namespace sdesktop::endpoints::json
namespace usb
{
- inline constexpr auto config = "config";
- inline constexpr auto locked = "locked";
- inline constexpr auto unlocked = "unlocked";
- inline constexpr auto security = "usbSecurity";
- inline constexpr auto phoneLockCode = "phoneLockCode";
- inline constexpr auto phoneLockStatus = "phoneLockStatus";
- inline constexpr auto phoneLockTime = "phoneLockTime";
+ inline constexpr auto config = "config";
+ inline constexpr auto locked = "locked";
+ inline constexpr auto unlocked = "unlocked";
+ inline constexpr auto security = "usbSecurity";
+ inline constexpr auto phoneLockCode = "phoneLockCode";
+ inline constexpr auto phoneLockStatus = "phoneLockStatus";
+ inline constexpr auto phoneLockTime = "phoneLockTime";
+ inline constexpr auto timeLeftToNextAttempt = "timeLeftToNextAttempt";
} // namespace usb
} // namespace sdesktop::endpoints::json
M module-services/service-desktop/endpoints/security/SecurityEndpointHelper.cpp => module-services/service-desktop/endpoints/security/SecurityEndpointHelper.cpp +7 -5
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <endpoints/security/SecurityEndpointHelper.hpp>
@@ 33,8 33,10 @@ namespace sdesktop::endpoints
}
if (context.getBody()[json::messages::category].string_value() == json::usb::phoneLockTime) {
if (auto phoneLockTime = getPhoneLockTime(context); phoneLockTime > std::time(nullptr)) {
- context.setResponseBody(
- json11::Json::object({{json::usb::phoneLockTime, static_cast<int>(phoneLockTime)}}));
+ auto timeLeftToNextAttempt = phoneLockTime - std::time(nullptr);
+ context.setResponseBody(json11::Json::object(
+ {{json::usb::phoneLockTime, static_cast<int>(phoneLockTime)},
+ {json::usb::timeLeftToNextAttempt, static_cast<int>(timeLeftToNextAttempt)}}));
context.setResponseStatus(http::Code::OK);
}
else {
@@ 46,7 48,7 @@ namespace sdesktop::endpoints
return {sent::no, ResponseContext{.status = http::Code::BadRequest}};
}
- auto SecurityEndpointHelper::processStatus(Context &context) -> http::Code
+ auto SecurityEndpointHelper::processStatus(Context & /*context*/) -> http::Code
{
auto desktopService = dynamic_cast<ServiceDesktop *>(owner);
auto security = desktopService->getSecurity()->getEndpointSecurity();
@@ 58,7 60,7 @@ namespace sdesktop::endpoints
return security == EndpointSecurity::Allow ? http::Code::NoContent : http::Code::Forbidden;
}
- auto SecurityEndpointHelper::getPhoneLockTime(Context &context) -> time_t
+ auto SecurityEndpointHelper::getPhoneLockTime(Context & /*context*/) -> time_t
{
auto desktopService = static_cast<ServiceDesktop *>(owner);
return desktopService->getSecurity()->getPhoneLockTime();
M test/harness => test/harness +1 -1
@@ 1,1 1,1 @@
-Subproject commit 3d77819ba8ab0cbac5912b2f3ca9f002e21a436a
+Subproject commit 7d219c6ee72d0207880a9e13fdd0c59892db9612
M test/pytest/service-desktop/test_security.py => test/pytest/service-desktop/test_security.py +2 -1
@@ 1,4 1,4 @@
-# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+# Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
import logging
@@ 192,6 192,7 @@ def test_security_time_lock(harness):
assert security_tester.confirm_phone_is_locked(), "Phone is unlocked, but should be locked!"
assert time.time() < GetPhoneLockTime().run(harness).phoneLockTime <= time.time() + 30
+ assert GetPhoneLockTime().run(harness).timeLeftToNextAttempt <= 15
"""
Attempt unlocking with default (correct) passcode while phone is time locked