@Test public void getAccessToken() throws Exception { TokenResponse tokenResponse = new TokenResponse(); tokenResponse.setAccessToken("test-access-token"); tokenResponse.setTokenType("Bearer"); tokenResponse.setIdToken("test-id-token"); given(localAuthorityService.getAccessTokenFromKernel("uuid-test-one")).willReturn(Optional.of(tokenResponse)); ResultActions resultActions = mockMvc.perform(get("/api/admin/local-authority/uuid-test-one/accessToken")); resultActions .andExpect(matchAll( status().isOk(), jsonPath("$").value("test-access-token") )) .andDo(print()); }
@GetMapping("/{siren}/accessToken") public ResponseEntity<String> getAccessToken(@PathVariable String siren) { Optional<TokenResponse> tokenResponse = localAuthorityService.getAccessTokenFromKernel(siren); return tokenResponse .map(tokenResponse1 -> new ResponseEntity<>(tokenResponse1.getAccessToken(), HttpStatus.OK)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); }
LocalAuthorityController { @GetMapping("/{siren}/accessToken") public ResponseEntity<String> getAccessToken(@PathVariable String siren) { Optional<TokenResponse> tokenResponse = localAuthorityService.getAccessTokenFromKernel(siren); return tokenResponse .map(tokenResponse1 -> new ResponseEntity<>(tokenResponse1.getAccessToken(), HttpStatus.OK)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); } }
LocalAuthorityController { @GetMapping("/{siren}/accessToken") public ResponseEntity<String> getAccessToken(@PathVariable String siren) { Optional<TokenResponse> tokenResponse = localAuthorityService.getAccessTokenFromKernel(siren); return tokenResponse .map(tokenResponse1 -> new ResponseEntity<>(tokenResponse1.getAccessToken(), HttpStatus.OK)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); } LocalAuthorityController(LocalAuthorityService localAuthorityService, ProfileService profileService,
            WorkGroupService workGroupService); }
LocalAuthorityController { @GetMapping("/{siren}/accessToken") public ResponseEntity<String> getAccessToken(@PathVariable String siren) { Optional<TokenResponse> tokenResponse = localAuthorityService.getAccessTokenFromKernel(siren); return tokenResponse .map(tokenResponse1 -> new ResponseEntity<>(tokenResponse1.getAccessToken(), HttpStatus.OK)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); } LocalAuthorityController(LocalAuthorityService localAuthorityService, ProfileService profileService,
            WorkGroupService workGroupService); @GetMapping("/instance-id/{instaceId}") ResponseEntity<String> getSlugByInstanceId(@PathVariable String instaceId); @GetMapping("/current") @JsonView(Views.LocalAuthorityView.class) ResponseEntity<LocalAuthority> getCurrentLocalAuthority(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid); @GetMapping("/all") @JsonView(Views.LocalAuthorityViewBasic.class) List<LocalAuthority> getAllBasicLocalAuthorities(); @GetMapping("/{uuid}") @JsonView(Views.LocalAuthorityView.class) ResponseEntity<LocalAuthority> getLocalAuthorityByUuid(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid,
            @PathVariable String uuid); @GetMapping("/instance/slug-name/{slugName}") OzwilloInstanceInfo getInstanceInfoBySlugName(@PathVariable String slugName); @GetMapping("/instance/instance-id/{instanceId}") OzwilloInstanceInfo getInstanceInfoByInstanceId(@PathVariable String instanceId); @PostMapping("/current/{module}") ResponseEntity addModule(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid,
            @PathVariable Module module); @DeleteMapping("/current/{module}") ResponseEntity removeModule(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid,
            @PathVariable Module module); @GetMapping("/{uuid}/agent/{agentUuid}") @JsonView(Views.ProfileView.class) ResponseEntity<Profile> getProfile(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @PathVariable String agentUuid); @GetMapping("/current/agent/{agentUuid}") @JsonView(Views.ProfileView.class) ResponseEntity<Profile> getProfileFromCurrent(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String agentUuid); @GetMapping("/{uuid}/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<List<WorkGroup>> getAllGroupByLocalAuthority(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @GetMapping("/{uuid}/{moduleName}/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<List<WorkGroup>> getAllGroupByLocalAuthorityAndModule(@PathVariable String uuid,
            @PathVariable String moduleName); @GetMapping("/current/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<List<WorkGroup>> getAllGroupForCurrent(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid); @PostMapping("/{uuid}/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> newGroupFromFront(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @RequestBody WorkGroupUI workGroupUI); @PostMapping("/{uuid}/group/{name}") @JsonView(Views.WorkGroupView.class) ResponseEntity<String> newGroupFromModules(
            @PathVariable String uuid, @PathVariable String name, @RequestBody Set<String> rights); @PostMapping("/current/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> newGroupForCurrent(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @RequestBody WorkGroupUI workGroupUI); @GetMapping("/group/{uuid}") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> getGroup(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @PatchMapping("/group/{uuid}") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> updateGroup(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @RequestBody WorkGroupUI workGroupUI); @DeleteMapping("/group/{uuid}") ResponseEntity deleteGroup(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @GetMapping("/certificates/{uuid}") ResponseEntity<Certificate> getLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @PostMapping("/current/certificates") ResponseEntity addCurrentLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @RequestParam("file") MultipartFile file); @PostMapping("/{uuid}/certificates") ResponseEntity addLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @RequestParam("file") MultipartFile file); @DeleteMapping("/current/certificates/{uuid}") ResponseEntity deleteCurrentLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @DeleteMapping("/{localAuthorityUuid}/certificates/{uuid}") ResponseEntity deleteLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String localAuthorityUuid, @PathVariable String uuid); @PostMapping("/{uuid}/{module}") ResponseEntity addModuleByUuid(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @PathVariable Module module); @DeleteMapping("/{uuid}/{module}") ResponseEntity removeModuleByUuid(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @PathVariable Module module); @GetMapping("/certificate/{serial}/{issuer}") ResponseEntity<LocalAuthority> getByCertificate(
            @PathVariable String serial,
            @PathVariable String issuer); @GetMapping("/{uuid}/siret") String getSiret(@PathVariable String uuid); @GetMapping("/{siren}/accessToken") ResponseEntity<String> getAccessToken(@PathVariable String siren); @GetMapping("/{siren}/dcId") ResponseEntity<String> getDcId(@PathVariable String siren); }
LocalAuthorityController { @GetMapping("/{siren}/accessToken") public ResponseEntity<String> getAccessToken(@PathVariable String siren) { Optional<TokenResponse> tokenResponse = localAuthorityService.getAccessTokenFromKernel(siren); return tokenResponse .map(tokenResponse1 -> new ResponseEntity<>(tokenResponse1.getAccessToken(), HttpStatus.OK)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); } LocalAuthorityController(LocalAuthorityService localAuthorityService, ProfileService profileService,
            WorkGroupService workGroupService); @GetMapping("/instance-id/{instaceId}") ResponseEntity<String> getSlugByInstanceId(@PathVariable String instaceId); @GetMapping("/current") @JsonView(Views.LocalAuthorityView.class) ResponseEntity<LocalAuthority> getCurrentLocalAuthority(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid); @GetMapping("/all") @JsonView(Views.LocalAuthorityViewBasic.class) List<LocalAuthority> getAllBasicLocalAuthorities(); @GetMapping("/{uuid}") @JsonView(Views.LocalAuthorityView.class) ResponseEntity<LocalAuthority> getLocalAuthorityByUuid(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid,
            @PathVariable String uuid); @GetMapping("/instance/slug-name/{slugName}") OzwilloInstanceInfo getInstanceInfoBySlugName(@PathVariable String slugName); @GetMapping("/instance/instance-id/{instanceId}") OzwilloInstanceInfo getInstanceInfoByInstanceId(@PathVariable String instanceId); @PostMapping("/current/{module}") ResponseEntity addModule(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid,
            @PathVariable Module module); @DeleteMapping("/current/{module}") ResponseEntity removeModule(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String agentUuid,
            @PathVariable Module module); @GetMapping("/{uuid}/agent/{agentUuid}") @JsonView(Views.ProfileView.class) ResponseEntity<Profile> getProfile(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @PathVariable String agentUuid); @GetMapping("/current/agent/{agentUuid}") @JsonView(Views.ProfileView.class) ResponseEntity<Profile> getProfileFromCurrent(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String agentUuid); @GetMapping("/{uuid}/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<List<WorkGroup>> getAllGroupByLocalAuthority(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @GetMapping("/{uuid}/{moduleName}/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<List<WorkGroup>> getAllGroupByLocalAuthorityAndModule(@PathVariable String uuid,
            @PathVariable String moduleName); @GetMapping("/current/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<List<WorkGroup>> getAllGroupForCurrent(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid); @PostMapping("/{uuid}/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> newGroupFromFront(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @RequestBody WorkGroupUI workGroupUI); @PostMapping("/{uuid}/group/{name}") @JsonView(Views.WorkGroupView.class) ResponseEntity<String> newGroupFromModules(
            @PathVariable String uuid, @PathVariable String name, @RequestBody Set<String> rights); @PostMapping("/current/group") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> newGroupForCurrent(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @RequestBody WorkGroupUI workGroupUI); @GetMapping("/group/{uuid}") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> getGroup(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @PatchMapping("/group/{uuid}") @JsonView(Views.WorkGroupView.class) ResponseEntity<WorkGroup> updateGroup(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @RequestBody WorkGroupUI workGroupUI); @DeleteMapping("/group/{uuid}") ResponseEntity deleteGroup(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @GetMapping("/certificates/{uuid}") ResponseEntity<Certificate> getLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @PostMapping("/current/certificates") ResponseEntity addCurrentLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @RequestParam("file") MultipartFile file); @PostMapping("/{uuid}/certificates") ResponseEntity addLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @RequestParam("file") MultipartFile file); @DeleteMapping("/current/certificates/{uuid}") ResponseEntity deleteCurrentLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Local-Authority-UUID") String currentLocalAuthUuid,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid); @DeleteMapping("/{localAuthorityUuid}/certificates/{uuid}") ResponseEntity deleteLocalAuthorityCertificate(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String localAuthorityUuid, @PathVariable String uuid); @PostMapping("/{uuid}/{module}") ResponseEntity addModuleByUuid(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @PathVariable Module module); @DeleteMapping("/{uuid}/{module}") ResponseEntity removeModuleByUuid(
            @RequestAttribute("STELA-Current-Profile-Is-Local-Authority-Admin") boolean isLocalAuthorityAdmin,
            @RequestAttribute("STELA-Current-Agent-UUID") String currentAgentUuid,
            @PathVariable String uuid, @PathVariable Module module); @GetMapping("/certificate/{serial}/{issuer}") ResponseEntity<LocalAuthority> getByCertificate(
            @PathVariable String serial,
            @PathVariable String issuer); @GetMapping("/{uuid}/siret") String getSiret(@PathVariable String uuid); @GetMapping("/{siren}/accessToken") ResponseEntity<String> getAccessToken(@PathVariable String siren); @GetMapping("/{siren}/dcId") ResponseEntity<String> getDcId(@PathVariable String siren);  }