Fix typo on path.

This commit is contained in:
Paulo Gustavo Veiga 2024-02-04 21:10:48 -08:00
parent 34a5328a2c
commit 96b6ff3841
12 changed files with 38 additions and 38 deletions

View File

@ -39,12 +39,12 @@ public class RestAppConfig {
.securityMatcher("/**")
.addFilterAfter(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class)
.authorizeHttpRequests(auth -> auth
.requestMatchers(mvc.pattern("/api/restfull/users/")).permitAll()
.requestMatchers(mvc.pattern("/api/restfull/authenticate")).permitAll()
.requestMatchers(mvc.pattern("/api/restfull/users/resetPassword")).permitAll()
.requestMatchers(mvc.pattern("/api/restfull/oauth2/googlecallback")).permitAll()
.requestMatchers(mvc.pattern("/api/restfull/oauth2/confirmaccountsync")).permitAll()
.requestMatchers(mvc.pattern("/api/restfull/admin/**")).hasAnyRole("ADMIN")
.requestMatchers(mvc.pattern("/api/restful/users/")).permitAll()
.requestMatchers(mvc.pattern("/api/restful/authenticate")).permitAll()
.requestMatchers(mvc.pattern("/api/restful/users/resetPassword")).permitAll()
.requestMatchers(mvc.pattern("/api/restful/oauth2/googlecallback")).permitAll()
.requestMatchers(mvc.pattern("/api/restful/oauth2/confirmaccountsync")).permitAll()
.requestMatchers(mvc.pattern("/api/restful/admin/**")).hasAnyRole("ADMIN")
.requestMatchers(mvc.pattern("/**")).hasAnyRole("USER", "ADMIN")
.anyRequest().authenticated()
)

View File

@ -39,7 +39,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/restfull/account/")
@RequestMapping("/api/restful/account/")
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
public class AccountController extends BaseController {
@Qualifier("userService")

View File

@ -36,7 +36,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/restfull/admin")
@RequestMapping("/api/restful/admin")
@PreAuthorize("isAuthenticated() and hasRole('ROLE_ADMIN')")
public class AdminController extends BaseController {
@Qualifier("userService")
@ -101,7 +101,7 @@ public class AdminController extends BaseController {
// Finally create the user ...
delegated.setAuthenticationType(AuthenticationType.DATABASE);
userService.createUser(delegated, false, true);
response.setHeader("Location", "/api/restfull/admin/users/" + user.getId());
response.setHeader("Location", "/api/restful/admin/users/" + user.getId());
}
@RequestMapping(method = RequestMethod.PUT, value = "/users/{id}/password", consumes = {"text/plain"})

View File

@ -39,7 +39,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@CrossOrigin
@RequestMapping("/api/restfull")
@RequestMapping("/api/restful")
public class JwtAuthController {
@Autowired

View File

@ -40,7 +40,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/restfull/labels")
@RequestMapping("/api/restful/labels")
@PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')")
public class LabelController extends BaseController {
@ -63,7 +63,7 @@ public class LabelController extends BaseController {
final Label label = createLabel(restLabel);
// Return the new created label ...
response.setHeader("Location", "/api/restfull/labels/" + label.getId());
response.setHeader("Location", "/api/restful/labels/" + label.getId());
response.setHeader("ResourceId", Long.toString(label.getId()));
}

View File

@ -46,7 +46,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/restfull/maps")
@RequestMapping("/api/restful/maps")
public class MindmapController extends BaseController {
private final Logger logger = LogManager.getLogger();
@ -548,7 +548,7 @@ public class MindmapController extends BaseController {
mindmapService.addMindmap(mindmap, user);
// Return the new created map ...
response.setHeader("Location", "/api/restfull/maps/" + mindmap.getId());
response.setHeader("Location", "/api/restful/maps/" + mindmap.getId());
response.setHeader("ResourceId", Integer.toString(mindmap.getId()));
}
@ -576,7 +576,7 @@ public class MindmapController extends BaseController {
mindmapService.addMindmap(clonedMap, user);
// Return the new created map ...
response.setHeader("Location", "/api/restfull/maps/" + clonedMap.getId());
response.setHeader("Location", "/api/restful/maps/" + clonedMap.getId());
response.setHeader("ResourceId", Integer.toString(clonedMap.getId()));
}

View File

@ -48,7 +48,7 @@ import java.util.Arrays;
import java.util.List;
@RestController
@RequestMapping("/api/restfull/users")
@RequestMapping("/api/restful/users")
@CrossOrigin
public class UserController extends BaseController {
@ -99,7 +99,7 @@ public class UserController extends BaseController {
user.setAuthenticationType(AuthenticationType.DATABASE);
userService.createUser(user, false, true);
response.setHeader("Location", "/api/restfull/users/" + user.getId());
response.setHeader("Location", "/api/restful/users/" + user.getId());
}
@RequestMapping(method = RequestMethod.PUT, value = "/resetPassword", produces = { "application/json" })

View File

@ -12,7 +12,7 @@ import java.util.ArrayList;
import java.util.List;
public class RestHelper {
public static final String BASE_REST_URL = "/api/restfull";
public static final String BASE_REST_URL = "/api/restful";
static HttpHeaders createHeaders(@NotNull MediaType mediaType) {
List<MediaType> acceptableMediaTypes = new ArrayList<>();

View File

@ -71,7 +71,7 @@ public class RestJwtAuthControllerTest {
final String userJson = objectMapper.writeValueAsString(user);
final MvcResult result = mockMvc.perform(
post("/api/restfull/authenticate").
post("/api/restful/authenticate").
contentType(MediaType.APPLICATION_JSON)
.content(userJson))
.andExpect(status().isOk()).andReturn();
@ -86,7 +86,7 @@ public class RestJwtAuthControllerTest {
final String userJson = objectMapper.writeValueAsString(user);
mockMvc.perform(
post("/api/restfull/authenticate").
post("/api/restful/authenticate").
contentType(MediaType.APPLICATION_JSON)
.content(userJson))
.andExpect(status().is4xxClientError());
@ -99,7 +99,7 @@ public class RestJwtAuthControllerTest {
final String userJson = objectMapper.writeValueAsString(user);
mockMvc.perform(
post("/api/restfull/authenticate").
post("/api/restful/authenticate").
contentType(MediaType.APPLICATION_JSON)
.content(userJson))
.andExpect(status().is4xxClientError());

View File

@ -134,7 +134,7 @@ public class RestLabelControllerTest {
// Create a new label ...
final HttpEntity<RestLabel> createUserEntity = new HttpEntity<>(restLabel, requestHeaders);
final ResponseEntity<String> result = template.exchange("/api/restfull/labels", HttpMethod.POST, createUserEntity, String.class);
final ResponseEntity<String> result = template.exchange("/api/restful/labels", HttpMethod.POST, createUserEntity, String.class);
if (!result.getStatusCode().is2xxSuccessful()) {
throw new IllegalStateException(result.toString());
}

View File

@ -128,7 +128,7 @@ public class RestMindmapControllerTest {
// Add map with same name ...
HttpEntity<RestMindmap> createUserEntity = new HttpEntity<>(requestHeaders);
final ResponseEntity<String> response = restTemplate.exchange("/api/restfull/maps?title=" + title, HttpMethod.POST, createUserEntity, String.class);
final ResponseEntity<String> response = restTemplate.exchange("/api/restful/maps?title=" + title, HttpMethod.POST, createUserEntity, String.class);
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
assertTrue(Objects.requireNonNull(response.getBody()).contains("You have already a map with the same name"));
}
@ -254,7 +254,7 @@ public class RestMindmapControllerTest {
addNewMap(secondTemplate, title2);
final TestRestTemplate superadminTemplate = this.restTemplate.withBasicAuth("admin@wisemapping.org", "test");
final ResponseEntity<String> exchange = superadminTemplate.exchange("/api/restfull/admin/users/" + secondUser.getId(), HttpMethod.DELETE, null, String.class);
final ResponseEntity<String> exchange = superadminTemplate.exchange("/api/restful/admin/users/" + secondUser.getId(), HttpMethod.DELETE, null, String.class);
assertTrue(exchange.getStatusCode().is2xxSuccessful(), "Status Code:" + exchange.getStatusCode() + "- " + exchange.getBody());
// Validate that the two maps are there ...
@ -490,15 +490,15 @@ public class RestMindmapControllerTest {
// Create a sample map ...
final String mapTitle = "removeLabelFromMindmap";
final URI mindmapUri = addNewMap(restTemplate, mapTitle);
final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
final String mapId = mindmapUri.getPath().replace("/api/restful/maps/", "");
// Assign label to map ...
String labelId = labelUri.getPath().replace("/api/restfull/labels/", "");
String labelId = labelUri.getPath().replace("/api/restful/labels/", "");
HttpEntity<String> labelEntity = new HttpEntity<>(labelId, requestHeaders);
restTemplate.postForLocation("/api/restfull/maps/" + mapId + "/labels", labelEntity);
restTemplate.postForLocation("/api/restful/maps/" + mapId + "/labels", labelEntity);
// Remove label from map
final ResponseEntity<String> exchange = restTemplate.exchange("/api/restfull//maps/" + mapId + "/labels/" + labelId, HttpMethod.DELETE, null, String.class);
final ResponseEntity<String> exchange = restTemplate.exchange("/api/restful//maps/" + mapId + "/labels/" + labelId, HttpMethod.DELETE, null, String.class);
assertTrue(exchange.getStatusCode().is2xxSuccessful());
@ -535,12 +535,12 @@ public class RestMindmapControllerTest {
// Create a sample map ...
final String mapTitle = "Maps 1 - ";
final URI mindmapUri = addNewMap(restTemplate, mapTitle);
final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
final String mapId = mindmapUri.getPath().replace("/api/restful/maps/", "");
// Assign label to map ...
String labelId = labelUri.getPath().replace("/api/restfull/labels/", "");
String labelId = labelUri.getPath().replace("/api/restful/labels/", "");
HttpEntity<String> labelEntity = new HttpEntity<>(labelId, requestHeaders);
restTemplate.postForLocation("/api/restfull/maps/" + mapId + "/labels", labelEntity);
restTemplate.postForLocation("/api/restful/maps/" + mapId + "/labels", labelEntity);
// Check that the label has been assigned ...
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, restTemplate, mapId);
@ -636,7 +636,7 @@ public class RestMindmapControllerTest {
final String maps = fetchMaps(requestHeaders, restTemplate).getMindmapsInfo().stream().map(map -> String.valueOf(map.getId())).collect(Collectors.joining(","));
final ResponseEntity<String> exchange = restTemplate.exchange("/api/restfull/maps/batch?ids=" + maps, HttpMethod.DELETE, null, String.class);
final ResponseEntity<String> exchange = restTemplate.exchange("/api/restful/maps/batch?ids=" + maps, HttpMethod.DELETE, null, String.class);
assertTrue(exchange.getStatusCode().is2xxSuccessful(), "Status code:" + exchange.getStatusCode() + " - " + exchange.getBody());
// Validate that the two maps are there ...
@ -769,7 +769,7 @@ public class RestMindmapControllerTest {
@NotNull
private RestMindmapList fetchMaps(final HttpHeaders requestHeaders, final TestRestTemplate template) throws RestClientException {
final HttpEntity<RestMindmapList> findMapEntity = new HttpEntity<>(requestHeaders);
final ResponseEntity<RestMindmapList> response = template.exchange("/api/restfull/maps/", HttpMethod.GET, findMapEntity, RestMindmapList.class);
final ResponseEntity<RestMindmapList> response = template.exchange("/api/restful/maps/", HttpMethod.GET, findMapEntity, RestMindmapList.class);
assertTrue(response.getStatusCode().is2xxSuccessful(), response.toString());
return Objects.requireNonNull(response.getBody());
@ -804,7 +804,7 @@ public class RestMindmapControllerTest {
// Create a new map ...
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_XML);
HttpEntity<String> createUserEntity = new HttpEntity<>(xml, requestHeaders);
return template.postForLocation("/api/restfull/maps?title=" + title, createUserEntity);
return template.postForLocation("/api/restful/maps?title=" + title, createUserEntity);
}
private URI addNewMap(@NotNull TestRestTemplate template, @NotNull String title) {

View File

@ -66,7 +66,7 @@ public class RestUserControllerTest {
final String userJson = objectMapper.writeValueAsString(result);
mockMvc.perform(
post("/api/restfull/admin/users").
post("/api/restful/admin/users").
contentType(MediaType.APPLICATION_JSON)
.content(userJson)
.with(user("test@wisemapping.org").roles("ADMIN")))
@ -81,7 +81,7 @@ public class RestUserControllerTest {
@Test
void resetPasswordInvalidUser() throws Exception {
this.mockMvc.perform
(put("/api/restfull/users/resetPassword?email=doesnotexist@example.com"))
(put("/api/restful/users/resetPassword?email=doesnotexist@example.com"))
.andDo(print())
.andExpect(status().is4xxClientError())
.andExpect(content().string(containsString("The email provided is not a valid user account.")));
@ -91,7 +91,7 @@ public class RestUserControllerTest {
void resetPasswordValidUser() throws Exception {
final RestUser user = createUser();
this.mockMvc.perform
(put("/api/restfull/users/resetPassword?email=" + user.getEmail()))
(put("/api/restful/users/resetPassword?email=" + user.getEmail()))
.andDo(print())
.andExpect(status().isOk());
}
@ -104,7 +104,7 @@ public class RestUserControllerTest {
final String userJson = objectMapper.writeValueAsString(user);
mockMvc.perform(
post("/api/restfull/users/").
post("/api/restful/users/").
contentType(MediaType.APPLICATION_JSON)
.content(userJson))
.andExpect(status().isCreated());