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.
- Loading branch information
Showing
10 changed files
with
647 additions
and
41 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
...data/src/test/java/ch/admin/bag/covidcertificate/backend/verifier/data/util/TestUtil.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,57 @@ | ||
/* | ||
* 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.data.util; | ||
|
||
import ch.admin.bag.covidcertificate.backend.verifier.model.cert.Algorithm; | ||
import ch.admin.bag.covidcertificate.backend.verifier.model.cert.db.DbCsca; | ||
import ch.admin.bag.covidcertificate.backend.verifier.model.cert.db.DbDsc; | ||
|
||
public class TestUtil { | ||
|
||
private TestUtil() {} | ||
|
||
public static DbCsca getDefaultCsca(int idSuffix, String origin) { | ||
var dbCsca = new DbCsca(); | ||
dbCsca.setKeyId("keyid_" + idSuffix); | ||
dbCsca.setCertificateRaw("cert"); | ||
dbCsca.setOrigin(origin); | ||
dbCsca.setSubjectPrincipalName("admin_ch"); | ||
return dbCsca; | ||
} | ||
|
||
public static DbDsc getRsaDsc(int idSuffix, String origin, long fkCsca) { | ||
final var dbDsc = new DbDsc(); | ||
dbDsc.setKeyId("keyid_" + idSuffix); | ||
dbDsc.setFkCsca(fkCsca); | ||
dbDsc.setCertificateRaw("cert"); | ||
dbDsc.setOrigin(origin); | ||
dbDsc.setUse("sig"); | ||
dbDsc.setAlg(Algorithm.RS256); | ||
dbDsc.setN("n"); | ||
dbDsc.setE("e"); | ||
dbDsc.setSubjectPublicKeyInfo("pk"); | ||
return dbDsc; | ||
} | ||
|
||
public static DbDsc getEcDsc(int idSuffix, String origin, long fkCsca) { | ||
final var dbDsc = new DbDsc(); | ||
dbDsc.setKeyId("keyid_" + idSuffix); | ||
dbDsc.setFkCsca(fkCsca); | ||
dbDsc.setCertificateRaw("cert"); | ||
dbDsc.setOrigin(origin); | ||
dbDsc.setUse("sig"); | ||
dbDsc.setAlg(Algorithm.ES256); | ||
dbDsc.setCrv("crv"); | ||
dbDsc.setX("x"); | ||
dbDsc.setY("y"); | ||
return dbDsc; | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
...ch/admin/bag/covidcertificate/backend/verifier/ws/controller/KeyControllerV2JsonTest.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,36 @@ | ||
/* | ||
* 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; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.TestInstance.Lifecycle; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@ActiveProfiles({"actuator-security"}) | ||
@SpringBootTest( | ||
properties = { | ||
"ws.monitor.prometheus.user=prometheus", | ||
"ws.monitor.prometheus.password=prometheus", | ||
"management.endpoints.enabled-by-default=true", | ||
"management.endpoints.web.exposure.include=*" | ||
}) | ||
@TestInstance(Lifecycle.PER_CLASS) | ||
public class KeyControllerV2JsonTest extends KeyControllerV2Test { | ||
|
||
@BeforeAll | ||
public void setup() { | ||
super.setup(); | ||
this.acceptMediaType = MediaType.APPLICATION_JSON; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../ch/admin/bag/covidcertificate/backend/verifier/ws/controller/KeyControllerV2JwsTest.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,36 @@ | ||
/* | ||
* 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; | ||
|
||
import ch.admin.bag.covidcertificate.backend.verifier.ws.security.signature.JwsMessageConverter; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.TestInstance.Lifecycle; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@ActiveProfiles({"actuator-security"}) | ||
@SpringBootTest( | ||
properties = { | ||
"ws.monitor.prometheus.user=prometheus", | ||
"ws.monitor.prometheus.password=prometheus", | ||
"management.endpoints.enabled-by-default=true", | ||
"management.endpoints.web.exposure.include=*" | ||
}) | ||
@TestInstance(Lifecycle.PER_CLASS) | ||
public class KeyControllerV2JwsTest extends KeyControllerV2Test { | ||
|
||
@BeforeAll | ||
public void setup() { | ||
super.setup(); | ||
this.acceptMediaType = JwsMessageConverter.JWS_MEDIA_TYPE; | ||
} | ||
} |
Oops, something went wrong.