Skip to content

Commit 88e64ba

Browse files
committed
Polish Tests
Issue gh-11992
1 parent 4e88623 commit 88e64ba

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

core/src/main/java/org/springframework/security/core/context/ObservationSecurityContextChangedListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
*/
3434
public final class ObservationSecurityContextChangedListener implements SecurityContextChangedListener {
3535

36-
private static final String SECURITY_CONTEXT_CREATED = "security.context.created";
36+
static final String SECURITY_CONTEXT_CREATED = "security.context.created";
3737

38-
private static final String SECURITY_CONTEXT_CHANGED = "security.context.changed";
38+
static final String SECURITY_CONTEXT_CHANGED = "security.context.changed";
3939

40-
private static final String SECURITY_CONTEXT_CLEARED = "security.context.cleared";
40+
static final String SECURITY_CONTEXT_CLEARED = "security.context.cleared";
4141

4242
private final ObservationRegistry registry;
4343

@@ -60,7 +60,7 @@ public void securityContextChanged(SecurityContextChangedEvent event) {
6060
return;
6161
}
6262
if (event.isCleared()) {
63-
observation.event(Observation.Event.of("security.context.cleared"));
63+
observation.event(Observation.Event.of(SECURITY_CONTEXT_CLEARED));
6464
return;
6565
}
6666
Authentication oldAuthentication = getAuthentication(event.getOldContext());

core/src/test/java/org/springframework/security/core/context/ObservationSecurityContextChangedListenerTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ void securityContextChangedWhenClearedEventThenAddsClearEventToObservation() {
6666
.securityContextChanged(new SecurityContextChangedEvent(one, SecurityContextChangedEvent.NO_CONTEXT));
6767
ArgumentCaptor<Observation.Event> event = ArgumentCaptor.forClass(Observation.Event.class);
6868
verify(observation).event(event.capture());
69-
assertThat(event.getValue().getName()).isEqualTo("security.context.cleared");
69+
assertThat(event.getValue().getName())
70+
.isEqualTo(ObservationSecurityContextChangedListener.SECURITY_CONTEXT_CLEARED);
7071
verifyNoInteractions(one);
7172
}
7273

@@ -85,7 +86,8 @@ void securityContextChangedWhenChangedEventThenAddsChangeEventToObservation() {
8586
this.tested.securityContextChanged(new SecurityContextChangedEvent(this.one, this.two));
8687
ArgumentCaptor<Observation.Event> event = ArgumentCaptor.forClass(Observation.Event.class);
8788
verify(observation).event(event.capture());
88-
assertThat(event.getValue().getName()).isEqualTo("security.context.changed");
89+
assertThat(event.getValue().getName())
90+
.isEqualTo(ObservationSecurityContextChangedListener.SECURITY_CONTEXT_CHANGED);
8991
}
9092

9193
@Test
@@ -95,7 +97,8 @@ void securityContextChangedWhenCreatedEventThenAddsCreatedEventToObservation() {
9597
this.tested.securityContextChanged(new SecurityContextChangedEvent(null, this.one));
9698
ArgumentCaptor<Observation.Event> event = ArgumentCaptor.forClass(Observation.Event.class);
9799
verify(observation).event(event.capture());
98-
assertThat(event.getValue().getName()).isEqualTo("security.context.created");
100+
assertThat(event.getValue().getName())
101+
.isEqualTo(ObservationSecurityContextChangedListener.SECURITY_CONTEXT_CREATED);
99102
}
100103

101104
}

0 commit comments

Comments
 (0)