Skip to content
Snippets Groups Projects
Commit 6a73f36d authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' of git.ozg-sh.de:mgm/goofy

parents 0c95026f 85ba212f
No related branches found
No related tags found
No related merge requests found
...@@ -60,6 +60,8 @@ public class RootController { ...@@ -60,6 +60,8 @@ public class RootController {
static final String REL_DOWNLOAD_TOKEN = "downloadToken"; static final String REL_DOWNLOAD_TOKEN = "downloadToken";
static final String REL_CURRENT_USER = "currentUser"; static final String REL_CURRENT_USER = "currentUser";
static final String USER_PROFILE_SEARCH_DELETED_PARAM = "deleted";
@Autowired(required = false) @Autowired(required = false)
public BuildProperties buildProperties; public BuildProperties buildProperties;
@Autowired @Autowired
...@@ -81,7 +83,11 @@ public class RootController { ...@@ -81,7 +83,11 @@ public class RootController {
linkTo(RootController.class).withSelfRel(), linkTo(RootController.class).withSelfRel(),
linkTo(VorgangController.class).withRel(REL_VORGAENGE), linkTo(VorgangController.class).withRel(REL_VORGAENGE),
linkTo(DownloadTokenController.class).withRel(REL_DOWNLOAD_TOKEN), linkTo(DownloadTokenController.class).withRel(REL_DOWNLOAD_TOKEN),
Link.of(userManagerUrlProvider.getUserProfileSearchTemplate(), REL_SEARCH_USER)) Link.of(userManagerUrlProvider.getUserProfileSearchTemplate()
.queryParam(USER_PROFILE_SEARCH_DELETED_PARAM, false)
.build(false)
.toUriString(),
REL_SEARCH_USER))
.ifMatch(this::hasRoleAndSearchServerAvailable).addLinks( .ifMatch(this::hasRoleAndSearchServerAvailable).addLinks(
buildVorgangListByPageLink(REL_SEARCH, Optional.empty())); buildVorgangListByPageLink(REL_SEARCH, Optional.empty()));
......
...@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import de.itvsh.goofy.postfach.PostfachMail; import de.itvsh.goofy.postfach.PostfachMail;
import org.springframework.web.util.UriComponentsBuilder;
//FIXME add missing tests //FIXME add missing tests
@Service @Service
...@@ -53,8 +54,8 @@ public class UserManagerUrlProvider { ...@@ -53,8 +54,8 @@ public class UserManagerUrlProvider {
return userManagerProperties.getInternalurl() + userManagerProperties.getProfileTemplate(); return userManagerProperties.getInternalurl() + userManagerProperties.getProfileTemplate();
} }
public String getUserProfileSearchTemplate() { public UriComponentsBuilder getUserProfileSearchTemplate() {
return userManagerProperties.getUrl() + userManagerProperties.getSearchTemplate(); return UriComponentsBuilder.fromUriString(userManagerProperties.getUrl() + userManagerProperties.getSearchTemplate());
} }
/** @deprecated for migration only */ /** @deprecated for migration only */
......
...@@ -54,6 +54,7 @@ import de.itvsh.goofy.common.user.UserProfileTestFactory; ...@@ -54,6 +54,7 @@ import de.itvsh.goofy.common.user.UserProfileTestFactory;
import de.itvsh.goofy.common.user.UserRemoteService; import de.itvsh.goofy.common.user.UserRemoteService;
import de.itvsh.goofy.common.user.UserRole; import de.itvsh.goofy.common.user.UserRole;
import de.itvsh.goofy.system.SystemStatusService; import de.itvsh.goofy.system.SystemStatusService;
import org.springframework.web.util.UriComponentsBuilder;
class RootControllerTest { class RootControllerTest {
...@@ -79,7 +80,8 @@ class RootControllerTest { ...@@ -79,7 +80,8 @@ class RootControllerTest {
when(currentUserService.getUserId()).thenReturn(UserId.from("42")); when(currentUserService.getUserId()).thenReturn(UserId.from("42"));
when(internalUserIdService.getUserId(any())).thenReturn(Optional.empty()); when(internalUserIdService.getUserId(any())).thenReturn(Optional.empty());
when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn("UserProfileSearchTemplateDummy/$"); when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn(
UriComponentsBuilder.fromUriString("UserProfileSearchTemplateDummy/$"));
} }
@DisplayName("Links for user") @DisplayName("Links for user")
...@@ -310,6 +312,25 @@ class RootControllerTest { ...@@ -310,6 +312,25 @@ class RootControllerTest {
} }
} }
} }
@DisplayName("User profile search")
@Nested
class TestUserProfileSearch {
@BeforeEach
void init() {
when(currentUserService.hasRole(UserRole.VERWALTUNG_USER)).thenReturn(true);
when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn(
UriComponentsBuilder.fromUriString("/api/userProfiles/?searchBy={searchBy}"));
}
@Test
void shouldAlwaysSearchForNotDeletedUserProfiles() {
var model = controller.getRootResource();
assertThat(model.getLink(RootController.REL_SEARCH_USER)).isPresent().get().extracting(Link::getHref).isEqualTo(
"/api/userProfiles/?searchBy={searchBy}&deleted=false");
}
}
} }
@DisplayName("Root resource") @DisplayName("Root resource")
...@@ -320,7 +341,8 @@ class RootControllerTest { ...@@ -320,7 +341,8 @@ class RootControllerTest {
void initTest() { void initTest() {
when(currentUserService.getUserId()).thenReturn(UserId.from("42")); when(currentUserService.getUserId()).thenReturn(UserId.from("42"));
when(internalUserIdService.getUserId(any())).thenReturn(Optional.empty()); when(internalUserIdService.getUserId(any())).thenReturn(Optional.empty());
when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn("UserProfileSearchTemplateDummy/$"); when(userManagerUrlProvider.getUserProfileSearchTemplate()).thenReturn(
UriComponentsBuilder.fromUriString("UserProfileSearchTemplateDummy/$"));
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment