diff --git a/mock-service/pom.xml b/mock-service/pom.xml index 955d9c38..25ad841e 100644 --- a/mock-service/pom.xml +++ b/mock-service/pom.xml @@ -156,13 +156,15 @@ ${project.artifactId}:latest - paketobuildpacks/builder-jammy-tiny:latest paketobuildpacks/run-jammy-tiny:latest 21 + + //./pipe/dockerDesktopLinuxEngine + diff --git a/spring-boot/spring-boot-rest/src/test/java/io/github/mjhaugsdal/rest/configuration/RestTestConfiguration.java b/spring-boot/spring-boot-rest/src/test/java/io/github/mjhaugsdal/rest/configuration/RestTestConfiguration.java index 09b5fe68..2549f072 100644 --- a/spring-boot/spring-boot-rest/src/test/java/io/github/mjhaugsdal/rest/configuration/RestTestConfiguration.java +++ b/spring-boot/spring-boot-rest/src/test/java/io/github/mjhaugsdal/rest/configuration/RestTestConfiguration.java @@ -26,133 +26,140 @@ @Profile("default") public class RestTestConfiguration { - static { - System.setProperty("rest.na.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort() + "/v2"); - System.setProperty("rest.rekvirent.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort()+ "/v2"); - System.setProperty("rest.utleverer.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort()+ "/v2"); - } - - @Value("${rest.na.address}") - String naAddress; - - @Value("${rest.rekvirent.address}") - String rekvirentAddress; - - @Value("${rest.utleverer.address}") - String utlevererAddress; - - @Value("${use.jwk}") - String jwk; - - - @Bean - public Server naServer() { - var serverFactoryBean = new JAXRSServerFactoryBean(); - serverFactoryBean.setServiceClass(NaWebServiceImpl.class); - serverFactoryBean.setAddress(naAddress + "/" + "NA"); - commonSetup(serverFactoryBean, jwk); - return serverFactoryBean.create(); - } + @TestConfiguration + @Profile("default") + public static class DefaultConfiguration { + static { + System.setProperty("rest.na.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort() + "/v2"); + System.setProperty("rest.rekvirent.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort()+ "/v2"); + System.setProperty("rest.utleverer.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort()+ "/v2"); + } - @Bean - public Server utlevererServer() { - var serverFactoryBean = new JAXRSServerFactoryBean(); - serverFactoryBean.setServiceClass(UtlevererWebServiceImpl.class); - serverFactoryBean.setAddress(utlevererAddress + "/" + "Utleverer"); - commonSetup(serverFactoryBean, jwk); - return serverFactoryBean.create(); - } + @Value("${rest.na.address}") + String naAddress; + @Value("${rest.rekvirent.address}") + String rekvirentAddress; - @Bean - public Server rekvirentServer() { - var serverFactoryBean = new JAXRSServerFactoryBean(); - serverFactoryBean.setServiceClass(RekvirentWebServiceImpl.class); - serverFactoryBean.setAddress(rekvirentAddress + "/" + "Rekvirent"); - commonSetup(serverFactoryBean, jwk); - return serverFactoryBean.create(); - } + @Value("${rest.utleverer.address}") + String utlevererAddress; - private static void commonSetup(JAXRSServerFactoryBean serverFactoryBean, String jwk) { - var loggingFeature = new LoggingFeature(); - loggingFeature.setPrettyLogging(true); - serverFactoryBean.getFeatures().add(loggingFeature); + @Value("${use.jwk}") + String jwk; - List providers = new LinkedList<>(); - providers.add("com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider"); - var jweContainerRequestFilter = new JweContainerRequestFilter(); - var jwsContainerRequestFilter = new JwsContainerRequestFilter(); + @Bean + public Server naServer() { + var serverFactoryBean = new JAXRSServerFactoryBean(); + serverFactoryBean.setServiceClass(NaWebServiceImpl.class); + serverFactoryBean.setAddress(naAddress + "/" + "NA"); + commonSetup(serverFactoryBean, jwk); + return serverFactoryBean.create(); + } - Properties properties = new Properties(); - try { - properties.load(RestTestConfiguration.class.getClassLoader().getResourceAsStream("server/server.properties")); - } catch (IOException e) { - e.printStackTrace(); + @Bean + public Server utlevererServer() { + var serverFactoryBean = new JAXRSServerFactoryBean(); + serverFactoryBean.setServiceClass(UtlevererWebServiceImpl.class); + serverFactoryBean.setAddress(utlevererAddress + "/" + "Utleverer"); + commonSetup(serverFactoryBean, jwk); + return serverFactoryBean.create(); } - var jweWriterInterceptor = new JweWriterInterceptor(); - jweWriterInterceptor.setUseJweOutputStream(true); - - var jwsWriterInterceptor = new JwsWriterInterceptor(); - jwsWriterInterceptor.setUseJwsOutputStream(true); - - providers.add(jweContainerRequestFilter); - providers.add(jwsContainerRequestFilter); - providers.add(jweWriterInterceptor); - providers.add(jwsWriterInterceptor); - - serverFactoryBean.setProviders(providers); - - if (Boolean.parseBoolean(jwk)) { - //ENCRYPTION properties - serverFactoryBean.getProperties(true).put( - "rs.security.encryption.in.properties", - "server/jwk/server.properties" - ); - serverFactoryBean.getProperties(true).put( - "rs.security.encryption.out.properties", - "server/jwk/server-out.properties" - ); - //SIGNATURE IN - serverFactoryBean.getProperties(true).put( - "rs.security.signature.in.properties", - "server/jwk/server-sign.properties" - ); - //SIGNATURE OUT - serverFactoryBean.getProperties(true).put( - "rs.security.signature.out.properties", - "server/jwk/server-out-sign.properties" - ); - - serverFactoryBean.getProperties(true).put("rs.security.accept.public.key", "true"); - serverFactoryBean.getProperties(true).put("rs.security.signature.include.public.key", "true"); - } else { - //ENCRYPTION properties - serverFactoryBean.getProperties(true).put( - "rs.security.encryption.in.properties", - "server/server.properties" - ); - serverFactoryBean.getProperties(true).put( - "rs.security.encryption.out.properties", - "server/server-out.properties" - ); - //SIGNATURE IN - serverFactoryBean.getProperties(true).put( - "rs.security.signature.in.properties", - "server/server-sign.properties" - ); - //SIGNATURE OUT - serverFactoryBean.getProperties(true).put( - "rs.security.signature.out.properties", - "server/server-out-sign.properties" - ); - serverFactoryBean.getProperties(true).put("rs.security.signature.include.cert", "true"); + + @Bean + public Server rekvirentServer() { + var serverFactoryBean = new JAXRSServerFactoryBean(); + serverFactoryBean.setServiceClass(RekvirentWebServiceImpl.class); + serverFactoryBean.setAddress(rekvirentAddress + "/" + "Rekvirent"); + commonSetup(serverFactoryBean, jwk); + return serverFactoryBean.create(); } - serverFactoryBean.getProperties(true).put("jose.debug", true); + private static void commonSetup(JAXRSServerFactoryBean serverFactoryBean, String jwk) { + var loggingFeature = new LoggingFeature(); + loggingFeature.setPrettyLogging(true); + serverFactoryBean.getFeatures().add(loggingFeature); + + List providers = new LinkedList<>(); + providers.add("com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider"); + + var jweContainerRequestFilter = new JweContainerRequestFilter(); + var jwsContainerRequestFilter = new JwsContainerRequestFilter(); + + Properties properties = new Properties(); + try { + properties.load(RestTestConfiguration.class.getClassLoader().getResourceAsStream("server/server.properties")); + } catch (IOException e) { + e.printStackTrace(); + } + + var jweWriterInterceptor = new JweWriterInterceptor(); + jweWriterInterceptor.setUseJweOutputStream(true); + + var jwsWriterInterceptor = new JwsWriterInterceptor(); + jwsWriterInterceptor.setUseJwsOutputStream(true); + + providers.add(jweContainerRequestFilter); + providers.add(jwsContainerRequestFilter); + providers.add(jweWriterInterceptor); + providers.add(jwsWriterInterceptor); + + serverFactoryBean.setProviders(providers); + + if (Boolean.parseBoolean(jwk)) { + //ENCRYPTION properties + serverFactoryBean.getProperties(true).put( + "rs.security.encryption.in.properties", + "server/jwk/server.properties" + ); + serverFactoryBean.getProperties(true).put( + "rs.security.encryption.out.properties", + "server/jwk/server-out.properties" + ); + //SIGNATURE IN + serverFactoryBean.getProperties(true).put( + "rs.security.signature.in.properties", + "server/jwk/server-sign.properties" + ); + //SIGNATURE OUT + serverFactoryBean.getProperties(true).put( + "rs.security.signature.out.properties", + "server/jwk/server-out-sign.properties" + ); + + serverFactoryBean.getProperties(true).put("rs.security.accept.public.key", "true"); + serverFactoryBean.getProperties(true).put("rs.security.signature.include.public.key", "true"); + } else { + //ENCRYPTION properties + serverFactoryBean.getProperties(true).put( + "rs.security.encryption.in.properties", + "server/server.properties" + ); + serverFactoryBean.getProperties(true).put( + "rs.security.encryption.out.properties", + "server/server-out.properties" + ); + //SIGNATURE IN + serverFactoryBean.getProperties(true).put( + "rs.security.signature.in.properties", + "server/server-sign.properties" + ); + //SIGNATURE OUT + serverFactoryBean.getProperties(true).put( + "rs.security.signature.out.properties", + "server/server-out-sign.properties" + ); + serverFactoryBean.getProperties(true).put("rs.security.signature.include.cert", "true"); + } + + serverFactoryBean.getProperties(true).put("jose.debug", true); + } } + @TestConfiguration + @Profile("local") + public static class LocalConfiguration { - + } } diff --git a/spring-boot/spring-boot-soap/src/test/java/io/github/mjhaugsdal/soap/configuration/SoapTestConfiguration.java b/spring-boot/spring-boot-soap/src/test/java/io/github/mjhaugsdal/soap/configuration/SoapTestConfiguration.java index f2b80e80..58e2db43 100644 --- a/spring-boot/spring-boot-soap/src/test/java/io/github/mjhaugsdal/soap/configuration/SoapTestConfiguration.java +++ b/spring-boot/spring-boot-soap/src/test/java/io/github/mjhaugsdal/soap/configuration/SoapTestConfiguration.java @@ -20,77 +20,93 @@ @TestConfiguration -@Profile("default") public class SoapTestConfiguration { - static { - System.setProperty("rekvirent.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort() + "/v1"); - System.setProperty("utleverer.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort()+ "/v1"); - System.setProperty("na.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort()+ "/v1"); - } - - @Value("${rekvirent.sign}") - boolean rekvirentSign; - - @Value("${rekvirent.encrypt}") - boolean rekvirentEncrypt; - - @Value("${rekvirent.address}") - String rekvirentAddress; - - @Value("${utleverer.sign}") - boolean utlevererSign; - - @Value("${utleverer.encrypt}") - boolean utlevererEncrypt; - - @Value("${utleverer.address}") - String utlevererAddress; + @TestConfiguration + @Profile("default") + public static class DefaultConfiguration { + @Value("${rekvirent.sign}") + boolean rekvirentSign; + + @Value("${rekvirent.encrypt}") + boolean rekvirentEncrypt; + + @Value("${rekvirent.address}") + String rekvirentAddress; + + @Value("${utleverer.sign}") + boolean utlevererSign; + + @Value("${utleverer.encrypt}") + boolean utlevererEncrypt; + + @Value("${utleverer.address}") + String utlevererAddress; + + @Value("${na.sign}") + boolean naSign; + + @Value("${na.encrypt}") + boolean naEncrypt; + + @Value("${na.address}") + String naAddress; + List featureList = new ArrayList<>(); + + DefaultConfiguration() { + var loggingFeature = new LoggingFeature(); + loggingFeature.setPrettyLogging(true); + featureList.add(loggingFeature); + } + + static { + System.setProperty("rekvirent.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort() + "/v1"); + System.setProperty("utleverer.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort() + "/v1"); + System.setProperty("na.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort() + "/v1"); + System.setProperty("rest.server.address", "http://localhost:" + TestSocketUtils.findAvailableTcpPort()); + } + + @Bean + public Server naEndpoint() { + var bean = new JaxWsServerFactoryBean(); + bean.setServiceBean(new NaWebService()); + bean.setAddress(naAddress + "/NA"); + bean.setFeatures(featureList); + setupWSSEServer(bean, naEncrypt, naSign); + return bean.create(); + } + + @Bean + public Server rekvirentEndpoint() { + var bean = new JaxWsServerFactoryBean(); + bean.setServiceBean(new RekvirentWebservice()); + bean.setAddress(rekvirentAddress + "/Rekvirent"); + bean.setFeatures(featureList); + setupWSSEServer(bean, rekvirentEncrypt, rekvirentSign); + return bean.create(); + } + + @Bean + public Server utlevererEndpoint() { + var bean = new JaxWsServerFactoryBean(); + bean.setServiceBean(new UtlevererWebservice()); + bean.setAddress(utlevererAddress + "/Utleverer"); + bean.setFeatures(featureList); + setupWSSEServer(bean, utlevererEncrypt, utlevererSign); + return bean.create(); + } - @Value("${na.sign}") - boolean naSign; - - @Value("${na.encrypt}") - boolean naEncrypt; - - @Value("${na.address}") - String naAddress; - List featureList = new ArrayList<>(); - - SoapTestConfiguration() { - var loggingFeature = new LoggingFeature(); - loggingFeature.setPrettyLogging(true); - featureList.add(loggingFeature); } + @TestConfiguration + @Profile("local") + public static class LocalConfiguration { + List featureList = new ArrayList<>(); - @Bean - public Server naEndpoint() { - var bean = new JaxWsServerFactoryBean(); - bean.setServiceBean(new NaWebService()); - bean.setAddress(naAddress + "/NA"); - bean.setFeatures(featureList); - setupWSSEServer(bean, naEncrypt, naSign); - return bean.create(); - } - - @Bean - public Server rekvirentEndpoint() { - var bean = new JaxWsServerFactoryBean(); - bean.setServiceBean(new RekvirentWebservice()); - bean.setAddress(rekvirentAddress + "/Rekvirent"); - bean.setFeatures(featureList); - setupWSSEServer(bean, rekvirentEncrypt, rekvirentSign); - return bean.create(); - } - - @Bean - public Server utlevererEndpoint() { - var bean = new JaxWsServerFactoryBean(); - bean.setServiceBean(new UtlevererWebservice()); - bean.setAddress(utlevererAddress + "/Utleverer"); - bean.setFeatures(featureList); - setupWSSEServer(bean, utlevererEncrypt, utlevererSign); - return bean.create(); + LocalConfiguration() { + var loggingFeature = new LoggingFeature(); + loggingFeature.setPrettyLogging(true); + featureList.add(loggingFeature); + } } }