This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dev controller that mocks endpoints not locally available
- Loading branch information
Showing
5 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
...src/main/java/ch/admin/bag/covidcertificate/backend/verifier/ws/config/WsLocalConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package ch.admin.bag.covidcertificate.backend.verifier.ws.config; | ||
|
||
import ch.admin.bag.covidcertificate.backend.verifier.ws.controller.dev.DevController; | ||
import com.zaxxer.hikari.HikariConfig; | ||
import com.zaxxer.hikari.HikariDataSource; | ||
import java.util.Properties; | ||
import javax.sql.DataSource; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
|
||
@Configuration | ||
@Profile("local") | ||
public class WsLocalConfig { | ||
|
||
@Bean | ||
public DevController devController() { | ||
return new DevController(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
.../java/ch/admin/bag/covidcertificate/backend/verifier/ws/controller/dev/DevController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2021 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package ch.admin.bag.covidcertificate.backend.verifier.ws.controller.dev; | ||
|
||
import ch.admin.bag.covidcertificate.backend.verifier.ws.utils.CacheUtil; | ||
import ch.ubique.openapi.docannotations.Documentation; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.springframework.http.CacheControl; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
@Controller | ||
@RequestMapping("") | ||
@Documentation(description = "mocks endpoints that are not available during local development") | ||
public class DevController { | ||
|
||
private static final String NEXT_SINCE_HEADER = "X-Next-Since"; | ||
private static final String UP_TO_DATE_HEADER = "up-to-date"; | ||
|
||
@GetMapping(value = "/v1/revocation-list") | ||
public @ResponseBody ResponseEntity<List<String>> getMockRevokedCerts( | ||
@RequestParam(required = false) String since) { | ||
List<String> response = new ArrayList<>(); | ||
for (int i = 0; i < 10; i++) { | ||
response.add("urn:uvci:01:CH:MOCK" + i); | ||
} | ||
return ResponseEntity.ok() | ||
.header(NEXT_SINCE_HEADER, "1000") | ||
.header(UP_TO_DATE_HEADER, "true") | ||
.cacheControl(CacheControl.maxAge(CacheUtil.REVOCATION_LIST_MAX_AGE)) | ||
.body(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters