Polish
This commit is contained in:
@@ -239,7 +239,7 @@ public class CrshAutoConfiguration {
|
||||
try {
|
||||
token = this.authenticationManager.authenticate(token);
|
||||
}
|
||||
catch (AuthenticationException ae) {
|
||||
catch (AuthenticationException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ public class CrshAutoConfiguration {
|
||||
this.accessDecisionManager.decide(token, this,
|
||||
SecurityConfig.createList(this.roles));
|
||||
}
|
||||
catch (AccessDeniedException e) {
|
||||
catch (AccessDeniedException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -440,7 +440,7 @@ public class CrshAutoConfiguration {
|
||||
try {
|
||||
return this.resource.lastModified();
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ex) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -50,18 +50,18 @@ public class SimpleHealthIndicator implements HealthIndicator<Map<String, Object
|
||||
map.put("database", this.dataSource.getConnection().getMetaData()
|
||||
.getDatabaseProductName());
|
||||
}
|
||||
catch (SQLException e) {
|
||||
catch (SQLException ex) {
|
||||
map.put("status", "error");
|
||||
map.put("error", e.getClass().getName() + ": " + e.getMessage());
|
||||
map.put("error", ex.getClass().getName() + ": " + ex.getMessage());
|
||||
}
|
||||
if (StringUtils.hasText(this.query)) {
|
||||
try {
|
||||
map.put("hello",
|
||||
this.jdbcTemplate.queryForObject(this.query, String.class));
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
map.put("status", "error");
|
||||
map.put("error", e.getClass().getName() + ": " + e.getMessage());
|
||||
map.put("error", ex.getClass().getName() + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Tests for {@link CrshAutoConfiguration}.
|
||||
@@ -235,7 +234,7 @@ public class CrshAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleAuthenticationProvider() {
|
||||
public void testSimpleAuthenticationProvider() throws Exception {
|
||||
MockEnvironment env = new MockEnvironment();
|
||||
env.setProperty("shell.auth", "simple");
|
||||
env.setProperty("shell.auth.simple.username", "user");
|
||||
@@ -261,24 +260,13 @@ public class CrshAutoConfigurationTests {
|
||||
}
|
||||
}
|
||||
assertNotNull(authenticationPlugin);
|
||||
try {
|
||||
assertTrue(authenticationPlugin.authenticate("user", "password"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
|
||||
try {
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
"password"));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
assertTrue(authenticationPlugin.authenticate("user", "password"));
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
"password"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpringAuthenticationProvider() {
|
||||
public void testSpringAuthenticationProvider() throws Exception {
|
||||
MockEnvironment env = new MockEnvironment();
|
||||
env.setProperty("shell.auth", "spring");
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
@@ -300,22 +288,11 @@ public class CrshAutoConfigurationTests {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertNotNull(authenticationPlugin);
|
||||
try {
|
||||
assertTrue(authenticationPlugin.authenticate(SecurityConfiguration.USERNAME,
|
||||
SecurityConfiguration.PASSWORD));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
assertTrue(authenticationPlugin.authenticate(SecurityConfiguration.USERNAME,
|
||||
SecurityConfiguration.PASSWORD));
|
||||
|
||||
try {
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
SecurityConfiguration.PASSWORD));
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail();
|
||||
}
|
||||
assertFalse(authenticationPlugin.authenticate(UUID.randomUUID().toString(),
|
||||
SecurityConfiguration.PASSWORD));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
Reference in New Issue
Block a user