-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add user profile settings menu mode configuration (#73)
* feat: add user profile settings menu mode configuration * tests: add tests for user profile menu config
- Loading branch information
1 parent
3b75342
commit 0f3f8c2
Showing
8 changed files
with
161 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.../user/profile/rs/external/v1/controllers/UserProfileV1RestControllerMenuSettingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.tkit.onecx.user.profile.rs.external.v1.controllers; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON; | ||
import static jakarta.ws.rs.core.Response.Status.OK; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.tkit.quarkus.security.test.SecurityTestUtils.getKeycloakClientToken; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.tkit.onecx.user.profile.domain.config.UserProfileConfig; | ||
import org.tkit.onecx.user.profile.test.AbstractTest; | ||
import org.tkit.quarkus.security.test.GenerateKeycloakClient; | ||
import org.tkit.quarkus.test.WithDBData; | ||
|
||
import gen.org.tkit.onecx.user.profile.rs.external.v1.model.*; | ||
import io.quarkus.test.InjectMock; | ||
import io.quarkus.test.common.http.TestHTTPEndpoint; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.smallrye.config.SmallRyeConfig; | ||
|
||
@QuarkusTest | ||
@TestHTTPEndpoint(UserProfileV1RestController.class) | ||
@WithDBData(value = "data/testdata.xml", deleteBeforeInsert = true, deleteAfterTest = true, rinseAndRepeat = true) | ||
@GenerateKeycloakClient(clientName = "testClient", scopes = { "ocx-up:read" }) | ||
class UserProfileV1RestControllerMenuSettingsTest extends AbstractTest { | ||
|
||
@InjectMock | ||
UserProfileConfig userProfileConfig; | ||
|
||
@Inject | ||
Config config; | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
var tmp = config.unwrap(SmallRyeConfig.class).getConfigMapping(UserProfileConfig.class); | ||
|
||
var m = Mockito.mock(UserProfileConfig.Settings.class); | ||
Mockito.when(m.locale()).thenReturn(tmp.settings().locale()); | ||
Mockito.when(m.timeZone()).thenReturn(tmp.settings().timeZone()); | ||
Mockito.when(m.menuMode()).thenReturn("WRONG_ENUM_KEY"); | ||
|
||
Mockito.when(userProfileConfig.claims()).thenReturn(tmp.claims()); | ||
Mockito.when(userProfileConfig.settings()).thenReturn(m); | ||
|
||
} | ||
|
||
@Test | ||
void getUserProfileTest() { | ||
// not existing user profile, should be created | ||
var userProfile = given() | ||
.auth().oauth2(getKeycloakClientToken("testClient")) | ||
.when() | ||
.contentType(APPLICATION_JSON) | ||
.header(APM_HEADER_PARAM, createToken("not-existing", null)) | ||
.get() | ||
.then() | ||
.statusCode(OK.getStatusCode()) | ||
.extract().as(UserProfileDTO.class); | ||
|
||
assertThat(userProfile.getUserId()).isEqualTo("not-existing"); | ||
assertThat(userProfile.getOrganization()).isEqualTo("org1"); | ||
assertThat(userProfile.getPerson().getEmail()).isEqualTo("[email protected]"); | ||
assertThat(userProfile.getAccountSettings().getMenuMode()).isEqualTo(MenuModeDTO.STATIC); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ void getUserProfileTest() { | |
assertThat(userPofile.getUserId()).isEqualTo("not-existing"); | ||
assertThat(userPofile.getOrganization()).isEqualTo("org1"); | ||
assertThat(userPofile.getPerson().getEmail()).isEqualTo("[email protected]"); | ||
assertThat(userPofile.getAccountSettings().getMenuMode()).isEqualTo(MenuModeDTO.HORIZONTAL); | ||
|
||
// load existing user profile | ||
userPofile = given() | ||
|
@@ -115,6 +116,7 @@ void getUserProfileTest() { | |
assertThat(userPofile.getOrganization()).isEqualTo("org2"); | ||
assertThat(userPofile.getUserId()).isEqualTo("user3"); | ||
assertThat(userPofile.getPerson().getDisplayName()).isEqualTo("User Three"); | ||
assertThat(userPofile.getAccountSettings().getMenuMode()).isEqualTo(MenuModeDTO.SLIM); | ||
} | ||
|
||
private static Stream<Arguments> claimTimezone() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters