diff --git a/README.md b/README.md
index 4067c48..63febb3 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Go to your project's pom.xml file and add as dependency.
com.liveperson.faas
functions-client
- 1.1.6
+ 1.2.2
```
@@ -35,10 +35,9 @@ FaasClient.Builder builder = new FaasWebClient.Builder(accountId);
Furthermore you have to choose a method of authorization.
Either you provide a client secret and client Id, as we use OAuth 2.0 with client credentials by default,
-or you alternatively pass your own implementation of the `AuthSignatureBilder`.
-
-* [More information on Client Credentials](https://developers.liveperson.com/liveperson-functions-external-invocations-client-credentials.html)
+or you alternatively pass your own implementation of the `AuthSignatureBuilder` or `AuthDpopSignatureBuilder`.
+* [More information on Client Credentials](https://developers.liveperson.com/liveperson-functions-foundations-external-invocation.html#authentication)
```java
String clientId = "clientId";
@@ -48,6 +47,9 @@ builder.withClientSecret(clientSecret);
or
AuthSignatureBuilder authSignatureBuilder = new YourAuthSignatureBuilder();
builder.withAuthSignatureBuilder(authSignatureBuider);
+or // Oauth2 + DPoP (only for internal usage)
+AuthDPoPSignatureBuilder authDPoPSignatureBuilder = new YourAuthDPoPSignatureBuilder();
+builder.withAuthDPoPSignatureBuilder(authDPoPSignatureBuilder);
```
This is the bare minimum that has to be provided to build the client.
@@ -56,6 +58,10 @@ This is the bare minimum that has to be provided to build the client.
FaasClient faasClient = builder.build();
```
+### DPoP authorization
+
+The client supports Oauth2+DPoP authorization ONLY FOR INTERNAL USE in service-to-service. You must provide your implementation of the `AuthDPoPSignatureBuilder` during the initialization.
+
### Optional fields for builder
Additionally you can pass your own implementations of specific fields to the builder before building the client.
@@ -139,7 +145,7 @@ optionalParams.setRequestId("requestId");
### Fetching lambdas
-**You have to use your own authentication method when fetching lambdas as it still relies on OAuth 1.0.**
+**You have to use your own authentication method when fetching lambdas as it relies on OAuth 1.0. / Oauth 2.0 + DPoP**
Fetching lambdas of account
diff --git a/src/main/java/com/liveperson/faas/client/FaaSWebClient.java b/src/main/java/com/liveperson/faas/client/FaaSWebClient.java
index 15fa866..86d5175 100644
--- a/src/main/java/com/liveperson/faas/client/FaaSWebClient.java
+++ b/src/main/java/com/liveperson/faas/client/FaaSWebClient.java
@@ -15,11 +15,13 @@
import com.liveperson.faas.metriccollector.MetricCollector;
import com.liveperson.faas.metriccollector.NullMetricCollector;
import com.liveperson.faas.response.lambda.LambdaResponse;
+import com.liveperson.faas.security.AuthDPoPSignatureBuilder;
import com.liveperson.faas.security.AuthSignatureBuilder;
import com.liveperson.faas.security.JwtSignatureBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StopWatch;
import org.springframework.web.util.UriComponents;
@@ -74,6 +76,7 @@ public class FaaSWebClient implements FaaSClient {
private CsdsClient csdsClient;
private RestClient restClient;
private AuthSignatureBuilder authSignatureBuilder;
+ private AuthDPoPSignatureBuilder authDPoPSignatureBuilder;
private MetricCollector metricCollector;
private String accountId;
private IsImplementedCache isImplementedCache;
@@ -82,7 +85,7 @@ private FaaSWebClient() {
}
private static void updateQueryParams(String key, Map newQueryParamsMap,
- UriComponentsBuilder uriComponentsBuilder) {
+ UriComponentsBuilder uriComponentsBuilder) {
String value = newQueryParamsMap.get(key);
if (value != null) {
uriComponentsBuilder.queryParam(key, value);
@@ -91,14 +94,14 @@ private static void updateQueryParams(String key, Map newQueryPa
@Override
public T invokeByUUID(String externalSystem, String lambdaUUID, FaaSInvocation data, Class responseType,
- OptionalParams optionalParams) throws FaaSException {
+ OptionalParams optionalParams) throws FaaSException {
String invokeUri = String.format(FaaSWebClient.INVOKE_UUID_URI, accountId, lambdaUUID);
return invokeWithUri(externalSystem, data, responseType, invokeUri, optionalParams);
}
@Override
public void invokeByUUID(String externalSystem, String lambdaUUID, FaaSInvocation data,
- OptionalParams optionalParams) throws FaaSException {
+ OptionalParams optionalParams) throws FaaSException {
String invokeUri = String.format(FaaSWebClient.INVOKE_UUID_URI, accountId, lambdaUUID);
invokeWithUriNoResponse(externalSystem, data, invokeUri, optionalParams);
@@ -106,45 +109,48 @@ public void invokeByUUID(String externalSystem, String lambdaUUID, FaaSInvocatio
@Override
public T invokeByEvent(String externalSystem, FaaSEvent event, FaaSInvocation data, Class responseType,
- OptionalParams optionalParams) throws FaaSException {
+ OptionalParams optionalParams) throws FaaSException {
String invokeUri = String.format(FaaSWebClient.INVOKE_EVENT_URI, accountId, event);
return invokeWithUri(externalSystem, data, responseType, invokeUri, optionalParams);
}
@Override
public T invokeByEvent(String externalSystem, String event, FaaSInvocation data, Class responseType,
- OptionalParams optionalParams) throws FaaSException {
+ OptionalParams optionalParams) throws FaaSException {
String invokeUri = String.format(FaaSWebClient.INVOKE_EVENT_URI, accountId, event);
return invokeWithUri(externalSystem, data, responseType, invokeUri, optionalParams);
}
@Override
public void invokeByEvent(String externalSystem, FaaSEvent event, FaaSInvocation data,
- OptionalParams optionalParams) throws FaaSException {
+ OptionalParams optionalParams) throws FaaSException {
String invokeUri = String.format(FaaSWebClient.INVOKE_EVENT_URI, accountId, event);
invokeWithUriNoResponse(externalSystem, data, invokeUri, optionalParams);
}
@Override
public void invokeByEvent(String externalSystem, String event, FaaSInvocation data,
- OptionalParams optionalParams) throws FaaSException {
+ OptionalParams optionalParams) throws FaaSException {
String invokeUri = String.format(FaaSWebClient.INVOKE_EVENT_URI, accountId, event);
invokeWithUriNoResponse(externalSystem, data, invokeUri, optionalParams);
}
- public boolean isImplemented(String externalSystem, FaaSEvent event, OptionalParams optionalParams) throws FaaSException {
+ public boolean isImplemented(String externalSystem, FaaSEvent event, OptionalParams optionalParams)
+ throws FaaSException {
String eventId = event.toString();
return isEventImplemented(externalSystem, eventId, optionalParams);
}
@Override
- public boolean isImplemented(String externalSystem, String event, OptionalParams optionalParams) throws FaaSException {
+ public boolean isImplemented(String externalSystem, String event, OptionalParams optionalParams)
+ throws FaaSException {
return isEventImplemented(externalSystem, event, optionalParams);
}
- private boolean isEventImplemented(String externalSystem, String event, OptionalParams optionalParams) throws FaaSException {
- String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString() :
- optionalParams.getRequestId();
+ private boolean isEventImplemented(String externalSystem, String event, OptionalParams optionalParams)
+ throws FaaSException {
+ String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString()
+ : optionalParams.getRequestId();
int timeOutInMs = optionalParams.getTimeOutInMs();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
@@ -157,8 +163,11 @@ private boolean isEventImplemented(String externalSystem, String event, Optional
String invokeUri = String.format(IS_IMPLEMENTED_URI, accountId, event);
url = buildGWDomainUrl(externalSystem, invokeUri);
logger.info(String.format(REQUEST_LOG_IS_IMPLEMENTED, requestId, accountId, url));
- String authHeader = authSignatureBuilder.getAuthHeader();
- String response = restClient.get(url, this.setHeaders(authHeader, requestId), timeOutInMs);
+
+ Map headers = generateRequestHeaders(this.getGWDomain(), url, requestId,
+ HttpMethod.GET.name());
+
+ String response = restClient.get(url, headers, timeOutInMs);
boolean isImplemented = objectMapper.readValue(response,
com.liveperson.faas.dto.FaaSEventImplemented.class).getImplemented();
@@ -184,16 +193,17 @@ private boolean isEventImplemented(String externalSystem, String event, Optional
}
private void collectMetricsIsImplementedFails(String externalSystem, String eventId, StopWatch stopWatch,
- Exception e, int statusCode) {
- if (stopWatch.isRunning()) stopWatch.stop();
+ Exception e, int statusCode) {
+ if (stopWatch.isRunning())
+ stopWatch.stop();
metricCollector.onIsImplementedFailure(externalSystem, stopWatch.getTotalTimeSeconds(), eventId, accountId,
statusCode, e);
}
public List getLambdas(String userId, Map optionalQueryParams,
- OptionalParams optionalParams) throws FaaSException {
- String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString() :
- optionalParams.getRequestId();
+ OptionalParams optionalParams) throws FaaSException {
+ String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString()
+ : optionalParams.getRequestId();
int timeOutInMs = optionalParams.getTimeOutInMs();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
@@ -201,10 +211,12 @@ public List getLambdas(String userId, Map option
try {
String getLambdasUri = String.format(GET_LAMBDAS_URI, accountId);
url = buildUIDomainUrl(userId, optionalQueryParams, getLambdasUri);
- // TODO: Needs Oauth1 still!
- String authHeader = authSignatureBuilder.getAuthHeader();
+
+ Map headers = generateRequestHeaders(this.getUIDomain(), url, requestId,
+ HttpMethod.GET.name());
+
logger.info(String.format(REQUEST_LOG_GET_LAMBDAS, requestId, accountId, url));
- String response = restClient.get(url, setHeaders(authHeader, requestId), timeOutInMs);
+ String response = restClient.get(url, headers, timeOutInMs);
stopWatch.stop();
metricCollector.onGetLambdasSuccess(userId, stopWatch.getTotalTimeSeconds(), accountId);
return objectMapper.readValue(response, new TypeReference>() {
@@ -224,14 +236,15 @@ public List getLambdas(String userId, Map option
}
private void collectMetricsGetLambdasFails(String userId, StopWatch stopWatch, int statusCode, Exception e) {
- if (stopWatch.isRunning()) stopWatch.stop();
+ if (stopWatch.isRunning())
+ stopWatch.stop();
metricCollector.onGetLambdasFailure(userId, stopWatch.getTotalTimeSeconds(), accountId, statusCode, e);
}
private T invokeWithUri(String externalSystem, FaaSInvocation data,
- Class responseType, String invokeUri, OptionalParams optionalParams) throws FaaSException {
- String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString() :
- optionalParams.getRequestId();
+ Class responseType, String invokeUri, OptionalParams optionalParams) throws FaaSException {
+ String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString()
+ : optionalParams.getRequestId();
int timeOutInMs = optionalParams.getTimeOutInMs();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
@@ -242,9 +255,12 @@ private T invokeWithUri(String externalSystem, FaaSInvocation data,
isLambda = invokeUri.contains("lambdas");
lambdaOrEventName = extractLambdaOrEventName(invokeUri);
url = buildGWDomainUrl(externalSystem, invokeUri);
- String authHeader = authSignatureBuilder.getAuthHeader();
+
+ Map headers = generateRequestHeaders(this.getGWDomain(), url, requestId,
+ HttpMethod.POST.name());
+
logger.info(String.format(REQUEST_LOG_INVOKE, requestId, accountId, url, data));
- String response = restClient.post(url, this.setHeaders(authHeader, requestId), data.toString(),
+ String response = restClient.post(url, headers, data.toString(),
timeOutInMs);
collectMetricsForSuccessfulInvocation(externalSystem, stopWatch, isLambda, lambdaOrEventName);
@@ -269,10 +285,10 @@ private String extractLambdaOrEventName(String invokeUri) {
return lambdaOrEventName;
}
- private void invokeWithUriNoResponse(String externalSystem, FaaSInvocation data
- , String invokeUri, OptionalParams optionalParams) throws FaaSException {
- String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString() :
- optionalParams.getRequestId();
+ private void invokeWithUriNoResponse(String externalSystem, FaaSInvocation data, String invokeUri,
+ OptionalParams optionalParams) throws FaaSException {
+ String requestId = optionalParams.getRequestId().equals("") ? UUID.randomUUID().toString()
+ : optionalParams.getRequestId();
int timeOutInMs = optionalParams.getTimeOutInMs();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
@@ -283,9 +299,12 @@ private void invokeWithUriNoResponse(String externalSystem, FaaSInvocation data
isLambda = invokeUri.contains("lambdas");
lambdaOrEventName = extractLambdaOrEventName(invokeUri);
url = buildGWDomainUrl(externalSystem, invokeUri);
- String authHeader = authSignatureBuilder.getAuthHeader();
+
+ Map headers = generateRequestHeaders(this.getGWDomain(), url, requestId,
+ HttpMethod.POST.name());
+
logger.info(String.format(REQUEST_LOG_INVOKE, requestId, accountId, url, data));
- restClient.post(url, this.setHeaders(authHeader, requestId), data.toString(), timeOutInMs);
+ restClient.post(url, headers, data.toString(), timeOutInMs);
collectMetricsForSuccessfulInvocation(externalSystem, stopWatch, isLambda, lambdaOrEventName);
} catch (RestException e) {
logger.error(String.format(REQUEST_REST_EXCEPTION_LOG, url, requestId, accountId, e.getStatusCode(),
@@ -302,8 +321,9 @@ private void invokeWithUriNoResponse(String externalSystem, FaaSInvocation data
}
private void collectMetricsForSuccessfulInvocation(String externalSystem, StopWatch stopWatch, boolean isLambda,
- String lambdaOrEventName) {
- if (stopWatch.isRunning()) stopWatch.stop();
+ String lambdaOrEventName) {
+ if (stopWatch.isRunning())
+ stopWatch.stop();
if (isLambda)
metricCollector.onInvokeByUUIDSuccess(externalSystem, stopWatch.getTotalTimeSeconds(), lambdaOrEventName,
accountId);
@@ -313,8 +333,9 @@ private void collectMetricsForSuccessfulInvocation(String externalSystem, StopWa
}
private void collectMetricsForFailedInvocation(String externalSystem, StopWatch stopWatch, boolean isLambda,
- String lambdaOrEventName, Exception e, int statusCode) {
- if (stopWatch.isRunning()) stopWatch.stop();
+ String lambdaOrEventName, Exception e, int statusCode) {
+ if (stopWatch.isRunning())
+ stopWatch.stop();
if (isLambda)
metricCollector.onInvokeByUUIDFailure(externalSystem, stopWatch.getTotalTimeSeconds(), lambdaOrEventName,
accountId, statusCode, e);
@@ -324,7 +345,7 @@ private void collectMetricsForFailedInvocation(String externalSystem, StopWatch
}
private String buildUIDomainUrl(String userId, Map optionalQueryParams,
- String getLambdasUri) throws CsdsRetrievalException {
+ String getLambdasUri) throws CsdsRetrievalException {
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.newInstance()
.scheme(PROTOCOL)
.host(getUIDomain())
@@ -354,7 +375,8 @@ private String buildGWDomainUrl(String externalSystem, String invokeUri) throws
private FaaSException handleFaaSInvocationException(RestException e) throws FaaSException {
FaaSError faaSError = this.getFaaSError(e);
- if (FaaSLambdaErrorCodes.contains(faaSError.getErrorCode())) throw new FaaSLambdaException(faaSError, e);
+ if (FaaSLambdaErrorCodes.contains(faaSError.getErrorCode()))
+ throw new FaaSLambdaException(faaSError, e);
throw new FaaSDetailedException(faaSError, e);
}
@@ -367,19 +389,60 @@ private FaaSError getFaaSError(RestException e) throws FaaSException {
}
}
+ /**
+ * Generates the request headers based on the authentication method
+ *
+ * @param domain the request domain
+ * @param url the request full url including domain and path parameters
+ * @param requestId the request identification
+ * @param method the request method
+ * @return the request required headers
+ * @throws TokenGenerationException
+ * @throws DPoPJwtGenerationException
+ */
+ private Map generateRequestHeaders(String domain, String url, String requestId, String method)
+ throws TokenGenerationException, DPoPJwtGenerationException {
+ if (this.authDPoPSignatureBuilder != null) {
+ String domainUrl = PROTOCOL + "://" + domain;
+ String accessToken = authDPoPSignatureBuilder.getAccessTokenInternal(domainUrl);
+ String dpopJwt = authDPoPSignatureBuilder.getDpopHeaderInternal(url, method, accessToken);
+ return this.getHeaders(accessToken, requestId, dpopJwt);
+ } else {
+ String authHeader = authSignatureBuilder.getAuthHeader();
+ return this.getHeaders(authHeader, requestId);
+ }
+ }
+
/**
* Set headers for the RESTful call
*
* @param authorizationHeader the authorization header
+ * @param requestId identifies the request
* @return the relevant headers
*/
- private Map setHeaders(String authorizationHeader, String requestId) {
+ private Map getHeaders(String authorizationHeader, String requestId) {
Map headers = new HashMap();
headers.put("X-REQUEST-ID", requestId);
headers.put(HttpHeaders.AUTHORIZATION, authorizationHeader);
return headers;
}
+ /**
+ * Set headers for the RESTful call
+ *
+ * @param accessToken the Oauth2 + DPoP access token
+ * @param requestId identifies the request
+ * @param dpopJwt the DPoP header
+ * @return the relevant headers
+ */
+ private Map getHeaders(String accessToken, String requestId, String dpopJwt) {
+ Map headers = new HashMap();
+ headers.put("X-REQUEST-ID", requestId);
+ headers.put(HttpHeaders.AUTHORIZATION, "DPoP " + accessToken);
+ headers.put("DPoP", dpopJwt);
+ return headers;
+ }
+
/**
* Determines the faas UI domain for the RESTful call.
* This domain is used for managing & deploying functions.
@@ -407,6 +470,7 @@ public static class Builder {
private Map csdsMap;
private RestClient restClient;
private AuthSignatureBuilder authSignatureBuilder;
+ private AuthDPoPSignatureBuilder authDPoPSignatureBuilder;
private MetricCollector metricCollector;
private String accountId;
private String clientSecret;
@@ -442,6 +506,11 @@ public Builder withAuthSignatureBuilder(AuthSignatureBuilder authSignatureBuilde
return this;
}
+ public Builder withAuthDPoPSignatureBuilder(AuthDPoPSignatureBuilder authDPoPSignatureBuilder) {
+ this.authDPoPSignatureBuilder = authDPoPSignatureBuilder;
+ return this;
+ }
+
public Builder withMetricCollector(MetricCollector metricCollector) {
this.metricCollector = metricCollector;
return this;
@@ -464,8 +533,7 @@ private boolean isInitalized(Object o) {
public FaaSWebClient build() {
FaaSWebClient client = new FaaSWebClient();
client.accountId = this.accountId;
- client.restClient = isInitalized(this.restClient) ? this.restClient :
- new DefaultRestClient();
+ client.restClient = isInitalized(this.restClient) ? this.restClient : new DefaultRestClient();
if (isInitalized(this.metricCollector)) {
client.metricCollector = this.metricCollector;
} else {
@@ -483,11 +551,15 @@ public FaaSWebClient build() {
if (isInitalized(this.authSignatureBuilder)) {
client.authSignatureBuilder = this.authSignatureBuilder;
} else if (isInitalized(this.clientSecret) && isInitalized(this.clientId)) {
- client.authSignatureBuilder = new JwtSignatureBuilder(client.restClient, client.csdsClient, accountId
- , this.clientId, this.clientSecret);
+ client.authSignatureBuilder = new JwtSignatureBuilder(client.restClient, client.csdsClient, accountId,
+ this.clientId, this.clientSecret);
+ } else if (isInitalized(this.authDPoPSignatureBuilder)) {
+ client.authDPoPSignatureBuilder = this.authDPoPSignatureBuilder;
} else {
- throw new IllegalStateException("Neither AuthSignatureBuilder instance, nor clientId and clientSecret" +
- " were provided, thus impossible to use any authentication method");
+ throw new IllegalStateException(
+ "Neither AuthSignatureBuilder instance, nor clientId and clientSecret, nor AuthDpopSignatureBuilder"
+ +
+ " were provided, thus impossible to use any authentication method");
}
if (isInitalized(this.isImplementedCache))
client.isImplementedCache = this.isImplementedCache;
diff --git a/src/main/java/com/liveperson/faas/exception/DPoPJwtGenerationException.java b/src/main/java/com/liveperson/faas/exception/DPoPJwtGenerationException.java
new file mode 100644
index 0000000..31adb43
--- /dev/null
+++ b/src/main/java/com/liveperson/faas/exception/DPoPJwtGenerationException.java
@@ -0,0 +1,12 @@
+package com.liveperson.faas.exception;
+
+public class DPoPJwtGenerationException extends Exception {
+
+ public DPoPJwtGenerationException(String message) {
+ super(message);
+ }
+
+ public DPoPJwtGenerationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/com/liveperson/faas/security/AuthDPoPSignatureBuilder.java b/src/main/java/com/liveperson/faas/security/AuthDPoPSignatureBuilder.java
new file mode 100644
index 0000000..1d0ea33
--- /dev/null
+++ b/src/main/java/com/liveperson/faas/security/AuthDPoPSignatureBuilder.java
@@ -0,0 +1,35 @@
+package com.liveperson.faas.security;
+
+import com.liveperson.faas.exception.TokenGenerationException;
+import com.liveperson.faas.exception.DPoPJwtGenerationException;
+
+/**
+ * Generates a Oauth2 + DPoP for authentication purposes
+ * OAuth2+DPoP authentication is only available INTERNALLY for service-to-service.
+ *
+ * @author eplazaso
+ */
+public interface AuthDPoPSignatureBuilder {
+
+ /**
+ * Generate Oauth2 access token string. Called whenever the faas-client needs to authenticate to send a request.
+ * Its return value is used in the 'Authorization'-header of the request.
+ *
+ * @param domainUrl Protocol (HTTPS) + domain of the API registered in the authentication server required to get the access token. E.g., https://va.faasgw.liveperson.net
+ * @throws TokenGenerationException when token generation fails
+ * @return a string containing the access token that will be included in the 'Authorization' header
+ */
+ String getAccessTokenInternal(String domainUrl) throws TokenGenerationException;
+
+ /**
+ * Generate the DPoP header. Called whenever the faas-client needs to authenticate to send a request.
+ *
+ * @param url Request 'url' including protocol domain and path
+ * @param method 'http-method' of the request
+ * @param accessToken A string containing the access token that was returned by 'getAccessTokenInternal' method
+ * @return The the 'DPoP' header of the request.
+ * @throws DPoPJwtGenerationException when DPoP header generation fails
+ */
+ String getDpopHeaderInternal(String url, String method, String accessToken) throws DPoPJwtGenerationException;
+
+}
diff --git a/src/test/java/com/liveperson/faas/client/FaaSClientTest.java b/src/test/java/com/liveperson/faas/client/FaaSClientTest.java
index 680f539..6080bce 100644
--- a/src/test/java/com/liveperson/faas/client/FaaSClientTest.java
+++ b/src/test/java/com/liveperson/faas/client/FaaSClientTest.java
@@ -11,6 +11,7 @@
import com.liveperson.faas.http.RestClient;
import com.liveperson.faas.metriccollector.MetricCollector;
import com.liveperson.faas.response.lambda.LambdaResponse;
+import com.liveperson.faas.security.AuthDPoPSignatureBuilder;
import com.liveperson.faas.security.AuthSignatureBuilder;
import com.liveperson.faas.util.EventResponse;
import com.liveperson.faas.util.UUIDResponse;
@@ -31,807 +32,1033 @@
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyFloat;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyMap;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
public class FaaSClientTest {
+ private final ObjectMapper objectMapper = new ObjectMapper();
+ private final SimpleDateFormat mockDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ @InjectMocks
+ private FaaSWebClient client;
+ @InjectMocks
+ private FaaSWebClient clientWithDPoP;
+ @Mock
+ private RestClient restClientMock;
+ @Mock
+ private CsdsClient csdsClientMock;
+ @Captor
+ private ArgumentCaptor