use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project yakc by manusa.
the class ConfigMapIT method deleteNamespacedConfigMap.
@Test
@DisplayName("deleteNamespacedConfigMap, should delete existing ConfigMap")
void deleteNamespacedConfigMap() throws IOException {
// When
final Status result = KC.create(CoreV1Api.class).deleteNamespacedConfigMap(configMapName, NAMESPACE).get();
// Then
assertAll("Deleted configMap", () -> assertThat(result).isNotNull(), () -> assertThat(result.getStatus()).isEqualTo("Success"));
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project koronavilkku-backend by THLfi.
the class DiagnosisKeyControllerIT method reusingTokenForDifferentRequestIs403.
@Test
public void reusingTokenForDifferentRequestIs403() throws Exception {
PublishTokenVerification verification = new PublishTokenVerification(1, LocalDate.now().minus(7, DAYS), Optional.empty());
given(tokenVerificationService.getVerification("123654032165")).willReturn(verification);
DiagnosisPublishRequest request1 = new DiagnosisPublishRequest(keyGenerator.someRequestKeys(14), Optional.empty(), Optional.empty());
DiagnosisPublishRequest request2 = new DiagnosisPublishRequest(keyGenerator.someRequestKeys(14), Optional.empty(), Optional.empty());
verifiedPost("123654032165", request1);
mockMvc.perform(post(BASE_URL).contentType(MediaType.APPLICATION_JSON).header(PUBLISH_TOKEN_HEADER, "123654032165").header(FAKE_REQUEST_HEADER, 0).content(mapper.writeValueAsString(request2))).andExpect(status().isForbidden()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().string(containsString("Publish token not accepted")));
verify(tokenVerificationService, times(2)).getVerification("123654032165");
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project koronavilkku-backend by THLfi.
the class DiagnosisKeyController method getCurrentStatus.
@GetMapping("/status")
public ResponseEntity<Status> getCurrentStatus(@RequestParam(value = "batch") Optional<BatchId> batchId, @RequestParam(value = "app-config") Optional<Integer> appConfigVersion, @RequestParam(value = "exposure-config") Optional<Integer> exposureConfigVersion, @RequestParam(value = "exposure-config-v2") Optional<Integer> exposureConfigVersionV2, @RequestParam(value = "en-api-version") Optional<Integer> enApiVersionOptional) {
int enApiVersion = enApiVersionOptional.orElse(1);
LOG.info("Fetching full status info: {} {} {} {} {}", keyValue("clientBatchId", batchId), keyValue("clientAppConfigVersion", appConfigVersion), keyValue("enApiVersion", enApiVersion), keyValue("clientExposureConfigVersion", exposureConfigVersion), keyValue("clientExposureConfigVersionV2", exposureConfigVersionV2));
BatchIntervals intervals = enApiVersion == 2 ? getExportIntervalsV2() : getExportIntervals();
ExposureConfiguration exposureConfig = configurationService.getLatestExposureConfig();
ExposureConfigurationV2 exposureConfigV2 = configurationService.getLatestV2ExposureConfig();
AppConfiguration appConfig = configurationService.getLatestAppConfig();
Status result = new Status(batchId.map(id -> enApiVersion == 2 ? batchFileService.listBatchIdsSinceV2(id, intervals) : batchFileService.listBatchIdsSince(id, intervals)).orElse(List.of()), toLatest(appConfig, appConfig.version, appConfigVersion), toLatest(exposureConfig, exposureConfig.version, exposureConfigVersion), toLatest(exposureConfigV2, exposureConfigV2.version, exposureConfigVersionV2));
boolean cacheableBatchId = batchId.isEmpty() || intervals.isDistributed(batchId.get().intervalNumber);
boolean cacheableAppConfig = appConfigVersion.isEmpty() || appConfigVersion.get().equals(appConfig.version);
boolean cacheableExposureConfig = exposureConfigVersion.isEmpty() || exposureConfigVersion.get().equals(exposureConfig.version);
boolean cacheableExposureConfigV2 = exposureConfigVersionV2.isEmpty() || exposureConfigVersionV2.get().equals(exposureConfigV2.version);
return statusResponse(result, cacheableBatchId && cacheableAppConfig && cacheableExposureConfig && cacheableExposureConfigV2);
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project koronavilkku-backend by THLfi.
the class DiagnosisKeyControllerDemoIT method assertListing.
private void assertListing(BatchId previous, List<BatchId> expected, boolean v2) throws Exception {
BatchList list = new BatchList(expected);
String listUrl = v2 ? LIST_URL_V2 : LIST_URL;
mockMvc.perform(get(listUrl + previous)).andExpect(status().isOk()).andExpect(header().exists("Cache-Control")).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().json(mapper.writeValueAsString(list)));
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project koronavilkku-backend by THLfi.
the class PublishTokenVerificationServiceRest method getVerification.
@Override
public PublishTokenVerification getVerification(String token) {
String url = publishTokenUrl + TOKEN_VERIFICATION_PATH;
try {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(List.of(MediaType.APPLICATION_JSON));
headers.add(PUBLISH_TOKEN_HEADER, token);
HttpEntity<String> entity = new HttpEntity<>(null, headers);
ResponseEntity<PublishTokenVerification> reply = restTemplate.exchange(url, HttpMethod.GET, entity, PublishTokenVerification.class);
if (reply.getStatusCode().is2xxSuccessful() && reply.hasBody()) {
return reply.getBody();
} else {
LOG.warn("Server didn't verify publish token: {}", keyValue("status", reply.getStatusCode()));
throw new TokenValidationException();
}
} catch (HttpClientErrorException e) {
LOG.warn("Publish token not verified: {}", keyValue("result", e.getStatusCode()), e);
throw new TokenValidationException();
} catch (HttpServerErrorException e) {
LOG.error("Error in token service: {}", keyValue("url", url), e);
} catch (RestClientException e) {
LOG.error("Error verifying token request: {}", keyValue("url", url), e);
}
throw new IllegalStateException("Could not handle token verification");
}
Aggregations