Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
fedd7b95
Commit
fedd7b95
authored
Mar 06, 2017
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
a3d51013
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
27 additions
and
19 deletions
+27
-19
CloudFoundryHealthMvcEndpoint.java
...t/actuate/cloudfoundry/CloudFoundryHealthMvcEndpoint.java
+2
-1
HealthMvcEndpoint.java
...ramework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java
+4
-3
MvcEndpointSecurityInterceptor.java
.../actuate/endpoint/mvc/MvcEndpointSecurityInterceptor.java
+1
-1
CloudFoundryHealthMvcEndpointTests.java
...uate/cloudfoundry/CloudFoundryHealthMvcEndpointTests.java
+1
-1
HealthMvcEndpointTests.java
...ork/boot/actuate/endpoint/mvc/HealthMvcEndpointTests.java
+2
-1
NoSpringSecurityHealthMvcEndpointIntegrationTests.java
...vc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java
+9
-3
MongoProperties.java
...ngframework/boot/autoconfigure/mongo/MongoProperties.java
+6
-7
MongoPropertiesTests.java
...mework/boot/autoconfigure/mongo/MongoPropertiesTests.java
+1
-1
JettyEmbeddedServletContainerFactoryTests.java
...dded/jetty/JettyEmbeddedServletContainerFactoryTests.java
+1
-1
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryHealthMvcEndpoint.java
View file @
fedd7b95
...
@@ -38,7 +38,8 @@ class CloudFoundryHealthMvcEndpoint extends HealthMvcEndpoint {
...
@@ -38,7 +38,8 @@ class CloudFoundryHealthMvcEndpoint extends HealthMvcEndpoint {
}
}
@Override
@Override
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
return
true
;
return
true
;
}
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java
View file @
fedd7b95
...
@@ -183,7 +183,8 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
...
@@ -183,7 +183,8 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
return
(
accessTime
-
this
.
lastAccess
)
>=
getDelegate
().
getTimeToLive
();
return
(
accessTime
-
this
.
lastAccess
)
>=
getDelegate
().
getTimeToLive
();
}
}
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
if
(!
this
.
secure
)
{
if
(!
this
.
secure
)
{
return
true
;
return
true
;
}
}
...
@@ -192,7 +193,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
...
@@ -192,7 +193,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
if
(
request
.
isUserInRole
(
role
))
{
if
(
request
.
isUserInRole
(
role
))
{
return
true
;
return
true
;
}
}
if
(
isSpringSecurityAuthentication
(
principal
))
{
if
(
isSpringSecurityAuthentication
(
principal
))
{
Authentication
authentication
=
(
Authentication
)
principal
;
Authentication
authentication
=
(
Authentication
)
principal
;
for
(
GrantedAuthority
authority
:
authentication
.
getAuthorities
())
{
for
(
GrantedAuthority
authority
:
authentication
.
getAuthorities
())
{
String
name
=
authority
.
getAuthority
();
String
name
=
authority
.
getAuthority
();
...
@@ -217,7 +218,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
...
@@ -217,7 +218,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
private
boolean
isSpringSecurityAuthentication
(
Principal
principal
)
{
private
boolean
isSpringSecurityAuthentication
(
Principal
principal
)
{
return
ClassUtils
.
isPresent
(
"org.springframework.security.core.Authentication"
,
return
ClassUtils
.
isPresent
(
"org.springframework.security.core.Authentication"
,
null
)
&&
(
principal
instanceof
Authentication
)
;
null
)
&&
principal
instanceof
Authentication
;
}
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointSecurityInterceptor.java
View file @
fedd7b95
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryHealthMvcEndpointTests.java
View file @
fedd7b95
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpointTests.java
View file @
fedd7b95
...
@@ -167,7 +167,8 @@ public class HealthMvcEndpointTests {
...
@@ -167,7 +167,8 @@ public class HealthMvcEndpointTests {
public
void
rightAuthorityPresentShouldExposeDetails
()
throws
Exception
{
public
void
rightAuthorityPresentShouldExposeDetails
()
throws
Exception
{
this
.
environment
.
getPropertySources
().
addLast
(
SECURITY_ROLES
);
this
.
environment
.
getPropertySources
().
addLast
(
SECURITY_ROLES
);
Authentication
principal
=
mock
(
Authentication
.
class
);
Authentication
principal
=
mock
(
Authentication
.
class
);
Set
<
SimpleGrantedAuthority
>
authorities
=
Collections
.
singleton
(
new
SimpleGrantedAuthority
(
"HERO"
));
Set
<
SimpleGrantedAuthority
>
authorities
=
Collections
.
singleton
(
new
SimpleGrantedAuthority
(
"HERO"
));
doReturn
(
authorities
).
when
(
principal
).
getAuthorities
();
doReturn
(
authorities
).
when
(
principal
).
getAuthorities
();
given
(
this
.
endpoint
.
invoke
())
given
(
this
.
endpoint
.
invoke
())
.
willReturn
(
new
Health
.
Builder
().
up
().
withDetail
(
"foo"
,
"bar"
).
build
());
.
willReturn
(
new
Health
.
Builder
().
up
().
withDetail
(
"foo"
,
"bar"
).
build
());
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java
View file @
fedd7b95
...
@@ -68,13 +68,15 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
...
@@ -68,13 +68,15 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
}
}
@Test
@Test
public
void
healthWhenRightRoleNotPresentShouldExposeHealthDetails
()
throws
Exception
{
public
void
healthWhenRightRoleNotPresentShouldExposeHealthDetails
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
.
setServletContext
(
new
MockServletContext
());
this
.
context
.
setServletContext
(
new
MockServletContext
());
this
.
context
.
register
(
TestConfiguration
.
class
);
this
.
context
.
register
(
TestConfiguration
.
class
);
this
.
context
.
refresh
();
this
.
context
.
refresh
();
MockMvc
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
MockMvc
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
mockMvc
.
perform
(
get
(
"/health"
).
with
(
getRequestPostProcessor
())).
andExpect
(
status
().
isOk
())
mockMvc
.
perform
(
get
(
"/health"
).
with
(
getRequestPostProcessor
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
containsString
(
"\"status\":\"UP\""
)));
.
andExpect
(
content
().
string
(
containsString
(
"\"status\":\"UP\""
)));
}
}
...
@@ -94,12 +96,15 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
...
@@ -94,12 +96,15 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
private
RequestPostProcessor
getRequestPostProcessor
()
{
private
RequestPostProcessor
getRequestPostProcessor
()
{
return
new
RequestPostProcessor
()
{
return
new
RequestPostProcessor
()
{
@Override
@Override
public
MockHttpServletRequest
postProcessRequest
(
MockHttpServletRequest
request
)
{
public
MockHttpServletRequest
postProcessRequest
(
MockHttpServletRequest
request
)
{
Principal
principal
=
mock
(
Principal
.
class
);
Principal
principal
=
mock
(
Principal
.
class
);
request
.
setUserPrincipal
(
principal
);
request
.
setUserPrincipal
(
principal
);
return
request
;
return
request
;
}
}
};
};
}
}
...
@@ -119,6 +124,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
...
@@ -119,6 +124,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
public
Health
health
()
{
public
Health
health
()
{
return
Health
.
up
().
withDetail
(
"hello"
,
"world"
).
build
();
return
Health
.
up
().
withDetail
(
"hello"
,
"world"
).
build
();
}
}
};
};
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java
View file @
fedd7b95
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
@@ -227,8 +227,7 @@ public class MongoProperties {
...
@@ -227,8 +227,7 @@ public class MongoProperties {
options
=
MongoClientOptions
.
builder
().
build
();
options
=
MongoClientOptions
.
builder
().
build
();
}
}
String
host
=
this
.
host
==
null
?
"localhost"
:
this
.
host
;
String
host
=
this
.
host
==
null
?
"localhost"
:
this
.
host
;
return
new
MongoClient
(
return
new
MongoClient
(
Collections
.
singletonList
(
new
ServerAddress
(
host
,
port
)),
Collections
.
singletonList
(
new
ServerAddress
(
host
,
port
)),
Collections
.<
MongoCredential
>
emptyList
(),
options
);
Collections
.<
MongoCredential
>
emptyList
(),
options
);
}
}
...
@@ -245,14 +244,14 @@ public class MongoProperties {
...
@@ -245,14 +244,14 @@ public class MongoProperties {
if
(
hasCustomCredentials
())
{
if
(
hasCustomCredentials
())
{
String
database
=
this
.
authenticationDatabase
==
null
String
database
=
this
.
authenticationDatabase
==
null
?
getMongoClientDatabase
()
:
this
.
authenticationDatabase
;
?
getMongoClientDatabase
()
:
this
.
authenticationDatabase
;
credentials
.
add
(
MongoCredential
.
createCredential
(
this
.
username
,
credentials
.
add
(
MongoCredential
.
createCredential
(
this
.
username
,
database
,
database
,
this
.
password
));
this
.
password
));
}
}
String
host
=
this
.
host
==
null
?
"localhost"
:
this
.
host
;
String
host
=
this
.
host
==
null
?
"localhost"
:
this
.
host
;
int
port
=
this
.
port
!=
null
?
this
.
port
:
DEFAULT_PORT
;
int
port
=
this
.
port
!=
null
?
this
.
port
:
DEFAULT_PORT
;
return
new
MongoClient
(
return
new
MongoClient
(
Collections
.
singletonList
(
new
ServerAddress
(
host
,
port
)),
Collections
.
singletonList
(
new
ServerAddress
(
host
,
port
)),
credentials
,
credentials
,
options
);
options
);
}
}
// The options and credentials are in the URI
// The options and credentials are in the URI
return
new
MongoClient
(
new
MongoClientURI
(
determineUri
(),
builder
(
options
)));
return
new
MongoClient
(
new
MongoClientURI
(
determineUri
(),
builder
(
options
)));
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoPropertiesTests.java
View file @
fedd7b95
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java
View file @
fedd7b95
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment