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
60afbdc8
Commit
60afbdc8
authored
Nov 06, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
871d65d8
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
85 additions
and
77 deletions
+85
-77
CloudFoundryWebFluxEndpointHandlerMapping.java
...y/reactive/CloudFoundryWebFluxEndpointHandlerMapping.java
+14
-11
ReactiveTokenValidator.java
...nfigure/cloudfoundry/reactive/ReactiveTokenValidator.java
+2
-2
ReactiveCloudFoundrySecurityInterceptorTests.java
...eactive/ReactiveCloudFoundrySecurityInterceptorTests.java
+3
-4
ReactiveCloudFoundrySecurityServiceTests.java
...ry/reactive/ReactiveCloudFoundrySecurityServiceTests.java
+36
-38
MetricsRestTemplateCustomizerTests.java
...etrics/web/client/MetricsRestTemplateCustomizerTests.java
+1
-1
DefaultErrorWebExceptionHandler.java
...e/web/reactive/error/DefaultErrorWebExceptionHandler.java
+2
-2
City.java
...ingframework/boot/autoconfigure/data/neo4j/city/City.java
+4
-2
Country.java
...mework/boot/autoconfigure/data/neo4j/country/Country.java
+4
-2
OAuth2WebSecurityConfigurationTests.java
...ty/oauth2/client/OAuth2WebSecurityConfigurationTests.java
+2
-2
ExampleGraph.java
...work/boot/test/autoconfigure/data/neo4j/ExampleGraph.java
+4
-2
LogbackLoggingSystemTests.java
...ework/boot/logging/logback/LogbackLoggingSystemTests.java
+6
-6
Customer.java
...-data-neo4j/src/main/java/sample/data/neo4j/Customer.java
+7
-5
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/CloudFoundryWebFluxEndpointHandlerMapping.java
View file @
60afbdc8
...
@@ -98,7 +98,8 @@ class CloudFoundryWebFluxEndpointHandlerMapping
...
@@ -98,7 +98,8 @@ class CloudFoundryWebFluxEndpointHandlerMapping
@ResponseBody
@ResponseBody
private
Publisher
<
ResponseEntity
<
Object
>>
links
(
ServerWebExchange
exchange
)
{
private
Publisher
<
ResponseEntity
<
Object
>>
links
(
ServerWebExchange
exchange
)
{
ServerHttpRequest
request
=
exchange
.
getRequest
();
ServerHttpRequest
request
=
exchange
.
getRequest
();
return
this
.
securityInterceptor
.
preHandle
(
exchange
,
""
).
map
(
securityResponse
->
{
return
this
.
securityInterceptor
.
preHandle
(
exchange
,
""
)
.
map
((
securityResponse
)
->
{
if
(!
securityResponse
.
getStatus
().
equals
(
HttpStatus
.
OK
))
{
if
(!
securityResponse
.
getStatus
().
equals
(
HttpStatus
.
OK
))
{
return
new
ResponseEntity
<>(
securityResponse
.
getStatus
());
return
new
ResponseEntity
<>(
securityResponse
.
getStatus
());
}
}
...
@@ -106,8 +107,10 @@ class CloudFoundryWebFluxEndpointHandlerMapping
...
@@ -106,8 +107,10 @@ class CloudFoundryWebFluxEndpointHandlerMapping
.
getAttribute
(
AccessLevel
.
REQUEST_ATTRIBUTE
);
.
getAttribute
(
AccessLevel
.
REQUEST_ATTRIBUTE
);
Map
<
String
,
Link
>
links
=
this
.
endpointLinksResolver
Map
<
String
,
Link
>
links
=
this
.
endpointLinksResolver
.
resolveLinks
(
getEndpoints
(),
request
.
getURI
().
toString
());
.
resolveLinks
(
getEndpoints
(),
request
.
getURI
().
toString
());
return
new
ResponseEntity
<>(
Collections
.
singletonMap
(
"_links"
,
return
new
ResponseEntity
<>(
getAccessibleLinks
(
accessLevel
,
links
)),
HttpStatus
.
OK
);
Collections
.
singletonMap
(
"_links"
,
getAccessibleLinks
(
accessLevel
,
links
)),
HttpStatus
.
OK
);
});
});
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveTokenValidator.java
View file @
60afbdc8
...
@@ -68,11 +68,11 @@ class ReactiveTokenValidator {
...
@@ -68,11 +68,11 @@ class ReactiveTokenValidator {
private
Mono
<
Void
>
validateKeyIdAndSignature
(
Token
token
)
{
private
Mono
<
Void
>
validateKeyIdAndSignature
(
Token
token
)
{
String
keyId
=
token
.
getKeyId
();
String
keyId
=
token
.
getKeyId
();
return
this
.
securityService
.
fetchTokenKeys
()
return
this
.
securityService
.
fetchTokenKeys
()
.
filter
(
tokenKeys
->
tokenKeys
.
containsKey
(
keyId
))
.
filter
(
(
tokenKeys
)
->
tokenKeys
.
containsKey
(
keyId
))
.
switchIfEmpty
(
Mono
.
error
(
.
switchIfEmpty
(
Mono
.
error
(
new
CloudFoundryAuthorizationException
(
Reason
.
INVALID_KEY_ID
,
new
CloudFoundryAuthorizationException
(
Reason
.
INVALID_KEY_ID
,
"Key Id present in token header does not match"
)))
"Key Id present in token header does not match"
)))
.
filter
(
tokenKeys
->
hasValidSignature
(
token
,
tokenKeys
.
get
(
keyId
)))
.
filter
(
(
tokenKeys
)
->
hasValidSignature
(
token
,
tokenKeys
.
get
(
keyId
)))
.
switchIfEmpty
(
Mono
.
error
(
new
CloudFoundryAuthorizationException
(
.
switchIfEmpty
(
Mono
.
error
(
new
CloudFoundryAuthorizationException
(
Reason
.
INVALID_SIGNATURE
,
"RSA Signature did not match content"
)))
Reason
.
INVALID_SIGNATURE
,
"RSA Signature did not match content"
)))
.
then
();
.
then
();
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityInterceptorTests.java
View file @
60afbdc8
...
@@ -130,10 +130,9 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
...
@@ -130,10 +130,9 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
.
header
(
HttpHeaders
.
AUTHORIZATION
,
"bearer "
+
mockAccessToken
())
.
header
(
HttpHeaders
.
AUTHORIZATION
,
"bearer "
+
mockAccessToken
())
.
build
());
.
build
());
StepVerifier
.
create
(
this
.
interceptor
.
preHandle
(
request
,
"/a"
))
StepVerifier
.
create
(
this
.
interceptor
.
preHandle
(
request
,
"/a"
))
.
consumeNextWith
((
response
)
->
{
.
consumeNextWith
((
response
)
->
assertThat
(
response
.
getStatus
())
assertThat
(
response
.
getStatus
())
.
isEqualTo
(
Reason
.
ACCESS_DENIED
.
getStatus
()))
.
isEqualTo
(
Reason
.
ACCESS_DENIED
.
getStatus
());
.
verifyComplete
();
}).
verifyComplete
();
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundrySecurityServiceTests.java
View file @
60afbdc8
...
@@ -70,15 +70,15 @@ public class ReactiveCloudFoundrySecurityServiceTests {
...
@@ -70,15 +70,15 @@ public class ReactiveCloudFoundrySecurityServiceTests {
@Test
@Test
public
void
getAccessLevelWhenSpaceDeveloperShouldReturnFull
()
throws
Exception
{
public
void
getAccessLevelWhenSpaceDeveloperShouldReturnFull
()
throws
Exception
{
String
responseBody
=
"{\"read_sensitive_data\": true,\"read_basic_data\": true}"
;
String
responseBody
=
"{\"read_sensitive_data\": true,\"read_basic_data\": true}"
;
prepareResponse
(
response
->
response
.
setBody
(
responseBody
)
prepareResponse
(
(
response
)
->
response
.
setBody
(
responseBody
)
.
setHeader
(
"Content-Type"
,
"application/json"
));
.
setHeader
(
"Content-Type"
,
"application/json"
));
StepVerifier
StepVerifier
.
create
(
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
.
create
(
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
"my-app-id"
))
.
consumeNextWith
(
accessLevel
->
assertThat
(
accessLevel
)
.
consumeNextWith
(
(
accessLevel
)
->
assertThat
(
accessLevel
)
.
isEqualTo
(
AccessLevel
.
FULL
))
.
isEqualTo
(
AccessLevel
.
FULL
))
.
expectComplete
().
verify
();
.
expectComplete
().
verify
();
expectRequest
(
request
->
{
expectRequest
(
(
request
)
->
{
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
.
isEqualTo
(
"bearer my-access-token"
);
.
isEqualTo
(
"bearer my-access-token"
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
...
@@ -89,15 +89,15 @@ public class ReactiveCloudFoundrySecurityServiceTests {
...
@@ -89,15 +89,15 @@ public class ReactiveCloudFoundrySecurityServiceTests {
public
void
getAccessLevelWhenNotSpaceDeveloperShouldReturnRestricted
()
public
void
getAccessLevelWhenNotSpaceDeveloperShouldReturnRestricted
()
throws
Exception
{
throws
Exception
{
String
responseBody
=
"{\"read_sensitive_data\": false,\"read_basic_data\": true}"
;
String
responseBody
=
"{\"read_sensitive_data\": false,\"read_basic_data\": true}"
;
prepareResponse
(
response
->
response
.
setBody
(
responseBody
)
prepareResponse
(
(
response
)
->
response
.
setBody
(
responseBody
)
.
setHeader
(
"Content-Type"
,
"application/json"
));
.
setHeader
(
"Content-Type"
,
"application/json"
));
StepVerifier
StepVerifier
.
create
(
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
.
create
(
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
"my-app-id"
))
.
consumeNextWith
(
accessLevel
->
assertThat
(
accessLevel
)
.
consumeNextWith
(
(
accessLevel
)
->
assertThat
(
accessLevel
)
.
isEqualTo
(
AccessLevel
.
RESTRICTED
))
.
isEqualTo
(
AccessLevel
.
RESTRICTED
))
.
expectComplete
().
verify
();
.
expectComplete
().
verify
();
expectRequest
(
request
->
{
expectRequest
(
(
request
)
->
{
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
.
isEqualTo
(
"bearer my-access-token"
);
.
isEqualTo
(
"bearer my-access-token"
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
...
@@ -106,17 +106,17 @@ public class ReactiveCloudFoundrySecurityServiceTests {
...
@@ -106,17 +106,17 @@ public class ReactiveCloudFoundrySecurityServiceTests {
@Test
@Test
public
void
getAccessLevelWhenTokenIsNotValidShouldThrowException
()
throws
Exception
{
public
void
getAccessLevelWhenTokenIsNotValidShouldThrowException
()
throws
Exception
{
prepareResponse
(
response
->
response
.
setResponseCode
(
401
));
prepareResponse
(
(
response
)
->
response
.
setResponseCode
(
401
));
StepVerifier
.
create
(
StepVerifier
.
create
(
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
.
consumeErrorWith
(
throwable
->
{
.
consumeErrorWith
(
(
throwable
)
->
{
assertThat
(
throwable
)
assertThat
(
throwable
)
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
assertThat
(
assertThat
(
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
.
isEqualTo
(
Reason
.
INVALID_TOKEN
);
.
isEqualTo
(
Reason
.
INVALID_TOKEN
);
}).
verify
();
}).
verify
();
expectRequest
(
request
->
{
expectRequest
(
(
request
)
->
{
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
.
isEqualTo
(
"bearer my-access-token"
);
.
isEqualTo
(
"bearer my-access-token"
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
...
@@ -125,17 +125,17 @@ public class ReactiveCloudFoundrySecurityServiceTests {
...
@@ -125,17 +125,17 @@ public class ReactiveCloudFoundrySecurityServiceTests {
@Test
@Test
public
void
getAccessLevelWhenForbiddenShouldThrowException
()
throws
Exception
{
public
void
getAccessLevelWhenForbiddenShouldThrowException
()
throws
Exception
{
prepareResponse
(
response
->
response
.
setResponseCode
(
403
));
prepareResponse
(
(
response
)
->
response
.
setResponseCode
(
403
));
StepVerifier
.
create
(
StepVerifier
.
create
(
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
.
consumeErrorWith
(
throwable
->
{
.
consumeErrorWith
(
(
throwable
)
->
{
assertThat
(
throwable
)
assertThat
(
throwable
)
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
assertThat
(
assertThat
(
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
.
isEqualTo
(
Reason
.
ACCESS_DENIED
);
.
isEqualTo
(
Reason
.
ACCESS_DENIED
);
}).
verify
();
}).
verify
();
expectRequest
(
request
->
{
expectRequest
(
(
request
)
->
{
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
.
isEqualTo
(
"bearer my-access-token"
);
.
isEqualTo
(
"bearer my-access-token"
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
...
@@ -145,17 +145,17 @@ public class ReactiveCloudFoundrySecurityServiceTests {
...
@@ -145,17 +145,17 @@ public class ReactiveCloudFoundrySecurityServiceTests {
@Test
@Test
public
void
getAccessLevelWhenCloudControllerIsNotReachableThrowsException
()
public
void
getAccessLevelWhenCloudControllerIsNotReachableThrowsException
()
throws
Exception
{
throws
Exception
{
prepareResponse
(
response
->
response
.
setResponseCode
(
500
));
prepareResponse
(
(
response
)
->
response
.
setResponseCode
(
500
));
StepVerifier
.
create
(
StepVerifier
.
create
(
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
this
.
securityService
.
getAccessLevel
(
"my-access-token"
,
"my-app-id"
))
.
consumeErrorWith
(
throwable
->
{
.
consumeErrorWith
(
(
throwable
)
->
{
assertThat
(
throwable
)
assertThat
(
throwable
)
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
assertThat
(
assertThat
(
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
.
isEqualTo
(
Reason
.
SERVICE_UNAVAILABLE
);
.
isEqualTo
(
Reason
.
SERVICE_UNAVAILABLE
);
}).
verify
();
}).
verify
();
expectRequest
(
request
->
{
expectRequest
(
(
request
)
->
{
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
assertThat
(
request
.
getHeader
(
HttpHeaders
.
AUTHORIZATION
))
.
isEqualTo
(
"bearer my-access-token"
);
.
isEqualTo
(
"bearer my-access-token"
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
assertThat
(
request
.
getPath
()).
isEqualTo
(
CLOUD_CONTROLLER_PERMISSIONS
);
...
@@ -173,78 +173,76 @@ public class ReactiveCloudFoundrySecurityServiceTests {
...
@@ -173,78 +173,76 @@ public class ReactiveCloudFoundrySecurityServiceTests {
+
"kqwIn7Glry9n9Suxygbf8g5AzpWcusZgDLIIZ7JTUldBb8qU2a0Dl4mvLZOn4wPo\n"
+
"kqwIn7Glry9n9Suxygbf8g5AzpWcusZgDLIIZ7JTUldBb8qU2a0Dl4mvLZOn4wPo\n"
+
"jfj9Cw2QICsc5+Pwf21fP+hzf+1WSRHbnYv8uanRO0gZ8ekGaghM/2H6gqJbo2nI\n"
+
"jfj9Cw2QICsc5+Pwf21fP+hzf+1WSRHbnYv8uanRO0gZ8ekGaghM/2H6gqJbo2nI\n"
+
"JwIDAQAB\n-----END PUBLIC KEY-----"
;
+
"JwIDAQAB\n-----END PUBLIC KEY-----"
;
prepareResponse
(
response
->
{
prepareResponse
(
(
response
)
->
{
response
.
setBody
(
"{\"token_endpoint\":\"/my-uaa.com\"}"
);
response
.
setBody
(
"{\"token_endpoint\":\"/my-uaa.com\"}"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
});
});
String
responseBody
=
"{\"keys\" : [ {\"kid\":\"test-key\",\"value\" : \""
String
responseBody
=
"{\"keys\" : [ {\"kid\":\"test-key\",\"value\" : \""
+
tokenKeyValue
.
replace
(
"\n"
,
"\\n"
)
+
"\"} ]}"
;
+
tokenKeyValue
.
replace
(
"\n"
,
"\\n"
)
+
"\"} ]}"
;
prepareResponse
(
response
->
{
prepareResponse
(
(
response
)
->
{
response
.
setBody
(
responseBody
);
response
.
setBody
(
responseBody
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
});
});
StepVerifier
.
create
(
this
.
securityService
.
fetchTokenKeys
())
StepVerifier
.
create
(
this
.
securityService
.
fetchTokenKeys
())
.
consumeNextWith
(
tokenKeys
->
assertThat
(
tokenKeys
.
get
(
"test-key"
))
.
consumeNextWith
(
(
tokenKeys
)
->
assertThat
(
tokenKeys
.
get
(
"test-key"
))
.
isEqualTo
(
tokenKeyValue
))
.
isEqualTo
(
tokenKeyValue
))
.
expectComplete
().
verify
();
.
expectComplete
().
verify
();
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
"/my-cloud-controller.com/info"
));
.
isEqualTo
(
"/my-cloud-controller.com/info"
));
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
"/my-uaa.com/token_keys"
));
.
isEqualTo
(
"/my-uaa.com/token_keys"
));
}
}
@Test
@Test
public
void
fetchTokenKeysWhenNoKeysReturnedFromUAA
()
throws
Exception
{
public
void
fetchTokenKeysWhenNoKeysReturnedFromUAA
()
throws
Exception
{
prepareResponse
(
response
->
{
prepareResponse
(
(
response
)
->
{
response
.
setBody
(
"{\"token_endpoint\":\"/my-uaa.com\"}"
);
response
.
setBody
(
"{\"token_endpoint\":\"/my-uaa.com\"}"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
});
});
String
responseBody
=
"{\"keys\": []}"
;
String
responseBody
=
"{\"keys\": []}"
;
prepareResponse
(
response
->
{
prepareResponse
(
(
response
)
->
{
response
.
setBody
(
responseBody
);
response
.
setBody
(
responseBody
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
});
});
StepVerifier
.
create
(
this
.
securityService
.
fetchTokenKeys
())
StepVerifier
.
create
(
this
.
securityService
.
fetchTokenKeys
())
.
consumeNextWith
(
tokenKeys
->
assertThat
(
tokenKeys
).
hasSize
(
0
))
.
consumeNextWith
(
(
tokenKeys
)
->
assertThat
(
tokenKeys
).
hasSize
(
0
))
.
expectComplete
().
verify
();
.
expectComplete
().
verify
();
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
"/my-cloud-controller.com/info"
));
.
isEqualTo
(
"/my-cloud-controller.com/info"
));
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
"/my-uaa.com/token_keys"
));
.
isEqualTo
(
"/my-uaa.com/token_keys"
));
}
}
@Test
@Test
public
void
fetchTokenKeysWhenUnsuccessfulShouldThrowException
()
throws
Exception
{
public
void
fetchTokenKeysWhenUnsuccessfulShouldThrowException
()
throws
Exception
{
prepareResponse
(
response
->
{
prepareResponse
(
(
response
)
->
{
response
.
setBody
(
"{\"token_endpoint\":\"/my-uaa.com\"}"
);
response
.
setBody
(
"{\"token_endpoint\":\"/my-uaa.com\"}"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
});
});
prepareResponse
(
response
->
{
prepareResponse
((
response
)
->
response
.
setResponseCode
(
500
));
response
.
setResponseCode
(
500
);
});
StepVerifier
.
create
(
this
.
securityService
.
fetchTokenKeys
())
StepVerifier
.
create
(
this
.
securityService
.
fetchTokenKeys
())
.
consumeErrorWith
(
throwable
->
assertThat
(
.
consumeErrorWith
(
(
throwable
)
->
assertThat
(
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
.
isEqualTo
(
Reason
.
SERVICE_UNAVAILABLE
))
.
isEqualTo
(
Reason
.
SERVICE_UNAVAILABLE
))
.
verify
();
.
verify
();
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
"/my-cloud-controller.com/info"
));
.
isEqualTo
(
"/my-cloud-controller.com/info"
));
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
"/my-uaa.com/token_keys"
));
.
isEqualTo
(
"/my-uaa.com/token_keys"
));
}
}
@Test
@Test
public
void
getUaaUrlShouldCallCloudControllerInfoOnlyOnce
()
throws
Exception
{
public
void
getUaaUrlShouldCallCloudControllerInfoOnlyOnce
()
throws
Exception
{
prepareResponse
(
response
->
{
prepareResponse
(
(
response
)
->
{
response
.
setBody
(
"{\"token_endpoint\":\""
+
UAA_URL
+
"\"}"
);
response
.
setBody
(
"{\"token_endpoint\":\""
+
UAA_URL
+
"\"}"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
response
.
setHeader
(
"Content-Type"
,
"application/json"
);
});
});
StepVerifier
.
create
(
this
.
securityService
.
getUaaUrl
())
StepVerifier
.
create
(
this
.
securityService
.
getUaaUrl
())
.
consumeNextWith
(
uaaUrl
->
assertThat
(
uaaUrl
).
isEqualTo
(
UAA_URL
))
.
consumeNextWith
(
(
uaaUrl
)
->
assertThat
(
uaaUrl
).
isEqualTo
(
UAA_URL
))
.
expectComplete
().
verify
();
.
expectComplete
().
verify
();
// this.securityService.getUaaUrl().block(); //FIXME subscribe again to check that
// this.securityService.getUaaUrl().block(); //FIXME subscribe again to check that
// it isn't called again
// it isn't called again
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
CLOUD_CONTROLLER
+
"/info"
));
.
isEqualTo
(
CLOUD_CONTROLLER
+
"/info"
));
expectRequestCount
(
1
);
expectRequestCount
(
1
);
}
}
...
@@ -252,16 +250,16 @@ public class ReactiveCloudFoundrySecurityServiceTests {
...
@@ -252,16 +250,16 @@ public class ReactiveCloudFoundrySecurityServiceTests {
@Test
@Test
public
void
getUaaUrlWhenCloudControllerUrlIsNotReachableShouldThrowException
()
public
void
getUaaUrlWhenCloudControllerUrlIsNotReachableShouldThrowException
()
throws
Exception
{
throws
Exception
{
prepareResponse
(
response
->
response
.
setResponseCode
(
500
));
prepareResponse
(
(
response
)
->
response
.
setResponseCode
(
500
));
StepVerifier
.
create
(
this
.
securityService
.
getUaaUrl
())
StepVerifier
.
create
(
this
.
securityService
.
getUaaUrl
())
.
consumeErrorWith
(
throwable
->
{
.
consumeErrorWith
(
(
throwable
)
->
{
assertThat
(
throwable
)
assertThat
(
throwable
)
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
.
isInstanceOf
(
CloudFoundryAuthorizationException
.
class
);
assertThat
(
assertThat
(
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
((
CloudFoundryAuthorizationException
)
throwable
).
getReason
())
.
isEqualTo
(
Reason
.
SERVICE_UNAVAILABLE
);
.
isEqualTo
(
Reason
.
SERVICE_UNAVAILABLE
);
}).
verify
();
}).
verify
();
expectRequest
(
request
->
assertThat
(
request
.
getPath
())
expectRequest
(
(
request
)
->
assertThat
(
request
.
getPath
())
.
isEqualTo
(
CLOUD_CONTROLLER
+
"/info"
));
.
isEqualTo
(
CLOUD_CONTROLLER
+
"/info"
));
}
}
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/client/MetricsRestTemplateCustomizerTests.java
View file @
60afbdc8
...
@@ -60,7 +60,7 @@ public class MetricsRestTemplateCustomizerTests {
...
@@ -60,7 +60,7 @@ public class MetricsRestTemplateCustomizerTests {
String
result
=
restTemplate
.
getForObject
(
"/test/{id}"
,
String
.
class
,
123
);
String
result
=
restTemplate
.
getForObject
(
"/test/{id}"
,
String
.
class
,
123
);
MockClock
.
clock
(
registry
).
add
(
SimpleConfig
.
DEFAULT_STEP
);
MockClock
.
clock
(
registry
).
add
(
SimpleConfig
.
DEFAULT_STEP
);
assertThat
(
registry
.
find
(
"http.client.requests"
)
assertThat
(
registry
.
find
(
"http.client.requests"
)
.
meters
()).
anySatisfy
(
m
->
assertThat
(
.
meters
()).
anySatisfy
(
(
m
)
->
assertThat
(
StreamSupport
.
stream
(
m
.
getId
().
getTags
().
spliterator
(),
false
)
StreamSupport
.
stream
(
m
.
getId
().
getTags
().
spliterator
(),
false
)
.
map
(
Tag:
:
getKey
)).
doesNotContain
(
"bucket"
));
.
map
(
Tag:
:
getKey
)).
doesNotContain
(
"bucket"
));
assertThat
(
registry
.
find
(
"http.client.requests"
)
assertThat
(
registry
.
find
(
"http.client.requests"
)
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java
View file @
60afbdc8
...
@@ -123,7 +123,7 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
...
@@ -123,7 +123,7 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
"error/"
+
SERIES_VIEWS
.
get
(
errorStatus
.
series
()),
"error/error"
)
"error/"
+
SERIES_VIEWS
.
get
(
errorStatus
.
series
()),
"error/error"
)
.
flatMap
((
viewName
)
->
renderErrorView
(
viewName
,
response
,
error
))
.
flatMap
((
viewName
)
->
renderErrorView
(
viewName
,
response
,
error
))
.
switchIfEmpty
(
renderDefaultErrorView
(
response
,
error
)).
next
()
.
switchIfEmpty
(
renderDefaultErrorView
(
response
,
error
)).
next
()
.
doOnNext
(
resp
->
logError
(
request
,
errorStatus
));
.
doOnNext
(
(
resp
)
->
logError
(
request
,
errorStatus
));
}
}
/**
/**
...
@@ -138,7 +138,7 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
...
@@ -138,7 +138,7 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
return
ServerResponse
.
status
(
getHttpStatus
(
error
))
return
ServerResponse
.
status
(
getHttpStatus
(
error
))
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
)
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
)
.
body
(
BodyInserters
.
fromObject
(
error
))
.
body
(
BodyInserters
.
fromObject
(
error
))
.
doOnNext
(
resp
->
logError
(
request
,
errorStatus
));
.
doOnNext
(
(
resp
)
->
logError
(
request
,
errorStatus
));
}
}
/**
/**
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/city/City.java
View file @
60afbdc8
...
@@ -18,7 +18,8 @@ package org.springframework.boot.autoconfigure.data.neo4j.city;
...
@@ -18,7 +18,8 @@ package org.springframework.boot.autoconfigure.data.neo4j.city;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
org.neo4j.ogm.annotation.GraphId
;
import
org.neo4j.ogm.annotation.GeneratedValue
;
import
org.neo4j.ogm.annotation.Id
;
import
org.neo4j.ogm.annotation.NodeEntity
;
import
org.neo4j.ogm.annotation.NodeEntity
;
import
org.springframework.boot.autoconfigure.data.neo4j.country.Country
;
import
org.springframework.boot.autoconfigure.data.neo4j.country.Country
;
...
@@ -28,7 +29,8 @@ public class City implements Serializable {
...
@@ -28,7 +29,8 @@ public class City implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@GraphId
@Id
@GeneratedValue
private
Long
id
;
private
Long
id
;
private
String
name
;
private
String
name
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/neo4j/country/Country.java
View file @
60afbdc8
...
@@ -18,7 +18,8 @@ package org.springframework.boot.autoconfigure.data.neo4j.country;
...
@@ -18,7 +18,8 @@ package org.springframework.boot.autoconfigure.data.neo4j.country;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
org.neo4j.ogm.annotation.GraphId
;
import
org.neo4j.ogm.annotation.GeneratedValue
;
import
org.neo4j.ogm.annotation.Id
;
import
org.neo4j.ogm.annotation.NodeEntity
;
import
org.neo4j.ogm.annotation.NodeEntity
;
@NodeEntity
@NodeEntity
...
@@ -26,7 +27,8 @@ public class Country implements Serializable {
...
@@ -26,7 +27,8 @@ public class Country implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@GraphId
@Id
@GeneratedValue
private
Long
id
;
private
Long
id
;
private
String
name
;
private
String
name
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2WebSecurityConfigurationTests.java
View file @
60afbdc8
...
@@ -93,7 +93,7 @@ public class OAuth2WebSecurityConfigurationTests {
...
@@ -93,7 +93,7 @@ public class OAuth2WebSecurityConfigurationTests {
@Test
@Test
public
void
configurationRegistersAuthorizedClientServiceBean
()
throws
Exception
{
public
void
configurationRegistersAuthorizedClientServiceBean
()
throws
Exception
{
this
.
contextRunner
.
withUserConfiguration
(
ClientRepositoryConfiguration
.
class
,
this
.
contextRunner
.
withUserConfiguration
(
ClientRepositoryConfiguration
.
class
,
OAuth2WebSecurityConfiguration
.
class
).
run
(
context
->
{
OAuth2WebSecurityConfiguration
.
class
).
run
(
(
context
)
->
{
OAuth2AuthorizedClientService
bean
=
context
OAuth2AuthorizedClientService
bean
=
context
.
getBean
(
OAuth2AuthorizedClientService
.
class
);
.
getBean
(
OAuth2AuthorizedClientService
.
class
);
OAuth2AuthorizedClientService
authorizedClientService
=
(
OAuth2AuthorizedClientService
)
ReflectionTestUtils
OAuth2AuthorizedClientService
authorizedClientService
=
(
OAuth2AuthorizedClientService
)
ReflectionTestUtils
...
@@ -108,7 +108,7 @@ public class OAuth2WebSecurityConfigurationTests {
...
@@ -108,7 +108,7 @@ public class OAuth2WebSecurityConfigurationTests {
this
.
contextRunner
this
.
contextRunner
.
withUserConfiguration
(
OAuth2AuthorizedClientServiceConfiguration
.
class
,
.
withUserConfiguration
(
OAuth2AuthorizedClientServiceConfiguration
.
class
,
OAuth2WebSecurityConfiguration
.
class
)
OAuth2WebSecurityConfiguration
.
class
)
.
run
(
context
->
{
.
run
(
(
context
)
->
{
OAuth2AuthorizedClientService
bean
=
context
OAuth2AuthorizedClientService
bean
=
context
.
getBean
(
OAuth2AuthorizedClientService
.
class
);
.
getBean
(
OAuth2AuthorizedClientService
.
class
);
OAuth2AuthorizedClientService
authorizedClientService
=
(
OAuth2AuthorizedClientService
)
ReflectionTestUtils
OAuth2AuthorizedClientService
authorizedClientService
=
(
OAuth2AuthorizedClientService
)
ReflectionTestUtils
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/ExampleGraph.java
View file @
60afbdc8
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
neo4j
;
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
data
.
neo4j
;
import
org.neo4j.ogm.annotation.GraphId
;
import
org.neo4j.ogm.annotation.GeneratedValue
;
import
org.neo4j.ogm.annotation.Id
;
import
org.neo4j.ogm.annotation.NodeEntity
;
import
org.neo4j.ogm.annotation.NodeEntity
;
import
org.neo4j.ogm.annotation.Property
;
import
org.neo4j.ogm.annotation.Property
;
...
@@ -28,7 +29,8 @@ import org.neo4j.ogm.annotation.Property;
...
@@ -28,7 +29,8 @@ import org.neo4j.ogm.annotation.Property;
@NodeEntity
@NodeEntity
public
class
ExampleGraph
{
public
class
ExampleGraph
{
@GraphId
@Id
@GeneratedValue
private
Long
id
;
private
Long
id
;
@Property
@Property
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
View file @
60afbdc8
...
@@ -460,16 +460,16 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
...
@@ -460,16 +460,16 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
return
context
.
getLogger
(
org
.
slf4j
.
Logger
.
ROOT_LOGGER_NAME
);
return
context
.
getLogger
(
org
.
slf4j
.
Logger
.
ROOT_LOGGER_NAME
);
}
}
private
static
ConsoleAppender
getConsoleAppender
()
{
private
static
ConsoleAppender
<?>
getConsoleAppender
()
{
return
(
ConsoleAppender
)
getRootLogger
().
getAppender
(
"CONSOLE"
);
return
(
ConsoleAppender
<?>
)
getRootLogger
().
getAppender
(
"CONSOLE"
);
}
}
private
static
RollingFileAppender
getFileAppender
()
{
private
static
RollingFileAppender
<?>
getFileAppender
()
{
return
(
RollingFileAppender
)
getRootLogger
().
getAppender
(
"FILE"
);
return
(
RollingFileAppender
<?>
)
getRootLogger
().
getAppender
(
"FILE"
);
}
}
private
static
SizeAndTimeBasedRollingPolicy
getRollingPolicy
()
{
private
static
SizeAndTimeBasedRollingPolicy
<?>
getRollingPolicy
()
{
return
(
SizeAndTimeBasedRollingPolicy
)
getFileAppender
().
getRollingPolicy
();
return
(
SizeAndTimeBasedRollingPolicy
<?>
)
getFileAppender
().
getRollingPolicy
();
}
}
private
String
getLineWithText
(
File
file
,
String
outputSearch
)
throws
Exception
{
private
String
getLineWithText
(
File
file
,
String
outputSearch
)
throws
Exception
{
...
...
spring-boot-samples/spring-boot-sample-data-neo4j/src/main/java/sample/data/neo4j/Customer.java
View file @
60afbdc8
/*
/*
* 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.
...
@@ -16,13 +16,15 @@
...
@@ -16,13 +16,15 @@
package
sample
.
data
.
neo4j
;
package
sample
.
data
.
neo4j
;
import
org.neo4j.ogm.annotation.GraphId
;
import
org.neo4j.ogm.annotation.GeneratedValue
;
import
org.neo4j.ogm.annotation.Id
;
import
org.neo4j.ogm.annotation.NodeEntity
;
import
org.neo4j.ogm.annotation.NodeEntity
;
@NodeEntity
@NodeEntity
public
class
Customer
{
public
class
Customer
{
@GraphId
@Id
@GeneratedValue
private
Long
id
;
private
Long
id
;
private
String
firstName
;
private
String
firstName
;
...
@@ -38,8 +40,8 @@ public class Customer {
...
@@ -38,8 +40,8 @@ public class Customer {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
String
.
format
(
"Customer[id=%s, firstName='%s', lastName='%s']"
,
id
,
return
String
.
format
(
"Customer[id=%s, firstName='%s', lastName='%s']"
,
this
.
id
,
firstName
,
lastName
);
this
.
firstName
,
this
.
lastName
);
}
}
}
}
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