From d2cc3e00e103c37983a91ebbc0c70875429e0efe Mon Sep 17 00:00:00 2001 From: Pierre Tellier Date: Tue, 11 Feb 2025 10:07:00 +0100 Subject: [PATCH 01/10] fix: Makefile now build correctly production environment --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6944ef4..26d5ccb 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ dev-front: clean vite prod: clean @cp config/prod.front.env front/MyINPulse-front/.env @cp config/prod.main.env .env - @cp config/frontdev.docker-compose.yaml docker-compose.yaml + @cp config/prod.docker-compose.yaml docker-compose.yaml @docker compose up -d --build From eed4e6f85586c4e2f1712f8714cb26ce04241897 Mon Sep 17 00:00:00 2001 From: Pierre Tellier Date: Tue, 11 Feb 2025 11:07:45 +0100 Subject: [PATCH 02/10] feat: multiple database and user in postgres --- .gitignore | 1 + config/backdev.docker-compose.yaml | 13 ++++++------- config/backdev.main.env | 16 ++++++++++------ config/frontdev.docker-compose.yaml | 12 ++++++------ config/frontdev.main.env | 16 ++++++++++++---- config/prod.docker-compose.yaml | 7 +++++-- config/prod.main.env | 16 ++++++++++++---- postgres/Dockerfile | 5 +++++ postgres/create_db.sh | 17 +++++++++++++++++ postgres/create_user.sh | 16 ++++++++++++++++ 10 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 postgres/Dockerfile create mode 100644 postgres/create_db.sh create mode 100644 postgres/create_user.sh diff --git a/.gitignore b/.gitignore index 170ba0d..7117a86 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea keycloak/CAS/target docker-compose.yaml +postgres/data \ No newline at end of file diff --git a/config/backdev.docker-compose.yaml b/config/backdev.docker-compose.yaml index 607fa49..25151a0 100644 --- a/config/backdev.docker-compose.yaml +++ b/config/backdev.docker-compose.yaml @@ -1,15 +1,14 @@ services: postgres: - image: postgres:latest + env_file: .env + build: + context: postgres/ + dockerfile: Dockerfile container_name: MyINPulse-DB ports: - - 5432:5432 + - 5433:5432 volumes: - - ./postgres:/var/lib/postgresql/data - environment: - POSTGRES_DB: ${POSTGRES_DB} - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + - ./postgres/data:/var/lib/postgresql/data keycloak: container_name: MyINPulse-keycloak diff --git a/config/backdev.main.env b/config/backdev.main.env index 6ddb261..2a597c3 100644 --- a/config/backdev.main.env +++ b/config/backdev.main.env @@ -1,10 +1,14 @@ -POSTGRES_DB=keycloak_db -POSTGRES_USER=keycloak_db_user -POSTGRES_PASSWORD=keycloak_db_user_password +POSTGRES_DB=postgres_db +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres_db_user_password + KEYCLOAK_ADMIN=admin KEYCLOAK_ADMIN_PASSWORD=admin KEYCLOAK_HOSTNAME=localhost +KEYCLOAK_DB=keycloak_db +KEYCLOAK_USER=keycloak_db_user +KEYCLOAK_PASSWORD=keycloak_db_user_password -MYINPULSE_DB=MyINPulse_db -MYINPULSE_DB_USER=MyINPulse_db_user -MYINPULSE_DB_PASS=MyINPulse_db_user_pass \ No newline at end of file +BACKEND_DB=backend_db +BACKEND_USER=backend_db_user +BACKEND_PASSWORD=backend_db_user_password \ No newline at end of file diff --git a/config/frontdev.docker-compose.yaml b/config/frontdev.docker-compose.yaml index aa6d0d0..529ac2c 100644 --- a/config/frontdev.docker-compose.yaml +++ b/config/frontdev.docker-compose.yaml @@ -1,15 +1,15 @@ services: postgres: - image: postgres:latest + env_file: .env + build: + context: postgres/ + dockerfile: Dockerfile container_name: MyINPulse-DB #ports: # - 5432:5432 volumes: - - ./postgres:/var/lib/postgresql/data - environment: - POSTGRES_DB: ${POSTGRES_DB} - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + - ./postgres/data:/var/lib/postgresql/data + keycloak: container_name: MyINPulse-keycloak diff --git a/config/frontdev.main.env b/config/frontdev.main.env index 6f32124..26c2803 100644 --- a/config/frontdev.main.env +++ b/config/frontdev.main.env @@ -1,6 +1,14 @@ -POSTGRES_DB=keycloak_db -POSTGRES_USER=keycloak_db_user -POSTGRES_PASSWORD=keycloak_db_user_password +POSTGRES_DB=postgres_db +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres_db_user_password + KEYCLOAK_ADMIN=admin KEYCLOAK_ADMIN_PASSWORD=admin -KEYCLOAK_HOSTNAME=localhost \ No newline at end of file +KEYCLOAK_HOSTNAME=localhost +KEYCLOAK_DB=keycloak_db +KEYCLOAK_USER=keycloak_db_user +KEYCLOAK_PASSWORD=keycloak_db_user_password + +BACKEND_DB=backend_db +BACKEND_USER=backend_db_user +BACKEND_PASSWORD=backend_db_user_password diff --git a/config/prod.docker-compose.yaml b/config/prod.docker-compose.yaml index fe2a3d7..51f2d76 100644 --- a/config/prod.docker-compose.yaml +++ b/config/prod.docker-compose.yaml @@ -1,11 +1,14 @@ services: postgres: - image: postgres:latest + env_file: .env + build: + context: postgres/ + dockerfile: Dockerfile container_name: MyINPulse-DB #ports: # - 5432:5432 volumes: - - ./postgres:/var/lib/postgresql/data + - ./postgres/data:/var/lib/postgresql/data environment: POSTGRES_DB: ${POSTGRES_DB} POSTGRES_USER: ${POSTGRES_USER} diff --git a/config/prod.main.env b/config/prod.main.env index e8db94b..179d92c 100644 --- a/config/prod.main.env +++ b/config/prod.main.env @@ -1,6 +1,14 @@ -POSTGRES_DB=keycloak_db -POSTGRES_USER=keycloak_db_user -POSTGRES_PASSWORD=keycloak_db_user_password +POSTGRES_DB=postgres_db +POSTGRES_USER=postgres +POSTGRES_PASSWORD=postgres_db_user_password + KEYCLOAK_ADMIN=admin KEYCLOAK_ADMIN_PASSWORD=admin -KEYCLOAK_HOSTNAME=0549cd63f912d5dc9b31278d6f.eirb.fr \ No newline at end of file +KEYCLOAK_HOSTNAME=0549cd63f912d5dc9b31278d6f.eirb.fr +KEYCLOAK_DB=keycloak_db +KEYCLOAK_USER=keycloak_db_user +KEYCLOAK_PASSWORD=keycloak_db_user_password + +BACKEND_DB=backend_db +BACKEND_USER=backend_db_user +BACKEND_PASSWORD=backend_db_user_password diff --git a/postgres/Dockerfile b/postgres/Dockerfile new file mode 100644 index 0000000..da99686 --- /dev/null +++ b/postgres/Dockerfile @@ -0,0 +1,5 @@ +FROM postgres:latest + +# Custom initialization scripts +COPY ./create_user.sh /docker-entrypoint-initdb.d/10-create_user.sh +COPY ./create_db.sh /docker-entrypoint-initdb.d/20-create_db.sh diff --git a/postgres/create_db.sh b/postgres/create_db.sh new file mode 100644 index 0000000..c1728a0 --- /dev/null +++ b/postgres/create_db.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +POSTGRES="psql --username ${POSTGRES_USER}" + +echo "Creating database: ${DB_NAME}" + +$POSTGRES < Date: Tue, 11 Feb 2025 19:04:02 +0100 Subject: [PATCH 03/10] test: check backend formatting --- .gitea/workflows/back.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .gitea/workflows/back.yaml diff --git a/.gitea/workflows/back.yaml b/.gitea/workflows/back.yaml new file mode 100644 index 0000000..0af4bc6 --- /dev/null +++ b/.gitea/workflows/back.yaml @@ -0,0 +1,13 @@ +name: check backend + +on: [ push, pull_request ] + +jobs: + + formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 # v2 minimum required + - uses: axel-op/googlejavaformat-action@v3 + with: + args: "--set-exit-if-changed --aosp" \ No newline at end of file From c7ddc37bf995e9e01e2644b57e51896f9e1c5d4e Mon Sep 17 00:00:00 2001 From: Pierre Tellier Date: Tue, 11 Feb 2025 19:12:49 +0100 Subject: [PATCH 04/10] test: changed the verification --- .gitea/workflows/back.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/back.yaml b/.gitea/workflows/back.yaml index 0af4bc6..f68f425 100644 --- a/.gitea/workflows/back.yaml +++ b/.gitea/workflows/back.yaml @@ -1,4 +1,4 @@ -name: check backend +name: Format on: [ push, pull_request ] @@ -10,4 +10,7 @@ jobs: - uses: actions/checkout@v4 # v2 minimum required - uses: axel-op/googlejavaformat-action@v3 with: - args: "--set-exit-if-changed --aosp" \ No newline at end of file + args: "--replace" + skip-commit: true + - name: Print diffs + run: git --no-pager diff --exit-code \ No newline at end of file From 0fc4be2008b208d2dab7b1824698582c1f3e7de2 Mon Sep 17 00:00:00 2001 From: Pierre Tellier Date: Tue, 11 Feb 2025 19:18:08 +0100 Subject: [PATCH 05/10] test: changed the verification --- .gitea/workflows/back.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitea/workflows/back.yaml b/.gitea/workflows/back.yaml index f68f425..91ffdd3 100644 --- a/.gitea/workflows/back.yaml +++ b/.gitea/workflows/back.yaml @@ -8,6 +8,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # v2 minimum required + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '21' - uses: axel-op/googlejavaformat-action@v3 with: args: "--replace" From c7159557584eef7b4fe75593aab97f01da0799a3 Mon Sep 17 00:00:00 2001 From: Pierre Tellier Date: Tue, 11 Feb 2025 19:20:49 +0100 Subject: [PATCH 06/10] feat: the backend validator is better --- .gitea/workflows/back.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitea/workflows/back.yaml b/.gitea/workflows/back.yaml index 91ffdd3..0e74e38 100644 --- a/.gitea/workflows/back.yaml +++ b/.gitea/workflows/back.yaml @@ -14,7 +14,6 @@ jobs: java-version: '21' - uses: axel-op/googlejavaformat-action@v3 with: - args: "--replace" - skip-commit: true + args: "--replace --skip-sorting-imports --aosp" - name: Print diffs run: git --no-pager diff --exit-code \ No newline at end of file From 45bbe51897ca81fcb27af13e8de7c559bc1c6ab9 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Tue, 11 Feb 2025 18:21:00 +0000 Subject: [PATCH 07/10] Google Java Format --- .../myinpulse/MyinpulseApplication.java | 19 +---- .../enseirb/myinpulse/api/GetUserInfo.java | 6 +- .../WebSecurityCustomConfiguration.java | 41 ++++++---- .../controller/AdministrateursController.java | 10 +-- .../controller/ComptesRendusController.java | 3 +- .../controller/EntrepreneursController.java | 18 ++--- .../controller/ProjetsController.java | 16 ++-- .../controller/RendezVousController.java | 14 ++-- .../controller/SectionsController.java | 13 +-- .../controller/UtilisateursController.java | 15 ++-- .../postgres_db/model/Administrateurs.java | 21 +++-- .../postgres_db/model/ComptesRendus.java | 4 +- .../postgres_db/model/Entrepreneurs.java | 27 +++++-- .../myinpulse/postgres_db/model/Projets.java | 17 ++-- .../postgres_db/model/RendezVous.java | 18 +++-- .../myinpulse/postgres_db/model/Sections.java | 11 ++- .../postgres_db/model/Utilisateurs.java | 21 +++-- .../repository/ComptesRendusRepository.java | 3 +- .../repository/ProjetsRepository.java | 3 +- .../repository/RendezVousRepository.java | 3 +- .../repository/SectionsRepository.java | 3 +- .../security/KeycloakJwtRolesConverter.java | 79 ++++++++++--------- .../myinpulse/MyinpulseApplicationTests.java | 6 +- 23 files changed, 205 insertions(+), 166 deletions(-) diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java index 23c2f28..1c39eef 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java @@ -1,29 +1,16 @@ package enseirb.myinpulse; -import enseirb.myinpulse.security.KeycloakJwtRolesConverter; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.core.convert.converter.Converter; -import org.springframework.security.authentication.AbstractAuthenticationToken; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.oauth2.jwt.*; -import org.springframework.security.web.SecurityFilterChain; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.CorsConfigurationSource; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import java.util.*; -import java.util.stream.Collectors; -import static org.springframework.security.authorization.AuthorityAuthorizationManager.hasRole; @SpringBootApplication public class MyinpulseApplication { - public static void main(String[] args) { - SpringApplication.run(MyinpulseApplication.class, args); - } - - + public static void main(String[] args) { + SpringApplication.run(MyinpulseApplication.class, args); + } } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/api/GetUserInfo.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/api/GetUserInfo.java index 50262e1..63aef48 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/api/GetUserInfo.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/api/GetUserInfo.java @@ -22,21 +22,21 @@ public class GetUserInfo { @CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS}) @GetMapping("/random") - public boolean rand(){ + public boolean rand() { System.err.println("HELLO"); return Math.random() > 0.5; } @CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS}) @GetMapping("/random2") - public boolean rand2(){ + public boolean rand2() { System.err.println("HELLO2"); return Math.random() > 0.5; } @CrossOrigin(methods = {RequestMethod.GET, RequestMethod.OPTIONS}) @GetMapping("/random3") - public boolean rand3(){ + public boolean rand3() { System.err.println("HELLO"); return Math.random() > 0.5; } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java index 14c46b3..e642fd8 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java @@ -23,10 +23,13 @@ public class WebSecurityCustomConfiguration { CorsConfiguration configuration = new CorsConfiguration(); configuration.setAllowedOrigins(List.of("*")); configuration.setAllowedMethods(Arrays.asList("GET", "OPTIONS")); - configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", - "x-auth-token")); // Do not remove, this fixes the CORS errors when unauthenticated - UrlBasedCorsConfigurationSource source = new - UrlBasedCorsConfigurationSource(); + configuration.setAllowedHeaders( + Arrays.asList( + "authorization", + "content-type", + "x-auth-token")); // Do not remove, this fixes the CORS errors when + // unauthenticated + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", configuration); return source; @@ -34,17 +37,23 @@ public class WebSecurityCustomConfiguration { @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { - http - .authorizeHttpRequests(authorize -> authorize - .requestMatchers("/random2").access(hasRole("REALM_MyINPulse-entrepreneur")) - .requestMatchers("/random").access(hasRole("REALM_MyINPulse-admin")) - .requestMatchers("/random3").permitAll() - .anyRequest().authenticated() - ) - .oauth2ResourceServer(oauth2 -> oauth2 - .jwt(jwt -> jwt. - jwtAuthenticationConverter(new KeycloakJwtRolesConverter()))); + http.authorizeHttpRequests( + authorize -> + authorize + .requestMatchers("/random2") + .access(hasRole("REALM_MyINPulse-entrepreneur")) + .requestMatchers("/random") + .access(hasRole("REALM_MyINPulse-admin")) + .requestMatchers("/random3") + .permitAll() + .anyRequest() + .authenticated()) + .oauth2ResourceServer( + oauth2 -> + oauth2.jwt( + jwt -> + jwt.jwtAuthenticationConverter( + new KeycloakJwtRolesConverter()))); return http.build(); - } -} \ No newline at end of file +} diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/AdministrateursController.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/AdministrateursController.java index 5f1a718..f27240e 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/AdministrateursController.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/AdministrateursController.java @@ -12,8 +12,7 @@ import java.util.Optional; @RestController public class AdministrateursController { - @Autowired - AdministrateursRepository administrateursRepository; + @Autowired AdministrateursRepository administrateursRepository; @GetMapping("/Administrateurs") @ResponseBody @@ -22,11 +21,11 @@ public class AdministrateursController { } @GetMapping("/Administrateurs/{id}") - public Administrateurs getAdministrateursById(@PathVariable Long id) - { + public Administrateurs getAdministrateursById(@PathVariable Long id) { Optional administrateur = this.administrateursRepository.findById(id); if (administrateur.isEmpty()) { - throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet administrateur n'existe pas"); + throw new ResponseStatusException( + HttpStatus.NOT_FOUND, "Cet administrateur n'existe pas"); } return administrateur.get(); } @@ -35,5 +34,4 @@ public class AdministrateursController { public Administrateurs addAdministrateurs(@RequestBody Administrateurs administrateurs) { return this.administrateursRepository.save(administrateurs); } - } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ComptesRendusController.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ComptesRendusController.java index 9bcc862..c6cccdb 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ComptesRendusController.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ComptesRendusController.java @@ -12,8 +12,7 @@ import java.util.Optional; @RestController public class ComptesRendusController { - @Autowired - ComptesRendusRepository comptesRendusRepository; + @Autowired ComptesRendusRepository comptesRendusRepository; @GetMapping("/ComptesRendus") @ResponseBody diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/EntrepreneursController.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/EntrepreneursController.java index 2bbc653..e07c359 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/EntrepreneursController.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/EntrepreneursController.java @@ -3,19 +3,16 @@ package enseirb.myinpulse.postgres_db.controller; import enseirb.myinpulse.postgres_db.repository.EntrepreneursRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; import org.springframework.web.bind.annotation.*; import enseirb.myinpulse.postgres_db.model.Entrepreneurs; import org.springframework.web.server.ResponseStatusException; import java.util.Optional; - @RestController public class EntrepreneursController { - @Autowired - EntrepreneursRepository entrepreneursRepository; + @Autowired EntrepreneursRepository entrepreneursRepository; @GetMapping("/Entrepreneurs") @ResponseBody @@ -24,11 +21,11 @@ public class EntrepreneursController { } @GetMapping("/Entrepreneurs/{id}") - public Entrepreneurs getEntrepreneursById(@PathVariable Long id) - { + public Entrepreneurs getEntrepreneursById(@PathVariable Long id) { Optional entrepreneur = entrepreneursRepository.findById(id); if (entrepreneur.isEmpty()) { - throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas"); + throw new ResponseStatusException( + HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas"); } return entrepreneur.get(); } @@ -39,10 +36,12 @@ public class EntrepreneursController { } @PostMapping("/Entrepreneurs/{id}") - public Entrepreneurs updateEntrepreneurs(@PathVariable Long id, String ecole, String filiere, Boolean status_snee) { + public Entrepreneurs updateEntrepreneurs( + @PathVariable Long id, String ecole, String filiere, Boolean status_snee) { Optional entrepreneur = entrepreneursRepository.findById(id); if (entrepreneur.isEmpty()) { - throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas"); + throw new ResponseStatusException( + HttpStatus.NOT_FOUND, "Cet entrepreneur n'existe pas"); } if (ecole != null) { entrepreneur.get().setEcole(ecole); @@ -55,5 +54,4 @@ public class EntrepreneursController { } return entrepreneur.get(); } - } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ProjetsController.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ProjetsController.java index 92b5908..2f11474 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ProjetsController.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/ProjetsController.java @@ -13,8 +13,7 @@ import java.util.Optional; @RestController public class ProjetsController { - @Autowired - ProjetsRepository projetsRepository; + @Autowired ProjetsRepository projetsRepository; @GetMapping("/Projets") @ResponseBody @@ -23,8 +22,7 @@ public class ProjetsController { } @GetMapping("/Projets/{id}") - public Projets getProjetsById(@PathVariable Long id) - { + public Projets getProjetsById(@PathVariable Long id) { Optional projet = this.projetsRepository.findById(id); if (projet.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce projet n'existe pas"); @@ -38,7 +36,12 @@ public class ProjetsController { } @PostMapping("/Projets/{id}") - public Projets updateProjets(@PathVariable Long id, String nom_projet, Byte[] logo, LocalDate date_creation, String status_projet) { + public Projets updateProjets( + @PathVariable Long id, + String nom_projet, + Byte[] logo, + LocalDate date_creation, + String status_projet) { Optional projet = this.projetsRepository.findById(id); if (projet.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce projet n'existe pas"); @@ -57,5 +60,4 @@ public class ProjetsController { } return projet.get(); } - -} \ No newline at end of file +} diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/RendezVousController.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/RendezVousController.java index aa9e3ba..0ec0b0c 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/RendezVousController.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/RendezVousController.java @@ -14,8 +14,7 @@ import java.util.Optional; @RestController public class RendezVousController { - @Autowired - RendezVousRepository rendezVousRepository; + @Autowired RendezVousRepository rendezVousRepository; @GetMapping("/RendezVous") @ResponseBody @@ -24,8 +23,7 @@ public class RendezVousController { } @GetMapping("/RendezVous/{id}") - public RendezVous getRendezVousById(@PathVariable Long id) - { + public RendezVous getRendezVousById(@PathVariable Long id) { Optional rendezVous = this.rendezVousRepository.findById(id); if (rendezVous.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce rendez vous n'existe pas"); @@ -39,7 +37,13 @@ public class RendezVousController { } @PostMapping("/RendezVous/{id}") - public RendezVous updateRendezVous(@PathVariable Long id, LocalDate date_rdv, LocalDateTime heure_rdv, LocalDateTime duree_rdv, String lieu_rdv, String sujet_rdv) { + public RendezVous updateRendezVous( + @PathVariable Long id, + LocalDate date_rdv, + LocalDateTime heure_rdv, + LocalDateTime duree_rdv, + String lieu_rdv, + String sujet_rdv) { Optional rendezVous = this.rendezVousRepository.findById(id); if (rendezVous.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Ce rendez vous n'existe pas"); diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/SectionsController.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/SectionsController.java index 49032fe..5f065a5 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/SectionsController.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/SectionsController.java @@ -13,8 +13,7 @@ import java.util.Optional; @RestController public class SectionsController { - @Autowired - SectionsRepository sectionsRepository; + @Autowired SectionsRepository sectionsRepository; @GetMapping("/Sections") @ResponseBody @@ -23,8 +22,7 @@ public class SectionsController { } @GetMapping("/Sections/{id}") - public Sections getSectionsById(@PathVariable Long id) - { + public Sections getSectionsById(@PathVariable Long id) { Optional section = this.sectionsRepository.findById(id); if (section.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cette section n'extise pas"); @@ -38,7 +36,11 @@ public class SectionsController { } @PostMapping("/Sections/{id}") - public Sections updateSections(@PathVariable Long id, String titre, String contenu_section, LocalDateTime date_modification) { + public Sections updateSections( + @PathVariable Long id, + String titre, + String contenu_section, + LocalDateTime date_modification) { Optional section = this.sectionsRepository.findById(id); if (section.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cette section n'extise pas"); @@ -54,5 +56,4 @@ public class SectionsController { } return section.get(); } - } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/UtilisateursController.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/UtilisateursController.java index 059e2f0..040b4d0 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/UtilisateursController.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/controller/UtilisateursController.java @@ -12,8 +12,7 @@ import java.util.Optional; @RestController public class UtilisateursController { - @Autowired - UtilisateursRepository utilisateursRepository; + @Autowired UtilisateursRepository utilisateursRepository; @GetMapping("/Utilisateurs") @ResponseBody @@ -36,11 +35,18 @@ public class UtilisateursController { } @PostMapping("/Utilisateurs/{id}") - public Utilisateurs updateUtilisateurs(@PathVariable Long id, String nom_utilisateur, String prenom_utilisateur, String mail_principal, String mail_secondaire, String numero_telephone) { + public Utilisateurs updateUtilisateurs( + @PathVariable Long id, + String nom_utilisateur, + String prenom_utilisateur, + String mail_principal, + String mail_secondaire, + String numero_telephone) { Optional utilisateur = utilisateursRepository.findById(id); if (utilisateur.isEmpty()) { throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Cet utilisateur n'existe pas"); - }if (nom_utilisateur != null) { + } + if (nom_utilisateur != null) { utilisateur.get().setNom_utilisateur(nom_utilisateur); } if (prenom_utilisateur != null) { @@ -57,5 +63,4 @@ public class UtilisateursController { } return utilisateur.get(); } - } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Administrateurs.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Administrateurs.java index 0255adf..5620b9a 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Administrateurs.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Administrateurs.java @@ -10,7 +10,6 @@ import java.util.List; @Entity @Table(name = "administrateurs") @PrimaryKeyJoinColumn(name = "id_administrateur") - public class Administrateurs extends Utilisateurs { @ManyToOne(fetch = FetchType.LAZY) @@ -24,11 +23,21 @@ public class Administrateurs extends Utilisateurs { @JoinColumn(name = "RendezVous.id_rdv") private RendezVous rendezVous; - public Administrateurs() { - } + public Administrateurs() {} - public Administrateurs(String nom_utilisateur, Long id_utilisateur, String prenom_utilisateur, String mail_principal, String mail_secondaire, String numero_telephone) { - super(nom_utilisateur, id_utilisateur, prenom_utilisateur, mail_principal, mail_secondaire, numero_telephone); + public Administrateurs( + String nom_utilisateur, + Long id_utilisateur, + String prenom_utilisateur, + String mail_principal, + String mail_secondaire, + String numero_telephone) { + super( + nom_utilisateur, + id_utilisateur, + prenom_utilisateur, + mail_principal, + mail_secondaire, + numero_telephone); } - } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/ComptesRendus.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/ComptesRendus.java index cd7f283..a629e3b 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/ComptesRendus.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/ComptesRendus.java @@ -21,9 +21,7 @@ public class ComptesRendus { @JoinColumn(name = "RendezVous.id_rdv") private RendezVous rendezVous; - - public ComptesRendus() { - } + public ComptesRendus() {} public ComptesRendus(Long id_compte_rendu, String contenu_compte_rendu) { this.id_compte_rendu = id_compte_rendu; diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Entrepreneurs.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Entrepreneurs.java index b8f6964..4f73d19 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Entrepreneurs.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Entrepreneurs.java @@ -9,10 +9,10 @@ import jakarta.persistence.Table; @PrimaryKeyJoinColumn(name = "id_entrepreneur") public class Entrepreneurs extends Utilisateurs { - @Column(length=255) + @Column(length = 255) private String ecole; - @Column(length=255) + @Column(length = 255) private String filiere; private boolean status_snee; @@ -29,12 +29,25 @@ public class Entrepreneurs extends Utilisateurs { @JoinColumn(name = "RendezVous.id_rdv") private RendezVous rendezVous; + public Entrepreneurs() {} - public Entrepreneurs() { - } - - public Entrepreneurs(String nom_utilisateur, Long id_utilisateur, String prenom_utilisateur, String mail_principal, String mail_secondaire, String numero_telephone, String ecole, boolean status_snee, String filiere) { - super(nom_utilisateur, id_utilisateur, prenom_utilisateur, mail_principal, mail_secondaire, numero_telephone); + public Entrepreneurs( + String nom_utilisateur, + Long id_utilisateur, + String prenom_utilisateur, + String mail_principal, + String mail_secondaire, + String numero_telephone, + String ecole, + boolean status_snee, + String filiere) { + super( + nom_utilisateur, + id_utilisateur, + prenom_utilisateur, + mail_principal, + mail_secondaire, + numero_telephone); this.ecole = ecole; this.status_snee = status_snee; this.filiere = filiere; diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Projets.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Projets.java index 6fd8d98..63d3bc3 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Projets.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Projets.java @@ -16,14 +16,14 @@ public class Projets { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id_projet; - @Column(length=255) + @Column(length = 255) private String nom_projet; private Byte[] logo; private LocalDate date_creation; - @Column(length=255) + @Column(length = 255) private String status_projet; @OneToMany(mappedBy = "projets", fetch = FetchType.LAZY, orphanRemoval = true) @@ -41,10 +41,14 @@ public class Projets { // Hibernate expects entities to have a no-arg constructor, // though it does not necessarily have to be public. - public Projets() { - } + public Projets() {} - public Projets(Long id_projet, String nom_projet, Byte[] logo, LocalDate date_creation, String status_projet) { + public Projets( + Long id_projet, + String nom_projet, + Byte[] logo, + LocalDate date_creation, + String status_projet) { this.id_projet = id_projet; this.nom_projet = nom_projet; this.logo = logo; @@ -91,5 +95,4 @@ public class Projets { public void setStatus_projet(String status_projet) { this.status_projet = status_projet; } - -} \ No newline at end of file +} diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/RendezVous.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/RendezVous.java index 78fbfc2..55732c1 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/RendezVous.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/RendezVous.java @@ -23,7 +23,7 @@ public class RendezVous { private LocalDateTime duree_rdv; - @Column(length=255) + @Column(length = 255) private String lieu_rdv; private String sujet_rdv; @@ -37,17 +37,24 @@ public class RendezVous { @OneToMany(mappedBy = "rendez_vous", fetch = FetchType.LAZY, orphanRemoval = true) private List ListComptesRendus = new ArrayList<>(); - @ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) + @ManyToMany( + fetch = FetchType.LAZY, + cascade = {CascadeType.ALL}) @JoinTable( name = "concerner", joinColumns = @JoinColumn(name = "id_rdv"), inverseJoinColumns = @JoinColumn(name = "id_sections")) List ListSections = new ArrayList<>(); - public RendezVous() { - } + public RendezVous() {} - public RendezVous(Long id_rdv, LocalDate date_rdv, LocalDateTime heure_rdv, LocalDateTime duree_rdv, String lieu_rdv, String sujet_rdv) { + public RendezVous( + Long id_rdv, + LocalDate date_rdv, + LocalDateTime heure_rdv, + LocalDateTime duree_rdv, + String lieu_rdv, + String sujet_rdv) { this.id_rdv = id_rdv; this.date_rdv = date_rdv; this.heure_rdv = heure_rdv; @@ -103,5 +110,4 @@ public class RendezVous { public void setSujet_rdv(String sujet_rdv) { this.sujet_rdv = sujet_rdv; } - } diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Sections.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Sections.java index f5852ac..0c9d013 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Sections.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Sections.java @@ -16,7 +16,7 @@ public class Sections { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id_section; - @Column(length=255) + @Column(length = 255) private String titre; private String contenu_section; @@ -34,10 +34,13 @@ public class Sections { @ManyToMany(mappedBy = "sections") private List rendezVous = new ArrayList<>(); - public Sections() { - } + public Sections() {} - public Sections(Long id_section, String titre, String contenu_section, LocalDateTime date_modification) { + public Sections( + Long id_section, + String titre, + String contenu_section, + LocalDateTime date_modification) { this.id_section = id_section; this.titre = titre; this.contenu_section = contenu_section; diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Utilisateurs.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Utilisateurs.java index e20de6b..9d81163 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Utilisateurs.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/model/Utilisateurs.java @@ -13,25 +13,30 @@ public class Utilisateurs { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id_utilisateur; - @Column(length=255) + @Column(length = 255) private String nom_utilisateur; - @Column(length=255) + @Column(length = 255) private String prenom_utilisateur; - @Column(length=255) + @Column(length = 255) private String mail_principal; - @Column(length=255) + @Column(length = 255) private String mail_secondaire; - @Column(length=15) + @Column(length = 15) private String numero_telephone; - public Utilisateurs() { - } + public Utilisateurs() {} - public Utilisateurs(String nom_utilisateur, Long id_utilisateur, String prenom_utilisateur, String mail_principal, String mail_secondaire, String numero_telephone) { + public Utilisateurs( + String nom_utilisateur, + Long id_utilisateur, + String prenom_utilisateur, + String mail_principal, + String mail_secondaire, + String numero_telephone) { this.nom_utilisateur = nom_utilisateur; this.id_utilisateur = id_utilisateur; this.prenom_utilisateur = prenom_utilisateur; diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ComptesRendusRepository.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ComptesRendusRepository.java index 41a9c0e..e4de376 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ComptesRendusRepository.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ComptesRendusRepository.java @@ -5,5 +5,4 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource -public interface ComptesRendusRepository extends JpaRepository { -} +public interface ComptesRendusRepository extends JpaRepository {} diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ProjetsRepository.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ProjetsRepository.java index 6665c89..37f5d8e 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ProjetsRepository.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/ProjetsRepository.java @@ -5,5 +5,4 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource -public interface ProjetsRepository extends JpaRepository { -} \ No newline at end of file +public interface ProjetsRepository extends JpaRepository {} diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/RendezVousRepository.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/RendezVousRepository.java index be67f00..93074f8 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/RendezVousRepository.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/RendezVousRepository.java @@ -5,5 +5,4 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource -public interface RendezVousRepository extends JpaRepository { -} +public interface RendezVousRepository extends JpaRepository {} diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/SectionsRepository.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/SectionsRepository.java index 70411d3..cc25ab1 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/SectionsRepository.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/postgres_db/repository/SectionsRepository.java @@ -5,5 +5,4 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource -public interface SectionsRepository extends JpaRepository { -} +public interface SectionsRepository extends JpaRepository {} diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/security/KeycloakJwtRolesConverter.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/security/KeycloakJwtRolesConverter.java index fafbef5..dba41cc 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/security/KeycloakJwtRolesConverter.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/security/KeycloakJwtRolesConverter.java @@ -16,40 +16,35 @@ import java.util.stream.Stream; import static java.util.stream.Collectors.toSet; - public class KeycloakJwtRolesConverter implements Converter { - /** - * Prefix used for realm level roles. - */ + /** Prefix used for realm level roles. */ public static final String PREFIX_REALM_ROLE = "ROLE_REALM_"; - /** - * Prefix used in combination with the resource (client) name for resource level roles. - */ + + /** Prefix used in combination with the resource (client) name for resource level roles. */ public static final String PREFIX_RESOURCE_ROLE = "ROLE_"; - /** - * Name of the claim containing the realm level roles - */ + /** Name of the claim containing the realm level roles */ private static final String CLAIM_REALM_ACCESS = "realm_access"; - /** - * Name of the claim containing the resources (clients) the user has access to. - */ + + /** Name of the claim containing the resources (clients) the user has access to. */ private static final String CLAIM_RESOURCE_ACCESS = "resource_access"; - /** - * Name of the claim containing roles. (Applicable to realm and resource level.) - */ + + /** Name of the claim containing roles. (Applicable to realm and resource level.) */ private static final String CLAIM_ROLES = "roles"; @Override - public AbstractAuthenticationToken convert(Jwt source) - { - return new JwtAuthenticationToken(source, Stream.concat(new JwtGrantedAuthoritiesConverter().convert(source) - .stream(), TEMPORARNAME(source).stream()) - .collect(toSet())); + public AbstractAuthenticationToken convert(Jwt source) { + return new JwtAuthenticationToken( + source, + Stream.concat( + new JwtGrantedAuthoritiesConverter().convert(source).stream(), + TEMPORARNAME(source).stream()) + .collect(toSet())); } /** - * Extracts the realm and resource level roles from a JWT token distinguishing between them using prefixes. + * Extracts the realm and resource level roles from a JWT token distinguishing between them + * using prefixes. */ public Collection TEMPORARNAME(Jwt jwt) { // Collection that will hold the extracted roles @@ -66,33 +61,43 @@ public class KeycloakJwtRolesConverter implements Converter realmRoles = roles.stream() - // Prefix all realm roles with "ROLE_realm_" - .map(role -> new SimpleGrantedAuthority(PREFIX_REALM_ROLE + role)) - .collect(Collectors.toList()); + Collection realmRoles = + roles.stream() + // Prefix all realm roles with "ROLE_realm_" + .map(role -> new SimpleGrantedAuthority(PREFIX_REALM_ROLE + role)) + .collect(Collectors.toList()); grantedAuthorities.addAll(realmRoles); } } // Resource (client) roles - // A user might have access to multiple resources all containing their own roles. Therefore, it is a map of + // A user might have access to multiple resources all containing their own roles. Therefore, + // it is a map of // resource each possibly containing a "roles" property. - Map>> resourceAccess = jwt.getClaim(CLAIM_RESOURCE_ACCESS); + Map>> resourceAccess = + jwt.getClaim(CLAIM_RESOURCE_ACCESS); // Check if resources are assigned if (resourceAccess != null && !resourceAccess.isEmpty()) { // Iterate of all the resources - resourceAccess.forEach((resource, resourceClaims) -> { - // Iterate of the "roles" claim inside the resource claims - resourceClaims.get(CLAIM_ROLES).forEach( - // Add the role to the granted authority prefixed with ROLE_ and the name of the resource - role -> grantedAuthorities.add(new SimpleGrantedAuthority(PREFIX_RESOURCE_ROLE + resource + "_" + role)) - ); - }); + resourceAccess.forEach( + (resource, resourceClaims) -> { + // Iterate of the "roles" claim inside the resource claims + resourceClaims + .get(CLAIM_ROLES) + .forEach( + // Add the role to the granted authority prefixed with ROLE_ + // and the name of the resource + role -> + grantedAuthorities.add( + new SimpleGrantedAuthority( + PREFIX_RESOURCE_ROLE + + resource + + "_" + + role))); + }); } return grantedAuthorities; } - - } diff --git a/MyINPulse-back/src/test/java/enseirb/myinpulse/MyinpulseApplicationTests.java b/MyINPulse-back/src/test/java/enseirb/myinpulse/MyinpulseApplicationTests.java index dce5ab2..04669ca 100644 --- a/MyINPulse-back/src/test/java/enseirb/myinpulse/MyinpulseApplicationTests.java +++ b/MyINPulse-back/src/test/java/enseirb/myinpulse/MyinpulseApplicationTests.java @@ -6,8 +6,6 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class MyinpulseApplicationTests { - @Test - void contextLoads() { - } - + @Test + void contextLoads() {} } From 1498b5908b84f554f6d5d96176d9d390dc7d39ae Mon Sep 17 00:00:00 2001 From: Pierre Tellier Date: Tue, 11 Feb 2025 19:24:04 +0100 Subject: [PATCH 08/10] fix: should now catch errors ? --- .gitea/workflows/back.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/back.yaml b/.gitea/workflows/back.yaml index 0e74e38..6cf8f56 100644 --- a/.gitea/workflows/back.yaml +++ b/.gitea/workflows/back.yaml @@ -14,6 +14,6 @@ jobs: java-version: '21' - uses: axel-op/googlejavaformat-action@v3 with: - args: "--replace --skip-sorting-imports --aosp" + args: "--skip-sorting-imports --aosp" - name: Print diffs run: git --no-pager diff --exit-code \ No newline at end of file From 70b00a19967426f7b41a0507b0dc066f39e99a7e Mon Sep 17 00:00:00 2001 From: Pierre Tellier Date: Tue, 11 Feb 2025 19:27:22 +0100 Subject: [PATCH 09/10] feat: test on github validation --- .gitea/workflows/back.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/back.yaml b/.gitea/workflows/back.yaml index 6cf8f56..0e74e38 100644 --- a/.gitea/workflows/back.yaml +++ b/.gitea/workflows/back.yaml @@ -14,6 +14,6 @@ jobs: java-version: '21' - uses: axel-op/googlejavaformat-action@v3 with: - args: "--skip-sorting-imports --aosp" + args: "--replace --skip-sorting-imports --aosp" - name: Print diffs run: git --no-pager diff --exit-code \ No newline at end of file From 9e2ab9fa5aa0dc72b663b479e3f6df3654ca6824 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Tue, 11 Feb 2025 18:27:36 +0000 Subject: [PATCH 10/10] Google Java Format --- .../src/main/java/enseirb/myinpulse/MyinpulseApplication.java | 1 - .../myinpulse/config/WebSecurityCustomConfiguration.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java index 1c39eef..196569d 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/MyinpulseApplication.java @@ -6,7 +6,6 @@ import org.springframework.security.oauth2.jwt.*; import java.util.*; - @SpringBootApplication public class MyinpulseApplication { diff --git a/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java b/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java index e642fd8..43a9889 100644 --- a/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java +++ b/MyINPulse-back/src/main/java/enseirb/myinpulse/config/WebSecurityCustomConfiguration.java @@ -28,7 +28,7 @@ public class WebSecurityCustomConfiguration { "authorization", "content-type", "x-auth-token")); // Do not remove, this fixes the CORS errors when - // unauthenticated + // unauthenticated UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); source.registerCorsConfiguration("/**", configuration);