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
2f24c186
Commit
2f24c186
authored
Jan 20, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish contribution
parent
3724db9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
29 deletions
+13
-29
AuthenticationAuditListener.java
...rk/boot/actuate/security/AuthenticationAuditListener.java
+1
-1
AuthenticationAuditListenerTests.java
...ot/actuate/security/AuthenticationAuditListenerTests.java
+12
-28
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/security/AuthenticationAuditListener.java
View file @
2f24c186
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java
View file @
2f24c186
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
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.
...
...
@@ -16,8 +16,6 @@
package
org
.
springframework
.
boot
.
actuate
.
security
;
import
java.util.Map
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.ArgumentCaptor
;
...
...
@@ -89,31 +87,17 @@ public class AuthenticationAuditListenerTests {
}
@Test
public
void
shouldPassDetailsToAuditEventOnAuthenticationFailureEvent
()
throws
Exception
{
// given
final
Object
details
=
new
Object
();
final
AuthenticationFailureExpiredEvent
event
=
createAuthenticationFailureEvent
(
details
);
// when
this
.
listener
.
onApplicationEvent
(
event
);
// then
final
ArgumentCaptor
<
AuditApplicationEvent
>
applicationEventArgumentCaptor
=
ArgumentCaptor
.
forClass
(
AuditApplicationEvent
.
class
);
verify
(
this
.
publisher
).
publishEvent
(
applicationEventArgumentCaptor
.
capture
());
final
Map
<
String
,
Object
>
eventData
=
applicationEventArgumentCaptor
.
getValue
().
getAuditEvent
().
getData
();
assertThat
(
eventData
,
hasEntry
(
"details"
,
details
));
}
private
AuthenticationFailureExpiredEvent
createAuthenticationFailureEvent
(
final
Object
details
)
{
final
UsernamePasswordAuthenticationToken
authentication
=
new
UsernamePasswordAuthenticationToken
(
"user"
,
"password"
);
public
void
testDetailsAreIncludedInAuditEvent
()
throws
Exception
{
Object
details
=
new
Object
();
UsernamePasswordAuthenticationToken
authentication
=
new
UsernamePasswordAuthenticationToken
(
"user"
,
"password"
);
authentication
.
setDetails
(
details
);
final
BadCredentialsException
exception
=
new
BadCredentialsException
(
"Bad user"
);
return
new
AuthenticationFailureExpiredEvent
(
authentication
,
exception
);
this
.
listener
.
onApplicationEvent
(
new
AuthenticationFailureExpiredEvent
(
authentication
,
new
BadCredentialsException
(
"Bad user"
)));
ArgumentCaptor
<
AuditApplicationEvent
>
auditApplicationEvent
=
ArgumentCaptor
.
forClass
(
AuditApplicationEvent
.
class
);
verify
(
this
.
publisher
).
publishEvent
(
auditApplicationEvent
.
capture
());
assertThat
(
auditApplicationEvent
.
getValue
().
getAuditEvent
().
getData
(),
hasEntry
(
"details"
,
details
));
}
}
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