Drop redundant web extension for sessions endpoint

Changes made in f1cfad67 mean that the web-specific extension is no
longer required as the infrastructure now automatically produces a
bad request (400) response when a required query parameter is absent.

See gh-10372
This commit is contained in:
Andy Wilkinson 2017-11-12 11:19:14 +00:00
parent 8d04525eb7
commit 806cf32549
4 changed files with 3 additions and 73 deletions

View File

@ -18,7 +18,6 @@ package org.springframework.boot.actuate.autoconfigure.session;
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
import org.springframework.boot.actuate.session.SessionsEndpoint;
import org.springframework.boot.actuate.session.SessionsWebEndpointExtension;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@ -50,13 +49,4 @@ public class SessionsEndpointAutoConfiguration {
return new SessionsEndpoint(sessionRepository);
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnEnabledEndpoint
@ConditionalOnBean(SessionsEndpoint.class)
public SessionsWebEndpointExtension sessionsWebEndpointExtension(
SessionsEndpoint sessionsEndpoint) {
return new SessionsWebEndpointExtension(sessionsEndpoint);
}
}

View File

@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.session;
import org.junit.Test;
import org.springframework.boot.actuate.session.SessionsEndpoint;
import org.springframework.boot.actuate.session.SessionsWebEndpointExtension;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
@ -48,18 +47,10 @@ public class SessionsEndpointAutoConfigurationTests {
}
@Test
public void runShouldHaveWebExtensionBean() {
this.contextRunner.run((context) -> assertThat(context)
.hasSingleBean(SessionsWebEndpointExtension.class));
}
@Test
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointOrExtensionBean()
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
throws Exception {
this.contextRunner.withPropertyValues("endpoints.sessions.enabled:false")
.run((context) -> assertThat(context)
.doesNotHaveBean(SessionsEndpoint.class)
.doesNotHaveBean(SessionsWebEndpointExtension.class));
this.contextRunner.withPropertyValues("endpoints.sessions.enabled:false").run(
(context) -> assertThat(context).doesNotHaveBean(SessionsEndpoint.class));
}
@Configuration

View File

@ -1,45 +0,0 @@
/*
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.actuate.session;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointExtension;
import org.springframework.boot.actuate.session.SessionsEndpoint.SessionsReport;
/**
* {@link WebEndpointExtension} for the {@link SessionsEndpoint}.
*
* @author Vedran Pavic
* @since 2.0.0
*/
@WebEndpointExtension(endpoint = SessionsEndpoint.class)
public class SessionsWebEndpointExtension {
private final SessionsEndpoint delegate;
public SessionsWebEndpointExtension(SessionsEndpoint delegate) {
this.delegate = delegate;
}
@ReadOperation
public WebEndpointResponse<SessionsReport> sessionsForUsername(String username) {
SessionsReport sessions = this.delegate.sessionsForUsername(username);
return new WebEndpointResponse<>(sessions);
}
}

View File

@ -88,12 +88,6 @@ public class SessionsEndpointWebIntegrationTests {
return new SessionsEndpoint(repository);
}
@Bean
public SessionsWebEndpointExtension sessionsWebEndpointExtension(
SessionsEndpoint delegate) {
return new SessionsWebEndpointExtension(delegate);
}
}
}