Skip to content

Commit c4521a4

Browse files
authored
Replace SignatureUtils#hashAndSign deprecated calls in LoginServiceTests (#618)
1 parent 29bfd81 commit c4521a4

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file.
1818
- Reorder `static` and `final` keywords. (#614)
1919
- Improve code maintainability in test classes. (#615)
2020
- Resolve deprecations caused by `TaskDescription` in `AppComputeService`, `TaskManagerService`, and `ResultService`. (#616)
21+
- Replace `SignatureUtils#hashAndSign` deprecated calls in `LoginServiceTests`. (#618)
2122

2223
### Dependency Upgrades
2324

src/test/java/com/iexec/worker/feign/LoginServiceTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private Credentials generateCredentials() {
7272

7373
@Test
7474
void shouldNotLoginOnBadChallengeStatusCode() {
75-
Credentials credentials = generateCredentials();
75+
final Credentials credentials = generateCredentials();
7676
when(coreClient.getChallenge(credentials.getAddress())).thenThrow(FeignException.class);
7777
assertAll(
7878
() -> assertEquals("", loginService.login()),
@@ -83,8 +83,8 @@ void shouldNotLoginOnBadChallengeStatusCode() {
8383
@ParameterizedTest
8484
@NullSource
8585
@ValueSource(strings = "")
86-
void shouldNotLoginOnEmptyChallenge(String challenge) {
87-
Credentials credentials = generateCredentials();
86+
void shouldNotLoginOnEmptyChallenge(final String challenge) {
87+
final Credentials credentials = generateCredentials();
8888
when(coreClient.getChallenge(credentials.getAddress())).thenReturn(challenge);
8989
assertAll(
9090
() -> assertEquals("", loginService.login()),
@@ -94,9 +94,9 @@ void shouldNotLoginOnEmptyChallenge(String challenge) {
9494

9595
@Test
9696
void shouldNotLoginOnBadLoginStatusCode() {
97-
Credentials credentials = generateCredentials();
97+
final Credentials credentials = generateCredentials();
9898
when(coreClient.getChallenge(credentials.getAddress())).thenReturn("challenge");
99-
Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getAddress(), credentials.getEcKeyPair());
99+
final Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getEcKeyPair());
100100
when(coreClient.login(credentials.getAddress(), signature)).thenThrow(FeignException.class);
101101
assertAll(
102102
() -> assertEquals("", loginService.login()),
@@ -108,10 +108,10 @@ void shouldNotLoginOnBadLoginStatusCode() {
108108
@NullSource
109109
@ValueSource(strings = "")
110110
@ParameterizedTest
111-
void shouldNotLoginOnEmptyToken(String token) {
112-
Credentials credentials = generateCredentials();
111+
void shouldNotLoginOnEmptyToken(final String token) {
112+
final Credentials credentials = generateCredentials();
113113
when(coreClient.getChallenge(credentials.getAddress())).thenReturn("challenge");
114-
Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getAddress(), credentials.getEcKeyPair());
114+
final Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getEcKeyPair());
115115
when(coreClient.login(credentials.getAddress(), signature)).thenReturn(token);
116116
assertAll(
117117
() -> assertEquals("", loginService.login()),
@@ -122,9 +122,9 @@ void shouldNotLoginOnEmptyToken(String token) {
122122

123123
@Test
124124
void shouldLogin() {
125-
Credentials credentials = generateCredentials();
125+
final Credentials credentials = generateCredentials();
126126
when(coreClient.getChallenge(credentials.getAddress())).thenReturn("challenge");
127-
Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getAddress(), credentials.getEcKeyPair());
127+
final Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getEcKeyPair());
128128
when(coreClient.login(credentials.getAddress(), signature)).thenReturn("token");
129129
assertAll(
130130
() -> assertEquals(TOKEN_PREFIX + "token", loginService.login()),
@@ -143,7 +143,7 @@ void shouldLogin() {
143143
* </ul>
144144
*/
145145
@Test
146-
void shouldLoginOnceOnSimultaneousCalls(CapturedOutput output)
146+
void shouldLoginOnceOnSimultaneousCalls(final CapturedOutput output)
147147
throws InterruptedException,
148148
ExecutionException,
149149
TimeoutException {
@@ -164,7 +164,7 @@ void shouldLoginOnceOnSimultaneousCalls(CapturedOutput output)
164164

165165
final Credentials credentials = generateCredentials();
166166
when(coreClient.getChallenge(credentials.getAddress())).thenReturn("challenge");
167-
final Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getAddress(), credentials.getEcKeyPair());
167+
final Signature signature = SignatureUtils.hashAndSign("challenge", credentials.getEcKeyPair());
168168
when(coreClient.login(credentials.getAddress(), signature))
169169
.then(waitForOtherThreads)
170170
.thenReturn("token");

0 commit comments

Comments
 (0)