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
7fb0bd77
Commit
7fb0bd77
authored
Dec 12, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Handle null Principal in AuditEvent"
Closes gh-11320
parent
6b6a01a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
AuditEvent.java
...va/org/springframework/boot/actuate/audit/AuditEvent.java
+2
-2
AuditEventTests.java
...g/springframework/boot/actuate/audit/AuditEventTests.java
+7
-7
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java
View file @
7fb0bd77
...
...
@@ -41,7 +41,6 @@ import org.springframework.util.Assert;
* (wrappers for AuditEvent).
*
* @author Dave Syer
* @author Nakul Mishra
* @see AuditEventRepository
*/
@JsonInclude
(
Include
.
NON_EMPTY
)
...
...
@@ -117,7 +116,8 @@ public class AuditEvent implements Serializable {
}
/**
* Returns the user principal responsible for the event.
* Returns the user principal responsible for the event or an empty String if the
* principal is not available.
* @return the principal
*/
public
String
getPrincipal
()
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/audit/AuditEventTests.java
View file @
7fb0bd77
...
...
@@ -32,7 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Dave Syer
* @author Vedran Pavic
* @author Nakul Mishra
*/
public
class
AuditEventTests
{
...
...
@@ -56,6 +55,13 @@ public class AuditEventTests {
assertThat
(
event
.
getData
().
get
(
"c"
)).
isEqualTo
(
"d"
);
}
@Test
public
void
nullPrincipalIsMappedToEmptyString
()
{
AuditEvent
auditEvent
=
new
AuditEvent
(
null
,
"UNKNOWN"
,
Collections
.
singletonMap
(
"a"
,
(
Object
)
"b"
));
assertThat
(
auditEvent
.
getPrincipal
()).
isEmpty
();
}
@Test
public
void
nullTimestamp
()
throws
Exception
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
...
...
@@ -64,12 +70,6 @@ public class AuditEventTests {
Collections
.
singletonMap
(
"a"
,
(
Object
)
"b"
));
}
@Test
public
void
nullPrincipal
()
{
AuditEvent
auditEvent
=
new
AuditEvent
(
null
,
"UNKNOWN"
,
Collections
.
singletonMap
(
"a"
,
(
Object
)
"b"
));
assertThat
(
auditEvent
.
getPrincipal
()).
isEmpty
();
}
@Test
public
void
nullType
()
throws
Exception
{
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
...
...
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