Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
* fix failing tests
  • Loading branch information
Leandro13Silva13 committed Apr 4, 2024
1 parent 34077eb commit c8d42c0
Showing 1 changed file with 7 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.RoleMappingResource;
Expand Down Expand Up @@ -710,36 +712,19 @@ void getSessionsForGroupOrFeedbackGroupIdsShouldBeForbiddenIfUserDoesNotParticip
.andExpect(status().isForbidden());
}

@Test
@ParameterizedTest
@WithMockUser(authorities = {AuthorityValue.CONSULTANT_DEFAULT})
@ValueSource(strings = {"QBv2xym9qQ2DoAxkR", "doesNotExist", "mzAdWzQEobJ2PkoxP"})
void
getSessionsForGroupOrFeedbackGroupIdsShouldBeForbiddenIfConsultantDoesNotParticipateInSession()
throws Exception {
givenAConsultantWithSessions();
givenNoRocketChatSubscriptionUpdates();
givenNoRocketChatRoomUpdates();

mockMvc
.perform(
get("/users/sessions/room?rcGroupIds=QBv2xym9qQ2DoAxkR")
.cookie(CSRF_COOKIE)
.header(CSRF_HEADER, CSRF_VALUE)
.header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isForbidden());
}

@Test
@WithMockUser(authorities = {AuthorityValue.CONSULTANT_DEFAULT})
void getSessionsForGroupOrFeedbackGroupIdsShouldBeNoContentIfNoSessionsFoundForIds()
throws Exception {
getSessionsForGroupOrFeedbackGroupIdsShouldBeNoContentIfConsultantDoesNotParticipateInSessionOrNoSessionsFoundForIdsOrNewEnquiriesForConsultantsNotInAgency(
String rcGroupId) throws Exception {
givenAConsultantWithSessions();
givenNoRocketChatSubscriptionUpdates();
givenNoRocketChatRoomUpdates();

mockMvc
.perform(
get("/users/sessions/room?rcGroupIds=doesNotExist")
get("/users/sessions/room?rcGroupIds=" + rcGroupId)
.cookie(CSRF_COOKIE)
.header(CSRF_HEADER, CSRF_VALUE)
.header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN)
Expand Down Expand Up @@ -768,25 +753,6 @@ void getSessionsForGroupOrFeedbackGroupIdsShouldBeNoContentIfNoSessionsFoundForI
.andExpect(jsonPath("sessions", hasSize(1)));
}

@Test
@WithMockUser(authorities = {AuthorityValue.CONSULTANT_DEFAULT})
void
getSessionsForGroupOrFeedbackGroupIdsShouldReturnForbiddenForNewEnquiriesForConsultantsNotInAgency()
throws Exception {
givenAConsultantWithSessions();
givenNoRocketChatSubscriptionUpdates();
givenNoRocketChatRoomUpdates();

mockMvc
.perform(
get("/users/sessions/room?rcGroupIds=mzAdWzQEobJ2PkoxP")
.cookie(CSRF_COOKIE)
.header(CSRF_HEADER, CSRF_VALUE)
.header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isForbidden());
}

@Test
@WithMockUser(authorities = {AuthorityValue.USER_DEFAULT})
void getSessionForIdShouldFindSessionsBySessionId() throws Exception {
Expand Down

0 comments on commit c8d42c0

Please sign in to comment.