| 1 | package org.sanmibuh.tedee.lock.infrastructure.secondary; | |
| 2 | ||
| 3 | import java.io.IOException; | |
| 4 | import java.time.Clock; | |
| 5 | import lombok.RequiredArgsConstructor; | |
| 6 | import org.springframework.http.HttpRequest; | |
| 7 | import org.springframework.http.client.ClientHttpRequestExecution; | |
| 8 | import org.springframework.http.client.ClientHttpRequestInterceptor; | |
| 9 | import org.springframework.http.client.ClientHttpResponse; | |
| 10 | ||
| 11 | @RequiredArgsConstructor | |
| 12 | final class TedeeApiTokenInterceptor implements ClientHttpRequestInterceptor { | |
| 13 | ||
| 14 | private static final String API_TOKEN_HEADER = "api_token"; | |
| 15 | ||
| 16 | private final TedeeApiTokenGenerator generator; | |
| 17 | private final Clock clock; | |
| 18 | ||
| 19 | @Override | |
| 20 | public ClientHttpResponse intercept( | |
| 21 | final HttpRequest request, final byte[] body, final ClientHttpRequestExecution execution) | |
| 22 | throws IOException { | |
| 23 |
1
1. intercept : removed call to org/springframework/http/HttpHeaders::set → KILLED |
request.getHeaders().set(API_TOKEN_HEADER, generator.generate(clock.millis())); |
| 24 |
1
1. intercept : replaced return value with null for org/sanmibuh/tedee/lock/infrastructure/secondary/TedeeApiTokenInterceptor::intercept → KILLED |
return execution.execute(request, body); |
| 25 | } | |
| 26 | } | |
Mutations | ||
| 23 |
1.1 |
|
| 24 |
1.1 |