Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package de.filefighter.rest.configuration;

import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class RestConfiguration {

//Custom static constants
public static final String BASE_API_URI = "/api/v1";
public static final String AUTHORIZATION_BASIC_PREFIX = "Basic: ";
public static final String AUTHORIZATION_BEARER_PREFIX = "Bearer: ";
public static final String AUTHORIZATION_BASIC_PREFIX = "Basic ";
public static final String AUTHORIZATION_BEARER_PREFIX = "Bearer ";
public static final String FS_BASE_URI = "/filesystem/";
public static final String FS_PATH_HEADER = "X-FF-PATH";
public static final String USER_BASE_URI = "/users/";

// PreventInstantiation
private RestConfiguration() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

@RestController
@Api(value = "User Rest Controller", tags = {"User"})

@RequestMapping(BASE_API_URI)
public class UserRestController {

private final static Logger LOG = LoggerFactory.getLogger(UserRestController.class);
private static final Logger LOG = LoggerFactory.getLogger(UserRestController.class);

private final UserRestServiceInterface userRestService;

Expand Down
178 changes: 0 additions & 178 deletions src/main/resources/CLASS_DIAGRAM_rest.uml

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/resources/DB_SCHEMA_filefighter.uml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class RestApplicationIntegrationTest {
PermissionRestController permissionRestController;

@Test
public void contextLoads() {
void contextLoads() {
assertThat(healthController).isNotNull();
assertThat(userController).isNotNull();
assertThat(fileSystemRestController).isNotNull();
Expand All @@ -59,17 +59,25 @@ public void contextLoads() {
protected void executeRestApiCall(HttpMethod httpMethod, String url) {
final Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
executeRequest(httpMethod, url, headers);
executeRequest(httpMethod, url, headers,null);
}

protected void executeRestApiCall(HttpMethod httpMethod, String url, Map<String, String> headers) {
executeRequest(httpMethod, url, headers);
executeRequest(httpMethod, url, headers,null);
}
protected void executeRestApiCall(HttpMethod httpMethod, String url, Map<String, String> headers,String postBody) {
executeRequest(httpMethod, url, headers, postBody);
}

private void executeRequest(HttpMethod httpMethod, String url, Map<String, String> headers) {
private void executeRequest(HttpMethod httpMethod, String url, Map<String, String> headers,String postBody) {
final HeaderSettingRequestCallback requestCallback = new HeaderSettingRequestCallback(headers);
if (postBody!=null){
requestCallback.setBody(postBody);
}
final ResponseResultErrorHandler errorHandler = new ResponseResultErrorHandler();

headers.put("Content-Type", "application/json");

restTemplate.setErrorHandler(errorHandler);
latestResponse = restTemplate
.execute("http://localhost:" + port + url, httpMethod, requestCallback, response -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package de.filefighter.rest.cucumber;

import de.filefighter.rest.RestApplicationIntegrationTest;
import io.cucumber.java.en.When;
import org.springframework.http.HttpMethod;

import java.util.HashMap;

import static de.filefighter.rest.configuration.RestConfiguration.*;

public class UserEditInformationSteps extends RestApplicationIntegrationTest {
@When("user requests change of username with value {string} and accessToken {string}")
public void userRequestsChangeOfUsernameWithValueAndAccessTokenAndId(String newUsername, String accessToken) {
String authHeaderString = AUTHORIZATION_BEARER_PREFIX + accessToken;
String url = BASE_API_URI + USER_BASE_URI + "edit";


HashMap<String, String> authHeader = new HashMap<>();
authHeader.put("Authorization", authHeaderString);




String postBody="{" +
" \"groupIds\": [" +
" 0" +
" ]," +
" \"username\": \""+newUsername+"\"" +
"}";

executeRestApiCall(HttpMethod.PUT, url, authHeader,postBody);
}

@When("user requests change of password with value {string} and accessToken {string} and id {string}")
public void userRequestsChangeOfPasswordWithValueAndAccessTokenAndId(String newPassword, String accessToken, String userId) {
String authHeaderString = AUTHORIZATION_BEARER_PREFIX + accessToken;
String url = BASE_API_URI + USER_BASE_URI + userId + "/edit";

HashMap<String, String> authHeader = new HashMap<>();
authHeader.put("Authorization", authHeaderString);


String postBody="{\n" +
" \"confirmationPassword\": \""+newPassword+"\"," +
" \"groupIds\": [" +
" 0" +
" ]," +
" \"password\": \""+newPassword+"\"," +
"}";

executeRestApiCall(HttpMethod.GET, url, authHeader,postBody);
}
}
Loading