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

mendersoftware / mender / 1056184062

31 Oct 2023 12:41PM UTC coverage: 80.182% (+0.3%) from 79.877%
1056184062

push

gitlab-ci

kacf
chore: Do not try to resume requests that were cancelled by callers.

This requires us to move the destruction of the inner reader until
after the body handler has been called, otherwise it will trigger
another `operation_canceled` error which we don't want.

Ticket: MEN-6807

Signed-off-by: Kristian Amlie <kristian.amlie@northern.tech>

5 of 5 new or added lines in 1 file covered. (100.0%)

6890 of 8593 relevant lines covered (80.18%)

9363.89 hits per line

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

0.0
/src/mender-auth/ipc/server.hpp
1
// Copyright 2023 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

16
#ifndef MENDER_AUTH_IPC_SERVER_HPP
17
#define MENDER_AUTH_IPC_SERVER_HPP
18

19
#include <functional>
20
#include <string>
21

22
#include <common/conf.hpp>
23
#include <common/dbus.hpp>
24
#include <common/error.hpp>
25
#include <common/events.hpp>
26
#include <common/http.hpp>
27
#include <common/path.hpp>
28

29
#include <api/api.hpp>
30
#include <api/auth.hpp>
31

32
#include <mender-auth/http_forwarder.hpp>
33

34
namespace mender {
35
namespace auth {
36
namespace ipc {
37

38

39
using namespace std;
40

41
namespace conf = mender::common::conf;
42
namespace dbus = mender::common::dbus;
43
namespace error = mender::common::error;
44
namespace events = mender::common::events;
45
namespace log = mender::common::log;
46
namespace path = mender::common::path;
47

48
namespace auth_client = mender::api::auth;
49

50
namespace http_forwarder = mender::auth::http_forwarder;
51

52
class AuthenticatingForwarder {
53
public:
54
        AuthenticatingForwarder(events::EventLoop &loop, const conf::MenderConfig &config) :
×
55
                servers_ {config.servers},
×
56
                tenant_token_ {config.tenant_token},
×
57
                client_ {config.GetHttpClientConfig(), loop},
58
                forwarder_ {http::ServerConfig {}, config.GetHttpClientConfig(), loop},
×
59
                default_identity_script_path_ {config.paths.GetIdentityScript()},
60
                dbus_server_ {loop, "io.mender.AuthenticationManager"} {};
×
61

62
        error::Error Listen(
63
                const string &private_key_path = "", const string &identity_script_path = "");
64

65
        string GetServerURL() {
66
                return this->cached_server_url_;
67
        }
68

69
        string GetJWTToken() {
70
                return this->cached_jwt_token_;
71
        }
72

73
        void Cache(const string &token, const string &url) {
74
                this->cached_jwt_token_ = token;
75
                this->cached_server_url_ = url;
76
        }
77

78
        const http_forwarder::Server &GetForwarder() const {
79
                return forwarder_;
80
        }
81

82
private:
83
        void ClearCache() {
84
                Cache("", "");
85
        }
86

87
        void FetchJwtTokenHandler(auth_client::APIResponse &resp);
88

89
        string cached_jwt_token_;
90
        string cached_server_url_;
91
        bool auth_in_progress_ = false;
92

93
        const vector<string> &servers_;
94
        const string tenant_token_;
95
        http::Client client_;
96
        http_forwarder::Server forwarder_;
97
        string default_identity_script_path_;
98
        dbus::DBusServer dbus_server_;
99
};
100

101
using Server = AuthenticatingForwarder;
102

103
} // namespace ipc
104
} // namespace auth
105
} // namespace mender
106

107

108
#endif // MENDER_AUTH_IPC_SERVER_HPP
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

© 2025 Coveralls, Inc