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

mendersoftware / mender / 974575668

21 Aug 2023 12:04PM UTC coverage: 78.829% (-0.05%) from 78.877%
974575668

push

gitlab-ci

kacf
chore: Implement pushing of logs to the server.

Ticket: MEN-6581

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

18 of 18 new or added lines in 2 files covered. (100.0%)

5492 of 6967 relevant lines covered (78.83%)

238.75 hits per line

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

25.0
/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_CLIENT_HPP
17
#define MENDER_AUTH_CLIENT_HPP
18

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

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

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

31
namespace mender {
32
namespace auth {
33
namespace ipc {
34

35

36
using namespace std;
37

38
namespace auth_client = mender::api::auth;
39
namespace conf = mender::common::conf;
40
namespace error = mender::common::error;
41
namespace events = mender::common::events;
42
namespace log = mender::common::log;
43
namespace path = mender::common::path;
44

45

46
namespace type {
47
namespace webserver {
48

49
class Caching {
50
public:
51
        Caching(events::EventLoop &loop, const conf::MenderConfig &config) :
52
                server_url_ {config.server_url},
53
                tenant_token_ {config.tenant_token},
54
                client_config_ {config.server_certificate},
55
                client_ {client_config_, loop},
56
                server_config_ {},
57
                server_ {server_config_, loop},
58
                default_identity_script_path_ {config.paths.GetIdentityScript()} {};
59

60
        Caching(Caching &&) = default;
61

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

67
        string GetServerURL() {
×
68
                return this->cached_server_url_;
×
69
        }
70

71
        string GetJWTToken() {
×
72
                return this->cached_jwt_token_;
×
73
        }
74

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

80
private:
81
        void ClearCache() {
×
82
                Cache("", "");
×
83
        }
×
84

85
        void CacheAPIResponse(const string &server_url, auth_client::APIResponse resp) {
1✔
86
                if (resp) {
1✔
87
                        Cache(resp.value(), server_url);
1✔
88
                        return;
1✔
89
                }
90
                ClearCache();
×
91
        };
92

93
        string cached_jwt_token_;
94
        string cached_server_url_;
95

96
        const string server_url_;
97
        const string tenant_token_;
98
        http::ClientConfig client_config_;
99
        http::Client client_;
100
        http::ServerConfig server_config_;
101
        http::Server server_;
102
        string default_identity_script_path_;
103
};
104

105
} // namespace webserver
106
} // namespace type
107

108
using Server = type::webserver::Caching;
109

110
} // namespace ipc
111
} // namespace auth
112
} // namespace mender
113

114

115
#endif // MENDER_AUTH_CLIENT_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