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

mendersoftware / mender / 969241802

16 Aug 2023 08:29AM UTC coverage: 79.019% (+0.2%) from 78.825%
969241802

push

gitlab-ci

oleorhagen
chore(crypto): Make the PrivateKey constructor public

Signed-off-by: Ole Petter <ole.orhagen@northern.tech>

5314 of 6725 relevant lines covered (79.02%)

200.29 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, 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

59
        Caching(Caching &&) = default;
60

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

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

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

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

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

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

92
        string cached_jwt_token_;
93
        string cached_server_url_;
94

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

103
} // namespace webserver
104
} // namespace type
105

106
using Server = type::webserver::Caching;
107

108
} // namespace ipc
109
} // namespace auth
110
} // namespace mender
111

112

113
#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