Skip to content

Commit 50a981b

Browse files
Remove methods marked as deprecated 04.2020 (#798)
Remove deprecated methods from AuthenticationClient. Adapt authentication test with proxy to new client constructor. Fix cpplint style warnings in AuthenticationClient.cpp Fix double quotes in cpplint check script. Redirect stderr output to warnings.txt and display it after the cpplint is finished. Relates-To: OLPEDGE-1855 Signed-off-by: Mykhailo Kuchma <ext-mykhailo.kuchma@here.com>
1 parent 6fa1fa7 commit 50a981b

File tree

4 files changed

+35
-119
lines changed

4 files changed

+35
-119
lines changed

olp-cpp-sdk-authentication/include/olp/authentication/AuthenticationClient.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,6 @@ class AUTHENTICATION_API AuthenticationClient {
257257
unsigned int expires_in = 0;
258258
};
259259

260-
/**
261-
* @brief Creates the `AuthenticationClient` instance.
262-
*
263-
* @param authentication_server_url The URL of the HERE Account server.
264-
* @example "https://account.api.here.com
265-
* @param token_cache_limit The maximum number of tokens that can be cached.
266-
*/
267-
OLP_SDK_DEPRECATED("Deprecated. Will be removed in 04.2020")
268-
AuthenticationClient(
269-
const std::string& authentication_server_url = kHereAccountProductionUrl,
270-
size_t token_cache_limit = 100u);
271-
272260
/**
273261
* @brief Creates the `AuthenticationClient` instance.
274262
*
@@ -576,39 +564,6 @@ class AUTHENTICATION_API AuthenticationClient {
576564
client::CancellationToken IntrospectApp(std::string access_token,
577565
IntrospectAppCallback callback);
578566

579-
/**
580-
* @brief Sets the `NetworkProxySettings` instance used by the underlying
581-
* network layer to make requests.
582-
*
583-
* It is recommended to call this function before you
584-
* make any requests using the `AuthenticationClient` instance.
585-
*
586-
* @param proxy_settings The proxy settings used by the network layer to make
587-
* requests.
588-
*/
589-
OLP_SDK_DEPRECATED("Deprecated. Will be removed in 04.2020")
590-
void SetNetworkProxySettings(
591-
const http::NetworkProxySettings& proxy_settings);
592-
593-
/**
594-
* @brief Sets the `Network` class handler used to make requests.
595-
*
596-
* @param network The shared `Network` instance used to trigger requests.
597-
* Should not be `nullptr`; otherwise, any access to the class method calls
598-
* would render `http::ErrorCode::IO_ERROR`.
599-
*/
600-
OLP_SDK_DEPRECATED("Deprecated. Will be removed in 04.2020")
601-
void SetNetwork(std::shared_ptr<http::Network> network);
602-
603-
/**
604-
* @brief Sets the `TaskScheduler` class.
605-
*
606-
* @param task_scheduler The shared `TaskScheduler` instance used for requests
607-
* outcomes. If set to `nullptr`, callbacks are sent synchronously.
608-
*/
609-
OLP_SDK_DEPRECATED("Deprecated. Will be removed in 04.2020")
610-
void SetTaskScheduler(std::shared_ptr<thread::TaskScheduler> task_scheduler);
611-
612567
private:
613568
class Impl;
614569
std::unique_ptr<Impl> impl_;

olp-cpp-sdk-authentication/src/AuthenticationClient.cpp

Lines changed: 21 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
#include "olp/authentication/AuthenticationClient.h"
2121

22-
#include <chrono>
23-
#include <sstream>
24-
25-
#include <olp/core/client/PendingRequests.h>
2622
#include <rapidjson/document.h>
2723
#include <rapidjson/istreamwrapper.h>
2824
#include <rapidjson/stringbuffer.h>
2925
#include <rapidjson/writer.h>
26+
27+
#include <chrono>
28+
#include <sstream>
29+
3030
#include <boost/uuid/uuid.hpp>
3131
#include <boost/uuid/uuid_generators.hpp>
3232
#include <boost/uuid/uuid_io.hpp>
@@ -42,6 +42,7 @@
4242
#include "olp/core/client/CancellationToken.h"
4343
#include "olp/core/client/ErrorCode.h"
4444
#include "olp/core/client/OlpClient.h"
45+
#include "olp/core/client/PendingRequests.h"
4546
#include "olp/core/http/HttpStatusCode.h"
4647
#include "olp/core/http/Network.h"
4748
#include "olp/core/http/NetworkConstants.h"
@@ -54,9 +55,6 @@
5455
#include "olp/core/utils/LruCache.h"
5556
#include "olp/core/utils/Url.h"
5657

57-
using namespace olp::thread;
58-
using namespace olp::utils;
59-
6058
namespace {
6159
using namespace olp::authentication;
6260

@@ -111,7 +109,7 @@ constexpr auto kVersion = "1.0";
111109
constexpr auto kHmac = "HMAC-SHA256";
112110

113111
void ExecuteOrSchedule(
114-
std::shared_ptr<olp::thread::TaskScheduler>& task_scheduler,
112+
const std::shared_ptr<olp::thread::TaskScheduler>& task_scheduler,
115113
olp::thread::TaskScheduler::CallFuncType&& func) {
116114
if (!task_scheduler) {
117115
// User didn't specify a TaskScheduler, execute sync
@@ -137,7 +135,7 @@ void ExecuteOrSchedule(
137135
*/
138136
template <typename Function, typename Callback, typename... Args>
139137
inline olp::client::CancellationToken AddTask(
140-
std::shared_ptr<olp::thread::TaskScheduler>& task_scheduler,
138+
const std::shared_ptr<olp::thread::TaskScheduler>& task_scheduler,
141139
const std::shared_ptr<olp::client::PendingRequests>& pending_requests,
142140
Function task, Callback callback, Args&&... args) {
143141
auto context = olp::client::TaskContext::Create(
@@ -247,11 +245,12 @@ enum class FederatedSignInType { FacebookSignIn, GoogleSignIn, ArcgisSignIn };
247245
class AuthenticationClient::Impl final {
248246
public:
249247
/// The sign in cache alias type
250-
using SignInCacheType = Atomic<utils::LruCache<std::string, SignInResult>>;
248+
using SignInCacheType =
249+
thread::Atomic<utils::LruCache<std::string, SignInResult>>;
251250

252251
/// The sign in user cache alias type
253252
using SignInUserCacheType =
254-
Atomic<utils::LruCache<std::string, SignInUserResult>>;
253+
thread::Atomic<utils::LruCache<std::string, SignInUserResult>>;
255254

256255
/**
257256
* @brief Constructor
@@ -264,7 +263,7 @@ class AuthenticationClient::Impl final {
264263
* @param settings The authentication settings that can be used to configure
265264
* the `Impl` instance.
266265
*/
267-
Impl(AuthenticationSettings settings);
266+
explicit Impl(AuthenticationSettings settings);
268267

269268
/**
270269
* @brief Destructor
@@ -318,13 +317,6 @@ class AuthenticationClient::Impl final {
318317
client::CancellationToken IntrospectApp(std::string access_token,
319318
IntrospectAppCallback callback);
320319

321-
void SetNetworkProxySettings(
322-
const http::NetworkProxySettings& proxy_settings);
323-
324-
void SetNetwork(std::shared_ptr<http::Network> network);
325-
326-
void SetTaskScheduler(std::shared_ptr<TaskScheduler> task_scheduler);
327-
328320
private:
329321
using TimeResponse = client::ApiResponse<time_t, client::ApiError>;
330322
using TimeCallback = std::function<void(TimeResponse)>;
@@ -369,25 +361,6 @@ class AuthenticationClient::Impl final {
369361
mutable std::mutex token_mutex_;
370362
};
371363

372-
void AuthenticationClient::Impl::SetNetworkProxySettings(
373-
const http::NetworkProxySettings& proxy_settings) {
374-
settings_.network_proxy_settings = proxy_settings;
375-
}
376-
377-
void AuthenticationClient::Impl::SetNetwork(
378-
std::shared_ptr<http::Network> network) {
379-
if (settings_.network_request_handler != network) {
380-
settings_.network_request_handler = std::move(network);
381-
}
382-
}
383-
384-
void AuthenticationClient::Impl::SetTaskScheduler(
385-
std::shared_ptr<TaskScheduler> task_scheduler) {
386-
if (settings_.task_scheduler != task_scheduler) {
387-
settings_.task_scheduler = std::move(task_scheduler);
388-
}
389-
}
390-
391364
AuthenticationClient::Impl::Impl(const std::string& authentication_server_url,
392365
size_t token_cache_limit)
393366
: client_token_cache_(std::make_shared<SignInCacheType>(token_cache_limit)),
@@ -557,7 +530,8 @@ AuthenticationClient::Impl::ParseTimeResponse(std::stringstream& payload) {
557530
return timestamp_it->value.GetUint();
558531
}
559532

560-
client::CancellationToken AuthenticationClient::Impl::GetTime(TimeCallback callback) {
533+
client::CancellationToken AuthenticationClient::Impl::GetTime(
534+
TimeCallback callback) {
561535
if (settings_.use_system_time) {
562536
callback(
563537
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
@@ -985,8 +959,8 @@ std::string AuthenticationClient::Impl::generateHeader(
985959
const time_t& timestamp) {
986960
std::string uid = generateUid();
987961
const std::string currentTime = std::to_string(timestamp);
988-
const std::string encodedUri = Url::Encode(url);
989-
const std::string encodedQuery = Url::Encode(
962+
const std::string encodedUri = utils::Url::Encode(url);
963+
const std::string encodedQuery = utils::Url::Encode(
990964
kOauthConsumerKey + kParamEquals + credentials.GetKey() + kParamAdd +
991965
kOauthNonce + kParamEquals + uid + kParamAdd + kOauthSignatureMethod +
992966
kParamEquals + kHmac + kParamAdd + kOauthTimestamp + kParamEquals +
@@ -998,14 +972,14 @@ std::string AuthenticationClient::Impl::generateHeader(
998972
auto signature = base64Encode(hmacResult);
999973
std::string authorization =
1000974
"OAuth " + kOauthConsumerKey + kParamEquals + kParamQuote +
1001-
Url::Encode(credentials.GetKey()) + kParamQuote + kParamComma +
1002-
kOauthNonce + kParamEquals + kParamQuote + Url::Encode(uid) +
975+
utils::Url::Encode(credentials.GetKey()) + kParamQuote + kParamComma +
976+
kOauthNonce + kParamEquals + kParamQuote + utils::Url::Encode(uid) +
1003977
kParamQuote + kParamComma + kOauthSignatureMethod + kParamEquals +
1004978
kParamQuote + kHmac + kParamQuote + kParamComma + kOauthTimestamp +
1005-
kParamEquals + kParamQuote + Url::Encode(currentTime) + kParamQuote +
1006-
kParamComma + kOauthVersion + kParamEquals + kParamQuote + kVersion +
1007-
kParamQuote + kParamComma + kOauthSignature + kParamEquals + kParamQuote +
1008-
Url::Encode(signature) + kParamQuote;
979+
kParamEquals + kParamQuote + utils::Url::Encode(currentTime) +
980+
kParamQuote + kParamComma + kOauthVersion + kParamEquals + kParamQuote +
981+
kVersion + kParamQuote + kParamComma + kOauthSignature + kParamEquals +
982+
kParamQuote + utils::Url::Encode(signature) + kParamQuote;
1009983

1010984
return authorization;
1011985
}
@@ -1230,10 +1204,6 @@ std::string AuthenticationClient::Impl::generateUid() {
12301204
}
12311205
}
12321206

1233-
AuthenticationClient::AuthenticationClient(
1234-
const std::string& authenticationServerUrl, size_t tokenCacheLimit)
1235-
: impl_(std::make_unique<Impl>(authenticationServerUrl, tokenCacheLimit)) {}
1236-
12371207
AuthenticationClient::AuthenticationClient(AuthenticationSettings settings)
12381208
: impl_(std::make_unique<Impl>(std::move(settings))) {}
12391209

@@ -1309,19 +1279,5 @@ client::CancellationToken AuthenticationClient::IntrospectApp(
13091279
return impl_->IntrospectApp(std::move(access_token), std::move(callback));
13101280
}
13111281

1312-
void AuthenticationClient::SetNetworkProxySettings(
1313-
const http::NetworkProxySettings& proxy_settings) {
1314-
impl_->SetNetworkProxySettings(proxy_settings);
1315-
}
1316-
1317-
void AuthenticationClient::SetNetwork(std::shared_ptr<http::Network> network) {
1318-
impl_->SetNetwork(network);
1319-
}
1320-
1321-
void AuthenticationClient::SetTaskScheduler(
1322-
std::shared_ptr<TaskScheduler> task_scheduler) {
1323-
impl_->SetTaskScheduler(task_scheduler);
1324-
}
1325-
13261282
} // namespace authentication
13271283
} // namespace olp

scripts/misc/cpplint_ci.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ printf "Installing cpplint using pip\n\n"
4747

4848
pip install --user cpplint
4949

50-
printf "Running cpplint\n\n"
50+
printf "\n\nRunning cpplint\n\n"
5151

5252
# Exclude warning about <future> <mutex> includes
5353
CPPLINT_FILTER="--filter=-build/c++11"
5454

5555
# Run the cpplint tool
56-
cpplint $CPPLINT_FILTER "$FILES"
56+
cpplint $CPPLINT_FILTER $FILES 2> warnigns.txt
57+
58+
printf "\n\nComplete cpplint\n\n"
59+
60+
cat warnigns.txt
5761

5862
# Despite the error found exit without errors.
5963
# Remove this exit to make the script blocking on CI.

tests/functional/olp-cpp-sdk-authentication/AuthenticationClientTest.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -614,19 +614,22 @@ TEST_F(AuthenticationClientTest, SignOutUser) {
614614
EXPECT_STREQ(kErrorNoContent.c_str(), response4.error.c_str());
615615
}
616616

617-
PORTING_PUSH_WARNINGS()
618-
PORTING_CLANG_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
619-
620617
TEST_F(AuthenticationClientTest, NetworkProxySettings) {
621618
AuthenticationCredentials credentials(id_, secret_);
622619

620+
AuthenticationSettings settings;
621+
settings.network_request_handler = network_;
622+
settings.task_scheduler = task_scheduler_;
623+
settings.token_endpoint_url = kHereAccountStagingURL;
624+
623625
auto proxy_settings = olp::http::NetworkProxySettings();
624-
client_->SetNetworkProxySettings(proxy_settings);
625626
proxy_settings.WithHostname("$.?");
626627
proxy_settings.WithPort(42);
627628
proxy_settings.WithType(olp::http::NetworkProxySettings::Type::SOCKS4);
629+
settings.network_proxy_settings = proxy_settings;
630+
631+
auto client = std::make_unique<AuthenticationClient>(settings);
628632

629-
client_->SetNetworkProxySettings(proxy_settings);
630633
std::time_t now;
631634
auto response = SignInClient(credentials, now, kExpiryTime);
632635
// Bad proxy error code and message varies by platform
@@ -636,8 +639,6 @@ TEST_F(AuthenticationClientTest, NetworkProxySettings) {
636639
EXPECT_STRNE(response.GetError().GetMessage().c_str(), kErrorOk.c_str());
637640
}
638641

639-
PORTING_POP_WARNINGS()
640-
641642
TEST_F(AuthenticationClientTest, ErrorFields) {
642643
static const std::string PASSWORD = "password";
643644
static const std::string EMAIL = "email";

0 commit comments

Comments
 (0)