Skip to content

Commit 90493b5

Browse files
committed
SDK-2771: Rename some internal methods createSignedRequest->createRequest
1 parent d986e81 commit 90493b5

File tree

8 files changed

+33
-34
lines changed

8 files changed

+33
-34
lines changed

yoti-sdk-api/src/main/java/com/yoti/api/client/spi/remote/call/ProfileService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public ProfileResponse getProfile(KeyPair keyPair, String connectToken) throws P
6666

6767
try {
6868
String authKey = Base64.getEncoder().encodeToString(keyPair.getPublic().getEncoded());
69-
YotiHttpRequest yotiHttpRequest = createSignedRequest(path, authKey);
69+
YotiHttpRequest yotiHttpRequest = createRequest(path, authKey);
7070
return fetchReceipt(yotiHttpRequest);
7171
} catch (IOException ioe) {
7272
throw new ProfileException("Error calling service to get profile", ioe);
@@ -91,7 +91,7 @@ private ProfileResponse fetchReceipt(YotiHttpRequest yotiHttpRequest) throws IOE
9191
}
9292
}
9393

94-
YotiHttpRequest createSignedRequest(String path, String authKey) throws ProfileException {
94+
YotiHttpRequest createRequest(String path, String authKey) throws ProfileException {
9595
try {
9696
return yotiHttpRequestBuilderFactory.create()
9797
.withAuthStrategy(profileSignedRequestStrategy)

yoti-sdk-api/src/main/java/com/yoti/api/client/spi/remote/call/aml/RemoteAmlService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public AmlResult performCheck(AmlProfile amlProfile) throws AmlException {
6363
String resourcePath = unsignedPathFactory.createAmlPath();
6464
byte[] body = objectMapper.writeValueAsString(amlProfile).getBytes(DEFAULT_CHARSET);
6565

66-
YotiHttpRequest yotiHttpRequest = createSignedRequest(resourcePath, body);
66+
YotiHttpRequest yotiHttpRequest = createRequest(resourcePath, body);
6767
return yotiHttpRequest.execute(AmlResult.class);
6868
} catch (IOException ioException) {
6969
throw new AmlException("Error communicating with AML endpoint", ioException);
@@ -85,7 +85,7 @@ private AmlException createExceptionFromStatusCode(ResourceException ex) {
8585
}
8686
}
8787

88-
YotiHttpRequest createSignedRequest(String resourcePath, byte[] body) throws AmlException {
88+
YotiHttpRequest createRequest(String resourcePath, byte[] body) throws AmlException {
8989
try {
9090
return yotiHttpRequestBuilderFactory.create()
9191
.withAuthStrategy(amlSignedRequestStrategy)

yoti-sdk-api/src/main/java/com/yoti/api/client/spi/remote/call/identity/DigitalIdentityService.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public ShareSession createShareSession(ShareSessionRequest shareSessionRequest)
7272

7373
try {
7474
byte[] payload = ResourceMapper.writeValueAsString(shareSessionRequest);
75-
return createSignedRequest(path, HTTP_POST, payload).execute(ShareSession.class);
75+
return createRequest(path, HTTP_POST, payload).execute(ShareSession.class);
7676
} catch (IOException ex) {
7777
throw new DigitalIdentityException("Error while parsing the share session creation request ", ex);
7878
} catch (URISyntaxException ex) {
@@ -90,7 +90,7 @@ public ShareSession fetchShareSession(String sessionId) throws DigitalIdentityEx
9090
LOG.debug("Requesting share session '{}' at '{}'", sessionId, path);
9191

9292
try {
93-
return createSignedRequest(path).execute(ShareSession.class);
93+
return createRequest(path).execute(ShareSession.class);
9494
} catch (Exception ex) {
9595
throw new DigitalIdentityException(
9696
String.format("Error while fetching the share session '{%s}' ", sessionId),
@@ -107,7 +107,7 @@ public ShareSessionQrCode createShareQrCode(String sessionId) throws DigitalIden
107107
LOG.debug("Requesting share session '{}' QR code creation at '{}'", sessionId, path);
108108

109109
try {
110-
return createSignedRequest(path, HTTP_POST, EMPTY_JSON).execute(ShareSessionQrCode.class);
110+
return createRequest(path, HTTP_POST, EMPTY_JSON).execute(ShareSessionQrCode.class);
111111
} catch (GeneralSecurityException ex) {
112112
throw new DigitalIdentityException("Error while signing the share QR code creation request ", ex);
113113
} catch (IOException | URISyntaxException | ResourceException ex) {
@@ -123,7 +123,7 @@ public ShareSessionQrCode fetchShareQrCode(String qrCodeId) throws DigitalIdenti
123123
LOG.debug("Requesting share session QR code '{} at '{}'", qrCodeId, path);
124124

125125
try {
126-
return createSignedRequest(path).execute(ShareSessionQrCode.class);
126+
return createRequest(path).execute(ShareSessionQrCode.class);
127127
} catch (Exception ex) {
128128
throw new DigitalIdentityException(
129129
String.format("Error while fetching the share session QR code '{%s}' ", qrCodeId),
@@ -149,7 +149,7 @@ private WrappedReceipt doFetchShareReceipt(String receiptId) {
149149
LOG.debug("Requesting share session receipt '{}' at '{}'", receiptId, path);
150150

151151
try {
152-
return createSignedRequest(path).execute(WrappedReceipt.class);
152+
return createRequest(path).execute(WrappedReceipt.class);
153153
} catch (Exception ex) {
154154
throw new DigitalIdentityException(
155155
String.format("Error while fetching the share session QR code '{%s}' ", receiptId),
@@ -164,7 +164,7 @@ private ReceiptItemKey fetchShareReceiptKey(WrappedReceipt wrappedReceipt) throw
164164
LOG.debug("Requesting share session receipt item key '{}' at '{}'", wrappedItemKeyId, path);
165165

166166
try {
167-
return createSignedRequest(path).execute(ReceiptItemKey.class);
167+
return createRequest(path).execute(ReceiptItemKey.class);
168168
} catch (Exception ex) {
169169
throw new DigitalIdentityException(
170170
String.format("Error while fetching the share session receipt key '{%s}' ", wrappedItemKeyId),
@@ -180,7 +180,7 @@ public MatchResult fetchMatch(MatchRequest matchRequest) throws DigitalIdentityE
180180

181181
try {
182182
byte[] payload = ResourceMapper.writeValueAsString(matchRequest);
183-
return createSignedRequest(path, HTTP_POST, payload).execute(MatchResult.class);
183+
return createRequest(path, HTTP_POST, payload).execute(MatchResult.class);
184184
} catch (IOException ex) {
185185
throw new DigitalIdentityException("Error while parsing the DID Match request", ex);
186186
} catch (URISyntaxException ex) {
@@ -192,11 +192,11 @@ public MatchResult fetchMatch(MatchRequest matchRequest) throws DigitalIdentityE
192192
}
193193
}
194194

195-
YotiHttpRequest createSignedRequest(String path) throws GeneralSecurityException, UnsupportedEncodingException, URISyntaxException {
196-
return createSignedRequest(path, HTTP_GET, null);
195+
YotiHttpRequest createRequest(String path) throws GeneralSecurityException, UnsupportedEncodingException, URISyntaxException {
196+
return createRequest(path, HTTP_GET, null);
197197
}
198198

199-
YotiHttpRequest createSignedRequest(String path, String method, byte[] payload)
199+
YotiHttpRequest createRequest(String path, String method, byte[] payload)
200200
throws GeneralSecurityException, UnsupportedEncodingException, URISyntaxException {
201201
YotiHttpRequestBuilder request = requestBuilderFactory.create()
202202
.withAuthStrategy(authStrategy)

yoti-sdk-api/src/main/java/com/yoti/api/client/spi/remote/call/qrcode/DynamicSharingService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public ShareUrlResult createShareUrl(String appId, DynamicScenario dynamicScenar
6666
try {
6767
byte[] body = objectMapper.writeValueAsString(dynamicScenario).getBytes(DEFAULT_CHARSET);
6868

69-
YotiHttpRequest yotiHttpRequest = createSignedRequest(path, body);
69+
YotiHttpRequest yotiHttpRequest = createRequest(path, body);
7070

7171
return yotiHttpRequest.execute(ShareUrlResult.class);
7272
} catch (ResourceException ex) {
@@ -76,7 +76,7 @@ public ShareUrlResult createShareUrl(String appId, DynamicScenario dynamicScenar
7676
}
7777
}
7878

79-
YotiHttpRequest createSignedRequest(String path, byte[] body) throws DynamicShareException {
79+
YotiHttpRequest createRequest(String path, byte[] body) throws DynamicShareException {
8080
try {
8181
return yotiHttpRequestBuilderFactory.create()
8282
.withAuthStrategy(simpleSignedRequestStrategy)

yoti-sdk-api/src/test/java/com/yoti/api/client/spi/remote/call/ProfileServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void setUp() {
6262

6363
@Test
6464
public void shouldReturnReceiptForCorrectRequest() throws Exception {
65-
doReturn(yotiHttpRequest).when(testObj).createSignedRequest(GENERATED_PROFILE_PATH, B64_PUBLIC_KEY);
65+
doReturn(yotiHttpRequest).when(testObj).createRequest(GENERATED_PROFILE_PATH, B64_PUBLIC_KEY);
6666
when(yotiHttpRequest.execute(ProfileResponse.class)).thenReturn(PROFILE_RESPONSE);
6767

6868
Receipt result = testObj.getReceipt(KEY_PAIR, TOKEN);
@@ -73,7 +73,7 @@ public void shouldReturnReceiptForCorrectRequest() throws Exception {
7373
@Test
7474
public void shouldThrowExceptionForIOError() throws Exception {
7575
IOException ioException = new IOException("Test exception");
76-
doReturn(yotiHttpRequest).when(testObj).createSignedRequest(GENERATED_PROFILE_PATH, B64_PUBLIC_KEY);
76+
doReturn(yotiHttpRequest).when(testObj).createRequest(GENERATED_PROFILE_PATH, B64_PUBLIC_KEY);
7777
when(yotiHttpRequest.execute(ProfileResponse.class)).thenThrow(ioException);
7878

7979
try {
@@ -87,7 +87,7 @@ public void shouldThrowExceptionForIOError() throws Exception {
8787
@Test
8888
public void shouldThrowExceptionWithResourceExceptionCause() throws Throwable {
8989
ResourceException resourceException = new ResourceException(404, "Not Found", "Test exception");
90-
doReturn(yotiHttpRequest).when(testObj).createSignedRequest(GENERATED_PROFILE_PATH, B64_PUBLIC_KEY);
90+
doReturn(yotiHttpRequest).when(testObj).createRequest(GENERATED_PROFILE_PATH, B64_PUBLIC_KEY);
9191
when(yotiHttpRequest.execute(ProfileResponse.class)).thenThrow(resourceException);
9292

9393
try {

yoti-sdk-api/src/test/java/com/yoti/api/client/spi/remote/call/aml/RemoteAmlServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void setUp() {
5959
@Test
6060
public void shouldPerformAmlCheck() throws Exception {
6161
when(objectMapperMock.writeValueAsString(amlProfileMock)).thenReturn(SERIALIZED_BODY);
62-
doReturn(yotiHttpRequestMock).when(testObj).createSignedRequest(GENERATED_PATH, BODY_BYTES);
62+
doReturn(yotiHttpRequestMock).when(testObj).createRequest(GENERATED_PATH, BODY_BYTES);
6363
when(yotiHttpRequestMock.execute(AmlResult.class)).thenReturn(amlResultMock);
6464

6565
AmlResult result = testObj.performCheck(amlProfileMock);
@@ -71,7 +71,7 @@ public void shouldPerformAmlCheck() throws Exception {
7171
public void shouldWrapIOException() throws Exception {
7272
IOException ioException = new IOException();
7373
when(objectMapperMock.writeValueAsString(amlProfileMock)).thenReturn(SERIALIZED_BODY);
74-
doReturn(yotiHttpRequestMock).when(testObj).createSignedRequest(GENERATED_PATH, BODY_BYTES);
74+
doReturn(yotiHttpRequestMock).when(testObj).createRequest(GENERATED_PATH, BODY_BYTES);
7575
when(yotiHttpRequestMock.execute(AmlResult.class)).thenThrow(ioException);
7676

7777
try {
@@ -86,7 +86,7 @@ public void shouldWrapIOException() throws Exception {
8686
public void shouldWrapResourceException() throws Exception {
8787
ResourceException resourceException = new ResourceException(HTTP_UNAUTHORIZED, "Unauthorized", "failed verification");
8888
when(objectMapperMock.writeValueAsString(amlProfileMock)).thenReturn(SERIALIZED_BODY);
89-
doReturn(yotiHttpRequestMock).when(testObj).createSignedRequest(GENERATED_PATH, BODY_BYTES);
89+
doReturn(yotiHttpRequestMock).when(testObj).createRequest(GENERATED_PATH, BODY_BYTES);
9090
when(yotiHttpRequestMock.execute(AmlResult.class)).thenThrow(resourceException);
9191

9292
try {

yoti-sdk-api/src/test/java/com/yoti/api/client/spi/remote/call/identity/DigitalIdentityServiceTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.yoti.api.client.spi.remote.call.YotiHttpRequest;
2222
import com.yoti.api.client.spi.remote.call.YotiHttpRequestBuilder;
2323
import com.yoti.api.client.spi.remote.call.YotiHttpRequestBuilderFactory;
24-
import com.yoti.api.client.spi.remote.call.factory.DigitalIdentitySignedRequestStrategy;
2524
import com.yoti.api.client.spi.remote.call.factory.UnsignedPathFactory;
2625
import com.yoti.json.ResourceMapper;
2726

@@ -99,7 +98,7 @@ public void createShareSession_BuildingRequestWithWrongUri_Exception() throws Ex
9998

10099
String exMessage = "URI wrong format";
101100
URISyntaxException causeEx = new URISyntaxException("", exMessage);
102-
when(testObj.createSignedRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
101+
when(testObj.createRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
103102

104103
DigitalIdentityException ex = assertThrows(
105104
DigitalIdentityException.class,
@@ -119,7 +118,7 @@ public void createShareSession_BuildingRequestWithWrongQueryParams_Exception() t
119118

120119
String exMessage = "Wrong query params format";
121120
UnsupportedEncodingException causeEx = new UnsupportedEncodingException(exMessage);
122-
when(testObj.createSignedRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
121+
when(testObj.createRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
123122

124123
DigitalIdentityException ex = assertThrows(
125124
DigitalIdentityException.class,
@@ -139,7 +138,7 @@ public void createShareSession_BuildingRequestWithWrongDigest_Exception() throws
139138

140139
String exMessage = "Wrong digest";
141140
GeneralSecurityException causeEx = new GeneralSecurityException(exMessage);
142-
when(testObj.createSignedRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
141+
when(testObj.createRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
143142

144143
DigitalIdentityException ex = assertThrows(
145144
DigitalIdentityException.class,
@@ -157,7 +156,7 @@ public void createShareSession_SessionRequest_exception() throws Exception {
157156
try (MockedStatic<ResourceMapper> mapper = Mockito.mockStatic(ResourceMapper.class)) {
158157
mapper.when(() -> ResourceMapper.writeValueAsString(shareSessionRequest)).thenReturn(A_BODY_BYTES);
159158

160-
when(testObj.createSignedRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenReturn(yotiHttpRequest);
159+
when(testObj.createRequest(SESSION_CREATION_PATH, POST, A_BODY_BYTES)).thenReturn(yotiHttpRequest);
161160
when(yotiHttpRequest.execute(ShareSession.class)).thenReturn(shareSession);
162161

163162
ShareSession result = testObj.createShareSession(shareSessionRequest);
@@ -221,7 +220,7 @@ public void fetchMatch_BuildingRequestWithWrongEndpoint_Exception() throws Excep
221220

222221
String exMessage = "URI wrong format";
223222
URISyntaxException causeEx = new URISyntaxException("", exMessage);
224-
when(testObj.createSignedRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
223+
when(testObj.createRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES)).thenThrow(causeEx);
225224

226225
DigitalIdentityException ex = assertThrows(
227226
DigitalIdentityException.class,
@@ -241,7 +240,7 @@ public void fetchMatch_BuildingRequestWithWrongQueryParams_Exception() throws Ex
241240

242241
String exMessage = "Wrong query params format";
243242
UnsupportedEncodingException causeEx = new UnsupportedEncodingException(exMessage);
244-
when(testObj.createSignedRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES))
243+
when(testObj.createRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES))
245244
.thenThrow(causeEx);
246245

247246
DigitalIdentityException ex = assertThrows(
@@ -262,7 +261,7 @@ public void fetchMatch_BuildingRequestWithWrongDigest_Exception() throws Excepti
262261

263262
String exMessage = "Wrong digest";
264263
GeneralSecurityException causeEx = new GeneralSecurityException(exMessage);
265-
when(testObj.createSignedRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES))
264+
when(testObj.createRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES))
266265
.thenThrow(causeEx);
267266

268267
DigitalIdentityException ex = assertThrows(
@@ -281,7 +280,7 @@ public void fetchMatch_SessionRequest_exception() throws Exception {
281280
try (MockedStatic<ResourceMapper> mapper = Mockito.mockStatic(ResourceMapper.class)) {
282281
mapper.when(() -> ResourceMapper.writeValueAsString(matchRequest)).thenReturn(A_BODY_BYTES);
283282

284-
when(testObj.createSignedRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES))
283+
when(testObj.createRequest(DIGITAL_ID_MATCH_PATH, POST, A_BODY_BYTES))
285284
.thenReturn(yotiHttpRequest);
286285
when(yotiHttpRequest.execute(MatchResult.class)).thenReturn(matchResult);
287286

yoti-sdk-api/src/test/java/com/yoti/api/client/spi/remote/call/qrcode/DynamicSharingServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void shouldThrowDynamicShareExceptionWhenParsingFails() throws Exception
8585
public void shouldThrowExceptionForIOError() throws Exception {
8686
when(objectMapperMock.writeValueAsString(simpleDynamicScenarioMock)).thenReturn(SOME_BODY);
8787
IOException ioException = new IOException();
88-
doReturn(yotiHttpRequestMock).when(testObj).createSignedRequest(DYNAMIC_QRCODE_PATH, SOME_BODY_BYTES);
88+
doReturn(yotiHttpRequestMock).when(testObj).createRequest(DYNAMIC_QRCODE_PATH, SOME_BODY_BYTES);
8989
when(yotiHttpRequestMock.execute(ShareUrlResult.class)).thenThrow(ioException);
9090

9191
try {
@@ -100,7 +100,7 @@ public void shouldThrowExceptionForIOError() throws Exception {
100100
public void shouldThrowExceptionWithResourceExceptionCause() throws Exception {
101101
when(objectMapperMock.writeValueAsString(simpleDynamicScenarioMock)).thenReturn(SOME_BODY);
102102
ResourceException resourceException = new ResourceException(404, "Not Found", "Test exception");
103-
doReturn(yotiHttpRequestMock).when(testObj).createSignedRequest(DYNAMIC_QRCODE_PATH, SOME_BODY_BYTES);
103+
doReturn(yotiHttpRequestMock).when(testObj).createRequest(DYNAMIC_QRCODE_PATH, SOME_BODY_BYTES);
104104
when(yotiHttpRequestMock.execute(ShareUrlResult.class)).thenThrow(resourceException);
105105

106106
try {
@@ -114,7 +114,7 @@ public void shouldThrowExceptionWithResourceExceptionCause() throws Exception {
114114
@Test
115115
public void shouldReturnReceiptForCorrectRequest() throws Exception {
116116
when(objectMapperMock.writeValueAsString(simpleDynamicScenarioMock)).thenReturn(SOME_BODY);
117-
doReturn(yotiHttpRequestMock).when(testObj).createSignedRequest(DYNAMIC_QRCODE_PATH, SOME_BODY_BYTES);
117+
doReturn(yotiHttpRequestMock).when(testObj).createRequest(DYNAMIC_QRCODE_PATH, SOME_BODY_BYTES);
118118
when(yotiHttpRequestMock.execute(ShareUrlResult.class)).thenReturn(shareUrlResultMock);
119119

120120
ShareUrlResult result = testObj.createShareUrl(APP_ID, simpleDynamicScenarioMock);

0 commit comments

Comments
 (0)