Commit 5d17ff6e authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #14124 from vpavic:align-session-bean

* pr/14124:
  Align SessionsEndpoint with Spring Session API improvements
  Start building against Spring Session Bean M2 snapshots
parents f6f9f271 644ab5f3
...@@ -89,9 +89,7 @@ public class SessionsEndpointDocumentationTests ...@@ -89,9 +89,7 @@ public class SessionsEndpointDocumentationTests
sessions.put(sessionOne.getId(), sessionOne); sessions.put(sessionOne.getId(), sessionOne);
sessions.put(sessionTwo.getId(), sessionTwo); sessions.put(sessionTwo.getId(), sessionTwo);
sessions.put(sessionThree.getId(), sessionThree); sessions.put(sessionThree.getId(), sessionThree);
given(this.sessionRepository.findByIndexNameAndIndexValue( given(this.sessionRepository.findByPrincipalName("alice")).willReturn(sessions);
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "alice"))
.willReturn(sessions);
this.mockMvc.perform(get("/actuator/sessions").param("username", "alice")) this.mockMvc.perform(get("/actuator/sessions").param("username", "alice"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andDo(document("sessions/username", .andDo(document("sessions/username",
......
...@@ -52,9 +52,7 @@ public class SessionsEndpoint { ...@@ -52,9 +52,7 @@ public class SessionsEndpoint {
@ReadOperation @ReadOperation
public SessionsReport sessionsForUsername(String username) { public SessionsReport sessionsForUsername(String username) {
Map<String, ? extends Session> sessions = this.sessionRepository Map<String, ? extends Session> sessions = this.sessionRepository
.findByIndexNameAndIndexValue( .findByPrincipalName(username);
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME,
username);
return new SessionsReport(sessions); return new SessionsReport(sessions);
} }
......
...@@ -48,8 +48,7 @@ public class SessionsEndpointTests { ...@@ -48,8 +48,7 @@ public class SessionsEndpointTests {
@Test @Test
public void sessionsForUsername() { public void sessionsForUsername() {
given(this.repository.findByIndexNameAndIndexValue( given(this.repository.findByPrincipalName("user"))
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "user"))
.willReturn(Collections.singletonMap(session.getId(), session)); .willReturn(Collections.singletonMap(session.getId(), session));
List<SessionDescriptor> result = this.endpoint.sessionsForUsername("user") List<SessionDescriptor> result = this.endpoint.sessionsForUsername("user")
.getSessions(); .getSessions();
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -58,9 +58,7 @@ public class SessionsEndpointWebIntegrationTests { ...@@ -58,9 +58,7 @@ public class SessionsEndpointWebIntegrationTests {
@Test @Test
public void sessionsForUsernameNoResults() { public void sessionsForUsernameNoResults() {
given(repository.findByIndexNameAndIndexValue( given(repository.findByPrincipalName("user")).willReturn(Collections.emptyMap());
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "user"))
.willReturn(Collections.emptyMap());
client.get() client.get()
.uri((builder) -> builder.path("/actuator/sessions") .uri((builder) -> builder.path("/actuator/sessions")
.queryParam("username", "user").build()) .queryParam("username", "user").build())
...@@ -70,8 +68,7 @@ public class SessionsEndpointWebIntegrationTests { ...@@ -70,8 +68,7 @@ public class SessionsEndpointWebIntegrationTests {
@Test @Test
public void sessionsForUsernameFound() { public void sessionsForUsernameFound() {
given(repository.findByIndexNameAndIndexValue( given(repository.findByPrincipalName("user"))
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "user"))
.willReturn(Collections.singletonMap(session.getId(), session)); .willReturn(Collections.singletonMap(session.getId(), session));
client.get() client.get()
.uri((builder) -> builder.path("/actuator/sessions") .uri((builder) -> builder.path("/actuator/sessions")
......
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
<spring-restdocs.version>2.0.2.RELEASE</spring-restdocs.version> <spring-restdocs.version>2.0.2.RELEASE</spring-restdocs.version>
<spring-retry.version>1.2.2.RELEASE</spring-retry.version> <spring-retry.version>1.2.2.RELEASE</spring-retry.version>
<spring-security.version>5.1.0.BUILD-SNAPSHOT</spring-security.version> <spring-security.version>5.1.0.BUILD-SNAPSHOT</spring-security.version>
<spring-session-bom.version>Bean-M1</spring-session-bom.version> <spring-session-bom.version>Bean-BUILD-SNAPSHOT</spring-session-bom.version>
<spring-ws.version>3.0.3.RELEASE</spring-ws.version> <spring-ws.version>3.0.3.RELEASE</spring-ws.version>
<sqlite-jdbc.version>3.23.1</sqlite-jdbc.version> <sqlite-jdbc.version>3.23.1</sqlite-jdbc.version>
<statsd-client.version>3.1.0</statsd-client.version> <statsd-client.version>3.1.0</statsd-client.version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment