Skip to content
Draft
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
Expand Up @@ -121,19 +121,19 @@ private void clientManagementFailsWithResponseForClient(ResultMatcher response,
private void paginatedGetClientsTest() throws Exception {
mvc.perform(get(ClientManagementAPIController.ENDPOINT))
.andExpect(OK)
.andExpect(jsonPath("$.totalResults").value(21))
.andExpect(jsonPath("$.totalResults").value(22))
.andExpect(jsonPath("$.itemsPerPage").value(10))
.andExpect(jsonPath("$.startIndex").value(1))
.andExpect(jsonPath("$.Resources", hasSize(10)))
.andExpect(jsonPath("$.Resources[0].client_id").value("admin-client-ro"));

mvc.perform(get(ClientManagementAPIController.ENDPOINT).param("startIndex", "13"))
.andExpect(OK)
.andExpect(jsonPath("$.totalResults").value(21))
.andExpect(jsonPath("$.itemsPerPage").value(9))
.andExpect(jsonPath("$.totalResults").value(22))
.andExpect(jsonPath("$.itemsPerPage").value(10))
.andExpect(jsonPath("$.startIndex").value(13))
.andExpect(jsonPath("$.Resources", hasSize(9)))
.andExpect(jsonPath("$.Resources[0].client_id").value("public-dc-client"));
.andExpect(jsonPath("$.Resources", hasSize(10)))
.andExpect(jsonPath("$.Resources[0].client_id").value("public-client-having-secret"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void searchForPublicClientByName() throws Exception {
.getResponse()
.getContentAsString(),
new TypeReference<ListResponseDTO<RegisteredClientDTO>>() {});
assertEquals(1, response.getTotalResults());
assertEquals(2, response.getTotalResults());
assertEquals("Public client", response.getResources().get(0).getClientName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.web.servlet.MockMvc;

import com.fasterxml.jackson.databind.ObjectMapper;

import it.infn.mw.iam.IamLoginService;
import it.infn.mw.iam.test.util.WithAnonymousUser;
import it.infn.mw.iam.test.util.annotation.IamMockMvcIntegrationTest;
Expand Down Expand Up @@ -73,6 +74,24 @@ void testTokenEndpointFormClientAuthentication() throws Exception {
// @formatter:on
}

@Test
void testTokenEndpointFormClientWithNoAuthenticationFailed() throws Exception {
// Replicate: When user is changing client auth method to No authentication from others,
// the previous secret value persist in the database. So when the client is in use, it is still checking for the secret.
String clientId = "public-client-having-secret";
String clientSecret = "";

// @formatter:off
mvc.perform(post(TOKEN_ENDPOINT)
.param("grant_type", GRANT_TYPE)
.param("client_id", clientId)
.param("client_secret", clientSecret)
.param("scope", SCOPE))
.andDo(print())
.andExpect(status().isUnauthorized());
// @formatter:on
}

@Test
void testTokenEndpointFormClientAuthenticationInvalidCredentials() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void testPagedClientLookup() {

ListResponseDTO<RegisteredClientDTO> clients = managementService.retrieveAllClients(pageable);

assertThat(clients.getTotalResults(), is(21L));
assertThat(clients.getTotalResults(), is(22L));
assertThat(clients.getItemsPerPage(), is(10));
assertThat(clients.getStartIndex(), is(1));
assertThat(clients.getResources().get(0).getClientId(), is("admin-client-ro"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ INSERT INTO client_details (id, client_id, client_secret, client_name, dynamical
(18, 'admin-client-rw', 'secret', 'Admin client (read-write)', false, null, 3600, 600, true, 'SECRET_POST',false, null, CURRENT_TIMESTAMP(), true),
(19, 'public-client', null, 'Public client', false, 3600, 3600, 600, true, 'NONE', false, null, CURRENT_TIMESTAMP(), true),
(20, 'refresh-client', 'secret', 'Refresh Flow client', false, 36000, 3600, 600, true, 'SECRET_BASIC', true, 30, CURRENT_TIMESTAMP(), true),
(21, 'protected-resource', 'secret', 'Protected Resource allowed only to introspect', false, 0, 0, 0, true, 'SECRET_BASIC', true, 0, CURRENT_TIMESTAMP(), true);
(21, 'protected-resource', 'secret', 'Protected Resource allowed only to introspect', false, 0, 0, 0, true, 'SECRET_BASIC', true, 0, CURRENT_TIMESTAMP(), true),
(22, 'public-client-having-secret', 'secret', 'Public client', false, 3600, 3600, 600, true, 'NONE', false, null, CURRENT_TIMESTAMP(), true);

INSERT INTO client_details (id, client_id, client_secret, client_name, dynamically_registered,
refresh_token_validity_seconds, access_token_validity_seconds, id_token_validity_seconds, allow_introspection,
Expand Down
Loading