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
b74a9b2d
Commit
b74a9b2d
authored
Nov 27, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests to FIXME
parent
67cc427d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
7 deletions
+43
-7
AuthenticationAuditListenerTests.java
...ot/actuate/security/AuthenticationAuditListenerTests.java
+43
-7
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java
View file @
b74a9b2d
...
...
@@ -16,23 +16,59 @@
package
org
.
springframework
.
boot
.
actuate
.
security
;
import
org.junit.
Ign
ore
;
import
org.junit.
Bef
ore
;
import
org.junit.Test
;
import
org.springframework.boot.actuate.security.AuthenticationAuditListener
;
import
org.mockito.Mockito
;
import
org.springframework.context.ApplicationEvent
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.event.AuthenticationFailureExpiredEvent
;
import
org.springframework.security.authentication.event.AuthenticationSuccessEvent
;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.security.web.authentication.switchuser.AuthenticationSwitchUserEvent
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
mockito
.
Matchers
.
anyObject
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
* Tests for {@link AuthenticationAuditListener}.
*/
@Ignore
public
class
AuthenticationAuditListenerTests
{
// FIXME
private
AuthenticationAuditListener
listener
=
new
AuthenticationAuditListener
();
private
ApplicationEventPublisher
publisher
=
Mockito
.
mock
(
ApplicationEventPublisher
.
class
);
@Before
public
void
init
()
{
this
.
listener
.
setApplicationEventPublisher
(
this
.
publisher
);
}
@Test
public
void
testAuthenticationSuccess
()
{
this
.
listener
.
onApplicationEvent
(
new
AuthenticationSuccessEvent
(
new
UsernamePasswordAuthenticationToken
(
"user"
,
"password"
)));
verify
(
this
.
publisher
).
publishEvent
((
ApplicationEvent
)
anyObject
());
}
@Test
public
void
testAuthenticationFailed
()
{
this
.
listener
.
onApplicationEvent
(
new
AuthenticationFailureExpiredEvent
(
new
UsernamePasswordAuthenticationToken
(
"user"
,
"password"
),
new
BadCredentialsException
(
"Bad user"
)));
verify
(
this
.
publisher
).
publishEvent
((
ApplicationEvent
)
anyObject
());
}
@Test
public
void
test
()
{
fail
(
"Not yet implemented"
);
public
void
testAuthenticationSwitch
()
{
this
.
listener
.
onApplicationEvent
(
new
AuthenticationSwitchUserEvent
(
new
UsernamePasswordAuthenticationToken
(
"user"
,
"password"
),
new
User
(
"user"
,
"password"
,
AuthorityUtils
.
commaSeparatedStringToAuthorityList
(
"USER"
))));
verify
(
this
.
publisher
).
publishEvent
((
ApplicationEvent
)
anyObject
());
}
}
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