From bae3fe16635bf61feb75fb2f26963d5f8a6c19c6 Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 22 Sep 2024 13:16:43 +0200 Subject: [PATCH] Rename template stuff --- README.md | 24 ++++++------- build.gradle.kts | 2 +- lefthook.yml | 35 +++++++++++++++++++ settings.gradle.kts | 2 +- .../{template => a2j}/Application.java | 2 +- .../{template => a2j}/Generated.java | 2 +- .../config/SecurityConfig.java | 2 +- .../a2j/controller/SenderController.java | 18 ++++++++++ .../resources/public/.well-known/security.txt | 2 +- .../ArchitectureFitnessTest.java | 2 +- .../HealthEndpointIntegrationTest.java | 2 +- .../SecurityTxtIntegrationTest.java | 2 +- 12 files changed, 74 insertions(+), 21 deletions(-) create mode 100644 lefthook.yml rename src/main/java/de/bund/digitalservice/{template => a2j}/Application.java (87%) rename src/main/java/de/bund/digitalservice/{template => a2j}/Generated.java (90%) rename src/main/java/de/bund/digitalservice/{template => a2j}/config/SecurityConfig.java (94%) create mode 100644 src/main/java/de/bund/digitalservice/a2j/controller/SenderController.java rename src/test/java/de/bund/digitalservice/{template => a2j}/ArchitectureFitnessTest.java (95%) rename src/test/java/de/bund/digitalservice/{template => a2j}/HealthEndpointIntegrationTest.java (93%) rename src/test/java/de/bund/digitalservice/{template => a2j}/SecurityTxtIntegrationTest.java (95%) diff --git a/README.md b/README.md index fb7c8fe..2f8d764 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Java Application Template -[![Pipeline](https://github.com/digitalservicebund/java-application-template/actions/workflows/pipeline.yml/badge.svg)](https://github.com/digitalservicebund/java-application-template/actions/workflows/pipeline.yml) -[![Scan](https://github.com/digitalservicebund/java-application-template/actions/workflows/scan.yml/badge.svg)](https://github.com/digitalservicebund/java-application-template/actions/workflows/scan.yml) -[![Secrets Check](https://github.com/digitalservicebund/java-application-template/actions/workflows/secrets-check.yml/badge.svg)](https://github.com/digitalservicebund/java-application-template/actions/workflows/secrets-check.yml) +[![Pipeline](https://github.com/digitalservicebund/fit-connect-adapter/actions/workflows/pipeline.yml/badge.svg)](https://github.com/digitalservicebund/fit-connect-adapter/actions/workflows/pipeline.yml) +[![Scan](https://github.com/digitalservicebund/fit-connect-adapter/actions/workflows/scan.yml/badge.svg)](https://github.com/digitalservicebund/fit-connect-adapter/actions/workflows/scan.yml) +[![Secrets Check](https://github.com/digitalservicebund/fit-connect-adapter/actions/workflows/secrets-check.yml/badge.svg)](https://github.com/digitalservicebund/fit-connect-adapter/actions/workflows/secrets-check.yml) Java service built with the [Spring WebFlux reactive stack](https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#spring-webflux). @@ -110,7 +110,7 @@ token provided as `SONAR_TOKEN` repository secret that needs to be obtained from SONAR_TOKEN=[sonar-token] ./gradlew sonarqube ``` -Go to [https://sonarcloud.io](https://sonarcloud.io/dashboard?id=digitalservicebund_java-application-template) +Go to [https://sonarcloud.io](https://sonarcloud.io/dashboard?id=digitalservicebund_fit-connect-adapter) for the analysis results. ## Container image @@ -121,7 +121,7 @@ the [GitHub Packages Container registry](https://docs.github.com/en/packages/wor **To run the latest published image:** ```bash -docker run -p8080:8080 "ghcr.io/digitalservicebund/java-application-template:$(git log -1 origin/main --format='%H')" +docker run -p8080:8080 "ghcr.io/digitalservicebund/fit-connect-adapter:$(git log -1 origin/main --format='%H')" ``` The service will be accessible at `http://localhost:8080`. @@ -130,7 +130,7 @@ We are using Spring's built-in support for producing an optimized container imag ```bash ./gradlew bootBuildImage -docker run -p8080:8080 ghcr.io/digitalservicebund/java-application-template +docker run -p8080:8080 ghcr.io/digitalservicebund/fit-connect-adapter ``` Container images in the registry are [signed with keyless signatures](https://github.com/sigstore/cosign/blob/main/KEYLESS.md). @@ -138,7 +138,7 @@ Container images in the registry are [signed with keyless signatures](https://gi **To verify an image**: ```bash -cosign verify "ghcr.io/digitalservicebund/java-application-template:$(git log -1 origin/main --format='%H')" --certificate-identity="https://github.com/digitalservicebund/java-application-template/.github/workflows/pipeline.yml@refs/heads/main" --certificate-oidc-issuer="https://token.actions.githubusercontent.com" +cosign verify "ghcr.io/digitalservicebund/fit-connect-adapter:$(git log -1 origin/main --format='%H')" --certificate-identity="https://github.com/digitalservicebund/fit-connect-adapter/.github/workflows/pipeline.yml@refs/heads/main" --certificate-oidc-issuer="https://token.actions.githubusercontent.com" ``` If you need to push a new container image to the registry manually there are two ways to do this: @@ -147,7 +147,7 @@ If you need to push a new container image to the registry manually there are two ```bash export CONTAINER_REGISTRY=ghcr.io -export CONTAINER_IMAGE_NAME=digitalservicebund/java-application-template +export CONTAINER_IMAGE_NAME=digitalservicebund/fit-connect-adapter export CONTAINER_IMAGE_VERSION="$(git log -1 --format='%H')" CONTAINER_REGISTRY_USER=[github-user] CONTAINER_REGISTRY_PASSWORD=[github-token] ./gradlew bootBuildImage --publishImage ``` @@ -158,7 +158,7 @@ CONTAINER_REGISTRY_USER=[github-user] CONTAINER_REGISTRY_PASSWORD=[github-token] ```bash echo [github-token] | docker login ghcr.io -u [github-user] --password-stdin -docker push "ghcr.io/digitalservicebund/java-application-template:$(git log -1 --format='%H')" +docker push "ghcr.io/digitalservicebund/fit-connect-adapter:$(git log -1 --format='%H')" ``` **Note:** Make sure you're using a GitHub token with the necessary `write:packages` scope for this to work. @@ -179,7 +179,7 @@ brew install aquasecurity/trivy/trivy ```bash ./gradlew bootBuildImage -trivy image --severity HIGH,CRITICAL ghcr.io/digitalservicebund/java-application-template:latest +trivy image --severity HIGH,CRITICAL ghcr.io/digitalservicebund/fit-connect-adapter:latest ``` As part of the automated vulnerability scanning we are generating a Cosign vulnerability scan record using Trivy, @@ -218,12 +218,12 @@ with the name `SLACK_WEBHOOK_URL`, containing a url for [Incoming Webhooks](http ## Contributing 🇬🇧 -Everyone is welcome to contribute the development of the _java-application-template_. You can contribute by opening pull request, +Everyone is welcome to contribute the development of the _fit-connect-adapter_. You can contribute by opening pull request, providing documentation or answering questions or giving feedback. Please always follow the guidelines and our [Code of Conduct](CODE_OF_CONDUCT.md). 🇩🇪 -Jede:r ist herzlich eingeladen, die Entwicklung der _java-application-template_ mitzugestalten. Du kannst einen Beitrag leisten, +Jede:r ist herzlich eingeladen, die Entwicklung der _fit-connect-adapter_ mitzugestalten. Du kannst einen Beitrag leisten, indem du Pull-Requests eröffnest, die Dokumentation erweiterst, Fragen beantwortest oder Feedback gibst. Bitte befolge immer die Richtlinien und unseren [Verhaltenskodex](CODE_OF_CONDUCT_DE.md). diff --git a/build.gradle.kts b/build.gradle.kts index 397888d..d2dc2ff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -161,7 +161,7 @@ sonar { // NOTE: sonarqube picks up combined coverage correctly without further configuration from: // build/reports/jacoco/test/jacocoTestReport.xml properties { - property("sonar.projectKey", "digitalservicebund_java-application-template") + property("sonar.projectKey", "digitalservicebund_fit-connect-adapter") property("sonar.organization", "digitalservicebund") property("sonar.host.url", "https://sonarcloud.io") } diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..0f013f5 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,35 @@ +# EXAMPLE USAGE: +# +# Refer for explanation to following link: +# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md +# +# pre-push: +# commands: +# packages-audit: +# tags: frontend security +# run: yarn audit +# gems-audit: +# tags: backend security +# run: bundle audit +# +# pre-commit: +# parallel: true +# commands: +# eslint: +# glob: "*.{js,ts,jsx,tsx}" +# run: yarn eslint {staged_files} +# rubocop: +# tags: backend style +# glob: "*.rb" +# exclude: "application.rb|routes.rb" +# run: bundle exec rubocop --force-exclusion {all_files} +# govet: +# tags: backend style +# files: git ls-files -m +# glob: "*.go" +# run: go vet {files} +# scripts: +# "hello.js": +# runner: node +# "any.go": +# runner: go run diff --git a/settings.gradle.kts b/settings.gradle.kts index 08e97a9..44a4086 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "java-application-template" +rootProject.name = "fit-connect-adapter" diff --git a/src/main/java/de/bund/digitalservice/template/Application.java b/src/main/java/de/bund/digitalservice/a2j/Application.java similarity index 87% rename from src/main/java/de/bund/digitalservice/template/Application.java rename to src/main/java/de/bund/digitalservice/a2j/Application.java index bd85e87..c313eca 100644 --- a/src/main/java/de/bund/digitalservice/template/Application.java +++ b/src/main/java/de/bund/digitalservice/a2j/Application.java @@ -1,4 +1,4 @@ -package de.bund.digitalservice.template; +package de.bund.digitalservice.a2j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/src/main/java/de/bund/digitalservice/template/Generated.java b/src/main/java/de/bund/digitalservice/a2j/Generated.java similarity index 90% rename from src/main/java/de/bund/digitalservice/template/Generated.java rename to src/main/java/de/bund/digitalservice/a2j/Generated.java index e54e05d..ea7b1af 100644 --- a/src/main/java/de/bund/digitalservice/template/Generated.java +++ b/src/main/java/de/bund/digitalservice/a2j/Generated.java @@ -1,4 +1,4 @@ -package de.bund.digitalservice.template; +package de.bund.digitalservice.a2j; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; diff --git a/src/main/java/de/bund/digitalservice/template/config/SecurityConfig.java b/src/main/java/de/bund/digitalservice/a2j/config/SecurityConfig.java similarity index 94% rename from src/main/java/de/bund/digitalservice/template/config/SecurityConfig.java rename to src/main/java/de/bund/digitalservice/a2j/config/SecurityConfig.java index 9b9b34b..e8832eb 100644 --- a/src/main/java/de/bund/digitalservice/template/config/SecurityConfig.java +++ b/src/main/java/de/bund/digitalservice/a2j/config/SecurityConfig.java @@ -1,4 +1,4 @@ -package de.bund.digitalservice.template.config; +package de.bund.digitalservice.a2j.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/de/bund/digitalservice/a2j/controller/SenderController.java b/src/main/java/de/bund/digitalservice/a2j/controller/SenderController.java new file mode 100644 index 0000000..fa1d687 --- /dev/null +++ b/src/main/java/de/bund/digitalservice/a2j/controller/SenderController.java @@ -0,0 +1,18 @@ +package de.bund.digitalservice.a2j.controller; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/sender") +public class SenderController { + public SenderController() {} + + @PostMapping("/submit") + public ResponseEntity submitMessage(@RequestBody String message) { + return ResponseEntity.ok("Received message: " + message); + } +} diff --git a/src/main/resources/public/.well-known/security.txt b/src/main/resources/public/.well-known/security.txt index 5767339..0764d6a 100644 --- a/src/main/resources/public/.well-known/security.txt +++ b/src/main/resources/public/.well-known/security.txt @@ -1,7 +1,7 @@ Contact: mailto:security@digitalservice.bund.de Expires: 2022-12-31T23:59:59.000Z Preferred-Languages: en, de -Policy: https://raw.githubusercontent.com/digitalservicebund/java-application-template/main/SECURITY.md +Policy: https://raw.githubusercontent.com/digitalservicebund/fit-connect-adapter/main/SECURITY.md # TODO: Update the canonical URI below and remove this comment Canonical: https://example.com/.well-known/security.txt Hiring: https://digitalservice.bund.de/en/career diff --git a/src/test/java/de/bund/digitalservice/template/ArchitectureFitnessTest.java b/src/test/java/de/bund/digitalservice/a2j/ArchitectureFitnessTest.java similarity index 95% rename from src/test/java/de/bund/digitalservice/template/ArchitectureFitnessTest.java rename to src/test/java/de/bund/digitalservice/a2j/ArchitectureFitnessTest.java index d9a1201..c636450 100644 --- a/src/test/java/de/bund/digitalservice/template/ArchitectureFitnessTest.java +++ b/src/test/java/de/bund/digitalservice/a2j/ArchitectureFitnessTest.java @@ -1,4 +1,4 @@ -package de.bund.digitalservice.template; +package de.bund.digitalservice.a2j; import com.tngtech.archunit.core.domain.JavaClasses; import com.tngtech.archunit.core.importer.ClassFileImporter; diff --git a/src/test/java/de/bund/digitalservice/template/HealthEndpointIntegrationTest.java b/src/test/java/de/bund/digitalservice/a2j/HealthEndpointIntegrationTest.java similarity index 93% rename from src/test/java/de/bund/digitalservice/template/HealthEndpointIntegrationTest.java rename to src/test/java/de/bund/digitalservice/a2j/HealthEndpointIntegrationTest.java index 16fda3d..9a3bdac 100644 --- a/src/test/java/de/bund/digitalservice/template/HealthEndpointIntegrationTest.java +++ b/src/test/java/de/bund/digitalservice/a2j/HealthEndpointIntegrationTest.java @@ -1,4 +1,4 @@ -package de.bund.digitalservice.template; +package de.bund.digitalservice.a2j; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; diff --git a/src/test/java/de/bund/digitalservice/template/SecurityTxtIntegrationTest.java b/src/test/java/de/bund/digitalservice/a2j/SecurityTxtIntegrationTest.java similarity index 95% rename from src/test/java/de/bund/digitalservice/template/SecurityTxtIntegrationTest.java rename to src/test/java/de/bund/digitalservice/a2j/SecurityTxtIntegrationTest.java index 58f6659..dd7a781 100644 --- a/src/test/java/de/bund/digitalservice/template/SecurityTxtIntegrationTest.java +++ b/src/test/java/de/bund/digitalservice/a2j/SecurityTxtIntegrationTest.java @@ -1,4 +1,4 @@ -package de.bund.digitalservice.template; +package de.bund.digitalservice.a2j; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Tag;