Skip to content

Commit 6f4f61a

Browse files
Remove deprecated SignInClient method. (#708)
Relates-To: OLPEDGE-1662 Signed-off-by: Mykhailo Kuchma <[email protected]>
1 parent 29d9a23 commit 6f4f61a

File tree

6 files changed

+58
-80
lines changed

6 files changed

+58
-80
lines changed

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

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -328,33 +328,6 @@ class AUTHENTICATION_API AuthenticationClient {
328328
using SignOutUserCallback =
329329
std::function<void(const SignOutUserResponse& response)>;
330330

331-
/**
332-
* @brief Deprecated. Use the `SignInClient` method that has the `properties`
333-
* parameter.
334-
*
335-
* Signs in with your HERE Account client credentials. Requests the client
336-
* access token. Client access tokens cannot be refreshed. Instead,
337-
* request a new client access token using your client credentials.
338-
*
339-
* @param credentials The `AuthenticationCredentials` instance.
340-
* @param callback The`SignInClientCallback` method that is called when
341-
* the client sign-in request is completed. If successful, the returned HTTP
342-
* status is 200. Otherwise, check the response error.
343-
* @param expires_in (Optional) The number of seconds left before the access
344-
* token expires. Ignored if it is zero or greater than the default expiration
345-
* time supported by the application.
346-
*
347-
* @return The `CancellationToken` instance that can be used to cancel
348-
* the equest.
349-
*/
350-
OLP_SDK_DEPRECATED(
351-
"Deprecated. Please use version with properties parameter. Will be "
352-
"removed by 03.2020")
353-
client::CancellationToken SignInClient(
354-
const AuthenticationCredentials& credentials,
355-
const SignInClientCallback& callback,
356-
const std::chrono::seconds& expires_in = std::chrono::seconds(0));
357-
358331
/**
359332
* @brief Signs in with your HERE Account client credentials and reuests
360333
* the client access token.

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1232,15 +1232,6 @@ AuthenticationClient::AuthenticationClient(AuthenticationSettings settings)
12321232

12331233
AuthenticationClient::~AuthenticationClient() = default;
12341234

1235-
client::CancellationToken AuthenticationClient::SignInClient(
1236-
const AuthenticationCredentials& credentials,
1237-
const SignInClientCallback& callback,
1238-
const std::chrono::seconds& expires_in) {
1239-
SignInProperties properties;
1240-
properties.expires_in = expires_in;
1241-
return impl_->SignInClient(credentials, properties, callback);
1242-
}
1243-
12441235
client::CancellationToken AuthenticationClient::SignInClient(
12451236
AuthenticationCredentials credentials, SignInProperties properties,
12461237
SignInClientCallback callback) {

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,27 +37,30 @@ constexpr auto kLogTag = "here::account::oauth2::TokenEndpoint";
3737

3838
namespace olp {
3939
namespace authentication {
40+
41+
namespace {
42+
AuthenticationSettings ConvertSettings(Settings settings) {
43+
AuthenticationSettings auth_settings;
44+
auth_settings.network_proxy_settings = settings.network_proxy_settings;
45+
auth_settings.task_scheduler = settings.task_scheduler;
46+
auth_settings.network_request_handler = settings.network_request_handler;
47+
auth_settings.token_endpoint_url = settings.token_endpoint_url;
48+
return auth_settings;
49+
}
50+
51+
} // namespace
52+
4053
struct TokenEndpoint::Impl {
4154
explicit Impl(Settings settings)
42-
: auth_client_(std::move(settings.token_endpoint_url)),
43-
auth_credentials_(std::move(settings.credentials)) {
44-
PORTING_PUSH_WARNINGS()
45-
PORTING_CLANG_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
46-
if (settings.network_proxy_settings) {
47-
auth_client_.SetNetworkProxySettings(
48-
settings.network_proxy_settings.get());
49-
}
50-
auth_client_.SetNetwork(std::move(settings.network_request_handler));
51-
auth_client_.SetTaskScheduler(std::move(settings.task_scheduler));
52-
PORTING_POP_WARNINGS()
53-
}
55+
: auth_client_(ConvertSettings(settings)),
56+
auth_credentials_(std::move(settings.credentials)) {}
5457

55-
PORTING_PUSH_WARNINGS()
56-
PORTING_CLANG_GCC_DISABLE_WARNING("-Wdeprecated-declarations")
5758
client::CancellationToken RequestToken(const TokenRequest& token_request,
5859
const RequestTokenCallback& callback) {
60+
AuthenticationClient::SignInProperties properties;
61+
properties.expires_in = token_request.GetExpiresIn();
5962
return auth_client_.SignInClient(
60-
auth_credentials_,
63+
auth_credentials_, properties,
6164
[callback](
6265
const AuthenticationClient::SignInClientResponse& signInResponse) {
6366
if (signInResponse.IsSuccessful()) {
@@ -69,8 +72,7 @@ struct TokenEndpoint::Impl {
6972
} else {
7073
callback(signInResponse.GetError());
7174
}
72-
},
73-
token_request.GetExpiresIn());
75+
});
7476
}
7577

7678
std::future<TokenResponse> RequestToken(
@@ -132,7 +134,6 @@ AutoRefreshingToken TokenEndpoint::RequestAutoRefreshingToken(
132134
const TokenRequest& token_request) {
133135
return AutoRefreshingToken(*this, token_request);
134136
}
135-
PORTING_POP_WARNINGS()
136137

137138
} // namespace authentication
138139
} // namespace olp

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,12 +55,15 @@ class AuthenticationClientTest : public AuthenticationCommonTestFixture {
5555
auto request_future = request.get_future();
5656

5757
now = std::time(nullptr);
58+
59+
AuthenticationClient::SignInProperties props;
60+
props.expires_in = std::chrono::seconds(expires_in);
61+
5862
auto cancel_token = client_->SignInClient(
59-
credentials,
63+
credentials, props,
6064
[&](const AuthenticationClient::SignInClientResponse& resp) {
6165
request.set_value(resp);
62-
},
63-
std::chrono::seconds(expires_in));
66+
});
6467

6568
if (do_cancel) {
6669
cancel_token.Cancel();

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,12 +69,15 @@ TEST_F(AuthenticationProductionTest, SignInClient) {
6969
CustomParameters::getArgument("production_service_secret"));
7070
std::promise<AuthenticationClient::SignInClientResponse> request;
7171
auto request_future = request.get_future();
72+
73+
AuthenticationClient::SignInProperties props_1;
74+
props_1.expires_in = std::chrono::seconds(kExpiryTime);
75+
7276
client_->SignInClient(
73-
credentials,
77+
credentials, props_1,
7478
[&](const AuthenticationClient::SignInClientResponse& response) {
7579
request.set_value(response);
76-
},
77-
std::chrono::seconds(kExpiryTime));
80+
});
7881

7982
AuthenticationClient::SignInClientResponse response = request_future.get();
8083
std::time_t now = std::time(nullptr);
@@ -92,12 +95,14 @@ TEST_F(AuthenticationProductionTest, SignInClient) {
9295
std::promise<AuthenticationClient::SignInClientResponse> request_2;
9396
now = std::time(nullptr);
9497
auto request_future_2 = request_2.get_future();
98+
99+
AuthenticationClient::SignInProperties props_2;
100+
props_2.expires_in = std::chrono::seconds(kExtendedExpiryTime);
95101
client_->SignInClient(
96-
credentials,
102+
credentials, props_2,
97103
[&](const AuthenticationClient::SignInClientResponse& response) {
98104
request_2.set_value(response);
99-
},
100-
std::chrono::seconds(kExtendedExpiryTime));
105+
});
101106

102107
AuthenticationClient::SignInClientResponse response_2 =
103108
request_future_2.get();
@@ -112,12 +117,14 @@ TEST_F(AuthenticationProductionTest, SignInClient) {
112117
std::promise<AuthenticationClient::SignInClientResponse> request_3;
113118
now = std::time(nullptr);
114119
auto request_future_3 = request_3.get_future();
120+
121+
AuthenticationClient::SignInProperties props_3;
122+
props_3.expires_in = std::chrono::seconds(kCustomExpiryTime);
115123
client_->SignInClient(
116-
credentials,
124+
credentials, props_3,
117125
[&](const AuthenticationClient::SignInClientResponse& response) {
118126
request_3.set_value(response);
119-
},
120-
std::chrono::seconds(kCustomExpiryTime));
127+
});
121128

122129
AuthenticationClient::SignInClientResponse response_3 =
123130
request_future_3.get();
@@ -138,8 +145,9 @@ TEST_F(AuthenticationProductionTest, SignInClientMaxExpiration) {
138145
std::promise<AuthenticationClient::SignInClientResponse> request;
139146
auto request_future = request.get_future();
140147
time_t now = std::time(nullptr);
148+
141149
client_->SignInClient(
142-
credentials,
150+
credentials, {},
143151
[&](const AuthenticationClient::SignInClientResponse& response) {
144152
request.set_value(response);
145153
});
@@ -154,12 +162,14 @@ TEST_F(AuthenticationProductionTest, SignInClientMaxExpiration) {
154162
std::promise<AuthenticationClient::SignInClientResponse> request_2;
155163
auto request_future_2 = request_2.get_future();
156164
now = std::time(nullptr);
165+
166+
AuthenticationClient::SignInProperties props;
167+
props.expires_in = std::chrono::seconds(90000);
157168
client_->SignInClient(
158-
credentials,
169+
credentials, props,
159170
[&](const AuthenticationClient::SignInClientResponse& response) {
160171
request_2.set_value(response);
161-
},
162-
std::chrono::seconds(90000));
172+
});
163173

164174
AuthenticationClient::SignInClientResponse response_2 =
165175
request_future_2.get();
@@ -179,7 +189,7 @@ TEST_F(AuthenticationProductionTest, InvalidCredentials) {
179189
std::promise<AuthenticationClient::SignInClientResponse> request;
180190
auto request_future = request.get_future();
181191
client_->SignInClient(
182-
credentials,
192+
credentials, {},
183193
[&](const AuthenticationClient::SignInClientResponse& response) {
184194
request.set_value(response);
185195
});

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -197,7 +197,7 @@ class AuthenticationClientTest : public ::testing::Test {
197197
});
198198

199199
client_->SignInClient(
200-
credentials,
200+
credentials, {},
201201
[&](const AuthenticationClient::SignInClientResponse& response) {
202202
request.set_value(response);
203203
});
@@ -355,7 +355,7 @@ TEST_F(AuthenticationClientTest, SignInClientData) {
355355

356356
std::time_t now = std::time(nullptr);
357357
client_->SignInClient(
358-
credentials,
358+
credentials, {},
359359
[&](const AuthenticationClient::SignInClientResponse& response) {
360360
request.set_value(response);
361361
});
@@ -375,7 +375,7 @@ TEST_F(AuthenticationClientTest, SignInClientData) {
375375
auto request_future_2 = request_2.get_future();
376376
std::time_t now_2 = std::time(nullptr);
377377
client_->SignInClient(
378-
credentials,
378+
credentials, {},
379379
[&](const AuthenticationClient::SignInClientResponse& response) {
380380
request_2.set_value(response);
381381
});

0 commit comments

Comments
 (0)