From f40ed22c54914e70d0509053d55abae7b53bc5c6 Mon Sep 17 00:00:00 2001 From: Gato Date: Mon, 25 May 2026 06:56:28 +0200 Subject: [PATCH 1/6] =?UTF-8?q?correction=20pb=20d'=C3=A9criture=20pour=20?= =?UTF-8?q?merge=20dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/sync-develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/sync-develop.yml b/.gitea/workflows/sync-develop.yml index 3e9a0f3..3eceed7 100644 --- a/.gitea/workflows/sync-develop.yml +++ b/.gitea/workflows/sync-develop.yml @@ -25,7 +25,7 @@ jobs: run: | RELEASE_BRANCH="${{ github.event.pull_request.head.ref }}" - curl -X POST \ + curl --fail-with-body -X POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -H "Content-Type: application/json" \ -d "{ From ee9777132ae454637ee0c0f77fd1bd8430635794 Mon Sep 17 00:00:00 2001 From: Gato Date: Mon, 25 May 2026 07:06:59 +0200 Subject: [PATCH 2/6] ajout api version --- build.gradle | 4 ++++ .../api/adapter/in/web/VersionController.java | 24 +++++++++++++++++++ .../fr/bonsai/api/config/SecurityConfig.java | 1 + 3 files changed, 29 insertions(+) create mode 100644 src/main/java/fr/bonsai/api/adapter/in/web/VersionController.java diff --git a/build.gradle b/build.gradle index 2fe3242..e499611 100644 --- a/build.gradle +++ b/build.gradle @@ -36,3 +36,7 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + +springBoot { + buildInfo() +} diff --git a/src/main/java/fr/bonsai/api/adapter/in/web/VersionController.java b/src/main/java/fr/bonsai/api/adapter/in/web/VersionController.java new file mode 100644 index 0000000..2b4ceab --- /dev/null +++ b/src/main/java/fr/bonsai/api/adapter/in/web/VersionController.java @@ -0,0 +1,24 @@ +package fr.bonsai.api.adapter.in.web; + +import org.springframework.boot.info.BuildProperties; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/version") +public class VersionController { + + private final BuildProperties buildProperties; + + public VersionController(BuildProperties buildProperties) { + this.buildProperties = buildProperties; + } + + @GetMapping + public VersionResponse get() { + return new VersionResponse(buildProperties.getVersion()); + } + + public record VersionResponse(String version) {} +} diff --git a/src/main/java/fr/bonsai/api/config/SecurityConfig.java b/src/main/java/fr/bonsai/api/config/SecurityConfig.java index 0221ad3..f0d5525 100644 --- a/src/main/java/fr/bonsai/api/config/SecurityConfig.java +++ b/src/main/java/fr/bonsai/api/config/SecurityConfig.java @@ -22,6 +22,7 @@ public class SecurityConfig { session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .authorizeHttpRequests(auth -> auth .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() + .requestMatchers(HttpMethod.GET, "/version").permitAll() .anyRequest().authenticated() ) .oauth2ResourceServer(oauth2 -> oauth2 From 5761b0e0c407275bfab06b666f829f34a7046556 Mon Sep 17 00:00:00 2001 From: Gato Date: Mon, 25 May 2026 07:08:28 +0200 Subject: [PATCH 3/6] Ajoute swagger --- build.gradle | 1 + src/main/java/fr/bonsai/api/config/SecurityConfig.java | 1 + src/main/resources/application.yml | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/build.gradle b/build.gradle index e499611..bf840a5 100644 --- a/build.gradle +++ b/build.gradle @@ -20,6 +20,7 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.6' implementation 'org.springframework.boot:spring-boot-starter-actuator' implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' diff --git a/src/main/java/fr/bonsai/api/config/SecurityConfig.java b/src/main/java/fr/bonsai/api/config/SecurityConfig.java index f0d5525..63557bd 100644 --- a/src/main/java/fr/bonsai/api/config/SecurityConfig.java +++ b/src/main/java/fr/bonsai/api/config/SecurityConfig.java @@ -23,6 +23,7 @@ public class SecurityConfig { .authorizeHttpRequests(auth -> auth .requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() .requestMatchers(HttpMethod.GET, "/version").permitAll() + .requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/swagger-ui.html").permitAll() .anyRequest().authenticated() ) .oauth2ResourceServer(oauth2 -> oauth2 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index cf85e1c..6654e40 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -18,6 +18,12 @@ spring: jwt: jwk-set-uri: ${KEYCLOAK_JWKS_URI:https://auth.goutailler-olivier.com/realms/bonsai/protocol/openid-connect/certs} +springdoc: + api-docs: + path: /v3/api-docs + swagger-ui: + path: /swagger-ui.html + app: cors: allowed-origins: "http://localhost:4200,${CORS_ALLOWED_ORIGIN_PROD:https://bonsai.goutailler-olivier.com}" From 5948e745969868b145f3b81d863b8880af66c142 Mon Sep 17 00:00:00 2001 From: Gato Date: Mon, 25 May 2026 07:25:56 +0200 Subject: [PATCH 4/6] correction pb buil jar --- .gitea/workflows/release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 918e414..aea72fb 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -13,12 +13,12 @@ jobs: - name: Checkout uses: https://github.com/actions/checkout@v4 - - name: Setup Java 25 - uses: https://github.com/actions/setup-java@v4 - with: - java-version: '25' - distribution: 'temurin' - cache: 'gradle' + - name: Install Java 25 + run: | + wget -q https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25.0.3%2B9/OpenJDK25U-jdk_x64_alpine-linux_hotspot_25.0.3_9.tar.gz + tar -xzf OpenJDK25U-jdk_x64_alpine-linux_hotspot_25.0.3_9.tar.gz -C /opt + echo "JAVA_HOME=/opt/jdk-25.0.3+9" >> $GITHUB_ENV + echo "/opt/jdk-25.0.3+9/bin" >> $GITHUB_PATH - name: Build JAR run: ./gradlew build -x test From fc89568b37c289b5b37dc219415ed951facba4a8 Mon Sep 17 00:00:00 2001 From: Gato Date: Mon, 25 May 2026 18:03:02 +0200 Subject: [PATCH 5/6] =?UTF-8?q?Correction=20probl=C3=A8me=20404=20en=20pro?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/sync-develop.yml | 13 ++++++++----- src/main/resources/application.yml | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/sync-develop.yml b/.gitea/workflows/sync-develop.yml index 3eceed7..8e17da7 100644 --- a/.gitea/workflows/sync-develop.yml +++ b/.gitea/workflows/sync-develop.yml @@ -21,17 +21,20 @@ jobs: - name: Install curl run: apk add --no-cache curl - - name: Create PR release → develop + - name: Create PR main → develop run: | RELEASE_BRANCH="${{ github.event.pull_request.head.ref }}" - - curl --fail-with-body -X POST \ + + STATUS=$(curl -s -o /tmp/pr_response.json -w "%{http_code}" -X POST \ -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ -H "Content-Type: application/json" \ -d "{ \"title\": \"chore: sync ${RELEASE_BRANCH} into develop\", - \"head\": \"${RELEASE_BRANCH}\", + \"head\": \"main\", \"base\": \"develop\", \"body\": \"Synchronisation automatique après merge de ${RELEASE_BRANCH} dans main.\" }" \ - "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/pulls" \ No newline at end of file + "https://git.goutailler-olivier.com/api/v1/repos/${{ gitea.repository }}/pulls") + echo "POST /pulls → HTTP $STATUS" + cat /tmp/pr_response.json + [ "$STATUS" = "201" ] || exit 1 \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6654e40..2b20991 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,7 @@ server: port: 8080 + servlet: + context-path: /api spring: datasource: From 51a38b827f401bc45ce4e95bf49a0ecc844ef030 Mon Sep 17 00:00:00 2001 From: Gato Date: Mon, 25 May 2026 18:37:05 +0200 Subject: [PATCH 6/6] =?UTF-8?q?cr=C3=A9er=20collection=20bruno=20pour=20te?= =?UTF-8?q?st=20d'api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bruno/.gitignore | 1 + bruno/auth/get-token.bru | 24 ++++++++++++++++++++++++ bruno/bruno.json | 6 ++++++ bruno/environments/local.bru | 12 ++++++++++++ bruno/environments/prod.bru | 11 +++++++++++ bruno/issues/create.bru | 32 ++++++++++++++++++++++++++++++++ bruno/issues/delete.bru | 15 +++++++++++++++ bruno/issues/get-all.bru | 15 +++++++++++++++ bruno/issues/update.bru | 32 ++++++++++++++++++++++++++++++++ bruno/version/get-version.bru | 11 +++++++++++ 10 files changed, 159 insertions(+) create mode 100644 bruno/.gitignore create mode 100644 bruno/auth/get-token.bru create mode 100644 bruno/bruno.json create mode 100644 bruno/environments/local.bru create mode 100644 bruno/environments/prod.bru create mode 100644 bruno/issues/create.bru create mode 100644 bruno/issues/delete.bru create mode 100644 bruno/issues/get-all.bru create mode 100644 bruno/issues/update.bru create mode 100644 bruno/version/get-version.bru diff --git a/bruno/.gitignore b/bruno/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/bruno/.gitignore @@ -0,0 +1 @@ +.env diff --git a/bruno/auth/get-token.bru b/bruno/auth/get-token.bru new file mode 100644 index 0000000..2c584df --- /dev/null +++ b/bruno/auth/get-token.bru @@ -0,0 +1,24 @@ +meta { + name: Get Token + type: http + seq: 1 +} + +post { + url: {{keycloakUrl}}/protocol/openid-connect/token + body: formUrlEncoded + auth: none +} + +body:form-urlencoded { + grant_type: password + client_id: {{clientId}} + username: {{username}} + password: {{password}} +} + +script:post-response { + if (res.status === 200) { + bru.setEnvVar("accessToken", res.body.access_token); + } +} diff --git a/bruno/bruno.json b/bruno/bruno.json new file mode 100644 index 0000000..ea0c7d8 --- /dev/null +++ b/bruno/bruno.json @@ -0,0 +1,6 @@ +{ + "version": "1", + "name": "Bonsai API", + "type": "collection", + "ignore": [] +} diff --git a/bruno/environments/local.bru b/bruno/environments/local.bru new file mode 100644 index 0000000..2fe23ff --- /dev/null +++ b/bruno/environments/local.bru @@ -0,0 +1,12 @@ +vars { + baseUrl: http://localhost:8080/api + keycloakUrl: https://auth.goutailler-olivier.com/realms/bonsai + clientId: bonsai-webapp +} + +vars:secret [ + username, + password, + clientSecret, + accessToken +] diff --git a/bruno/environments/prod.bru b/bruno/environments/prod.bru new file mode 100644 index 0000000..9d5e409 --- /dev/null +++ b/bruno/environments/prod.bru @@ -0,0 +1,11 @@ +vars { + baseUrl: https://bonsai.goutailler-olivier.com/api + keycloakUrl: https://auth.goutailler-olivier.com/realms/bonsai + clientId: bonsai-webapp +} +vars:secret [ + username, + password, + clientSecret, + accessToken +] diff --git a/bruno/issues/create.bru b/bruno/issues/create.bru new file mode 100644 index 0000000..6c98160 --- /dev/null +++ b/bruno/issues/create.bru @@ -0,0 +1,32 @@ +meta { + name: Create Issue + type: http + seq: 2 +} + +post { + url: {{baseUrl}}/issues + body: json + auth: bearer +} + +auth:bearer { + token: {{accessToken}} +} + +body:json { + { + "type": "Story", + "name": "Nouvelle issue", + "priority": "Moyenne", + "status": "todo", + "progress": 0, + "assignee": null, + "epic": null, + "dueDate": null, + "description": null, + "estimatedTime": null, + "dependsOnIds": [], + "comments": [] + } +} diff --git a/bruno/issues/delete.bru b/bruno/issues/delete.bru new file mode 100644 index 0000000..053b226 --- /dev/null +++ b/bruno/issues/delete.bru @@ -0,0 +1,15 @@ +meta { + name: Delete Issue + type: http + seq: 4 +} + +delete { + url: {{baseUrl}}/issues/1 + body: none + auth: bearer +} + +auth:bearer { + token: {{accessToken}} +} diff --git a/bruno/issues/get-all.bru b/bruno/issues/get-all.bru new file mode 100644 index 0000000..eb4b7f8 --- /dev/null +++ b/bruno/issues/get-all.bru @@ -0,0 +1,15 @@ +meta { + name: Get All Issues + type: http + seq: 1 +} + +get { + url: {{baseUrl}}/issues + body: none + auth: bearer +} + +auth:bearer { + token: {{accessToken}} +} diff --git a/bruno/issues/update.bru b/bruno/issues/update.bru new file mode 100644 index 0000000..96ef3ce --- /dev/null +++ b/bruno/issues/update.bru @@ -0,0 +1,32 @@ +meta { + name: Update Issue + type: http + seq: 3 +} + +put { + url: {{baseUrl}}/issues/1 + body: json + auth: bearer +} + +auth:bearer { + token: {{accessToken}} +} + +body:json { + { + "type": "Story", + "name": "Issue mise à jour", + "priority": "Haute", + "status": "in-progress", + "progress": 50, + "assignee": null, + "epic": null, + "dueDate": "2026-06-01", + "description": null, + "estimatedTime": 3.5, + "dependsOnIds": [], + "comments": [] + } +} diff --git a/bruno/version/get-version.bru b/bruno/version/get-version.bru new file mode 100644 index 0000000..c92f3d3 --- /dev/null +++ b/bruno/version/get-version.bru @@ -0,0 +1,11 @@ +meta { + name: Get Version + type: http + seq: 1 +} + +get { + url: {{baseUrl}}/version + body: none + auth: none +}