Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 75547b0

Browse files
Avoiding duplicated code between Authorize token and Refresh token
1 parent 52c8e70 commit 75547b0

4 files changed

Lines changed: 34 additions & 48 deletions

File tree

src/main/java/com/venafi/vcert/sdk/connectors/tpp/AuthorizeTokenResponse.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,8 @@
55
import lombok.Data;
66

77
@Data
8-
public class AuthorizeTokenResponse {
9-
10-
@SerializedName("access_token")
11-
private String accessToken;
12-
13-
@SerializedName("refresh_token")
14-
private String refreshToken;
15-
16-
@SerializedName("expires")
17-
private long expire;
18-
19-
@SerializedName("token_type")
20-
private String tokenType;
21-
22-
@SerializedName("scope")
23-
private String scope;
8+
public class AuthorizeTokenResponse extends TokenResponse {
249

2510
@SerializedName("identity")
2611
private String identity;
27-
28-
@SerializedName("refresh_until")
29-
private long refreshUntil;
30-
3112
}
Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
11
package com.venafi.vcert.sdk.connectors.tpp;
22

3-
import com.google.gson.annotations.SerializedName;
4-
5-
import lombok.Data;
6-
7-
@Data
8-
public class RefreshTokenResponse {
9-
10-
@SerializedName("access_token")
11-
private String accessToken;
12-
13-
@SerializedName("refresh_token")
14-
private String refreshToken;
15-
16-
@SerializedName("expires")
17-
private long expire;
18-
19-
@SerializedName("token_type")
20-
private String tokenType;
21-
22-
@SerializedName("scope")
23-
private String scope;
24-
25-
@SerializedName("refresh_until")
26-
private long refreshUntil;
3+
public class RefreshTokenResponse extends TokenResponse {
274
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.venafi.vcert.sdk.connectors.tpp;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
5+
import lombok.Data;
6+
7+
@Data
8+
public class TokenResponse {
9+
10+
@SerializedName("access_token")
11+
private String accessToken;
12+
13+
@SerializedName("refresh_token")
14+
private String refreshToken;
15+
16+
@SerializedName("expires")
17+
private long expire;
18+
19+
@SerializedName("token_type")
20+
private String tokenType;
21+
22+
@SerializedName("scope")
23+
private String scope;
24+
25+
@SerializedName("refresh_until")
26+
private long refreshUntil;
27+
}

src/test/java/com/venafi/vcert/sdk/connectors/tpp/TppTokenConnectorTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ public class TppTokenConnectorTest {
6565
@BeforeEach
6666
void setUp() throws VCertException {
6767
this.classUnderTest = new TppTokenConnector(tpp);
68-
69-
AuthorizeTokenResponse response =
70-
new AuthorizeTokenResponse().accessToken(ACCESS_TOKEN).
71-
refreshToken(REFRESH_TOKEN);
68+
69+
AuthorizeTokenResponse response = new AuthorizeTokenResponse();
70+
71+
response.accessToken(ACCESS_TOKEN).refreshToken(REFRESH_TOKEN);
72+
7273
when(tpp.authorizeToken(any(TppTokenConnector.AuthorizeTokenRequest.class))).thenReturn(response);
7374

7475
Authentication authentication = Authentication.builder().user("user").password("pass").build();

0 commit comments

Comments
 (0)