• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender / 2286202698

26 Jan 2026 10:37AM UTC coverage: 81.48% (+0.1%) from 81.368%
2286202698

push

gitlab-ci

lluiscampos
test: Add new DBus service file

See:
* https://github.com/mendersoftware/mender/pull/1874

Signed-off-by: Lluis Campos <lluis.campos@northern.tech>

8839 of 10848 relevant lines covered (81.48%)

20226.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

67.86
/src/api/auth/platform/dbus/auth.cpp
1
// Copyright 2024 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
#include <api/auth.hpp>
16

17
#include <string>
18
#include <vector>
19

20
#include <common/common.hpp>
21
#include <common/error.hpp>
22
#include <common/log.hpp>
23
#include <common/expected.hpp>
24

25
namespace mender {
26
namespace api {
27
namespace auth {
28

29

30
using namespace std;
31
namespace error = mender::common::error;
32
namespace common = mender::common;
33

34

35
namespace mlog = mender::common::log;
36
namespace expected = mender::common::expected;
37

38
error::Error AuthenticatorDBus::StartWatchingTokenSignal() {
22✔
39
        if (dbus_client_.WatchingSignal("io.mender.Authentication1", "JwtTokenStateChange")) {
44✔
40
                return error::NoError;
10✔
41
        }
42

43
        auto err = dbus_client_.RegisterSignalHandler<dbus::ExpectedStringPair>(
24✔
44
                "io.mender.Authentication1",
45
                "JwtTokenStateChange",
46
                [this](dbus::ExpectedStringPair ex_auth_dbus_data) {
12✔
47
                        HandleReceivedToken(ex_auth_dbus_data, NoTokenAction::Finish);
4✔
48
                });
16✔
49

50
        return err;
12✔
51
}
52

53
error::Error AuthenticatorDBus::GetJwtToken() {
15✔
54
        // Try to get token from mender-auth
55
        return dbus_client_.CallMethod<dbus::ExpectedStringPair>(
30✔
56
                "io.mender.AuthenticationManager",
57
                "/io/mender/AuthenticationManager",
58
                "io.mender.Authentication1",
59
                "GetJwtToken",
60
                [this](dbus::ExpectedStringPair ex_auth_dbus_data) {
45✔
61
                        HandleReceivedToken(ex_auth_dbus_data, NoTokenAction::RequestNew);
15✔
62
                });
60✔
63
}
64

65
error::Error AuthenticatorDBus::FetchJwtToken() {
28✔
66
        return dbus_client_.CallMethod<expected::ExpectedBool>(
56✔
67
                "io.mender.AuthenticationManager",
68
                "/io/mender/AuthenticationManager",
69
                "io.mender.Authentication1",
70
                "FetchJwtToken",
71
                [this](expected::ExpectedBool ex_value) {
6✔
72
                        if (!ex_value) {
6✔
73
                                token_fetch_in_progress_ = false;
×
74
                                mlog::Error("Failed to request new token fetching: " + ex_value.error().String());
×
75
                                ExpectedAuthData ex_auth_data = expected::unexpected(ex_value.error());
×
76
                                PostPendingActions(ex_auth_data);
×
77
                        } else if (!ex_value.value()) {
6✔
78
                                // mender-auth encountered an error not sent over DBus (should never happen)
79
                                token_fetch_in_progress_ = false;
×
80
                                mlog::Error(
×
81
                                        "Failed to request new token fetching (see mender-auth logs for details)");
82
                                ExpectedAuthData ex_auth_data = expected::unexpected(MakeError(
×
83
                                        AuthenticationError, "Failed to request new token fetching from mender-auth"));
×
84
                                PostPendingActions(ex_auth_data);
×
85
                        }
86
                });
90✔
87
}
88

89
} // namespace auth
90
} // namespace api
91
} // namespace mender
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc