Skip to content

Commit

Permalink
Merge pull request #4222 from Gepardgame/fix/issue-4219
Browse files Browse the repository at this point in the history
Log contains now username when user gets deleted
  • Loading branch information
nscuro authored Oct 7, 2024
2 parents cad9e20 + ddf097f commit d84ee0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public Response deleteLdapUser(LdapUser jsonUser) {
if (user != null) {
final LdapUser detachedUser = qm.getPersistenceManager().detachCopy(user);
qm.delete(user);
super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "LDAP user deleted: " + detachedUser);
super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "LDAP user deleted: " + detachedUser.getUsername());
Notification.dispatch(new Notification()
.scope(NotificationScope.SYSTEM)
.group(NotificationGroup.USER_DELETED)
Expand Down Expand Up @@ -593,7 +593,7 @@ public Response deleteManagedUser(ManagedUser jsonUser) {
if (user != null) {
final ManagedUser detachedUser = qm.getPersistenceManager().detachCopy(user);
qm.delete(user);
super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "Managed user deleted: " +detachedUser);
super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "Managed user deleted: " + detachedUser.getUsername());
Notification.dispatch(new Notification()
.scope(NotificationScope.SYSTEM)
.group(NotificationGroup.USER_DELETED)
Expand Down Expand Up @@ -670,7 +670,7 @@ public Response deleteOidcUser(final OidcUser jsonUser) {
if (user != null) {
final OidcUser detachedUser = qm.getPersistenceManager().detachCopy(user);
qm.delete(user);
super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "OpenID Connect user deleted: " + detachedUser);
super.logSecurityEvent(LOGGER, SecurityMarkers.SECURITY_AUDIT, "OpenID Connect user deleted: " + detachedUser.getUsername());
Notification.dispatch(new Notification()
.scope(NotificationScope.SYSTEM)
.group(NotificationGroup.USER_DELETED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,19 @@ public void createOidcUserDuplicateUsernameTest() {
Assert.assertEquals("A user with the same username already exists. Cannot create new user.", body);
}

@Test
public void deleteOidcUserTest() {
qm.createOidcUser("blackbeard");
OidcUser user = new OidcUser();
user.setUsername("blackbeard");
Response response = jersey.target(V1_USER + "/oidc").request()
.header(X_API_KEY, apiKey)
.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true) // HACK
.method("DELETE", Entity.entity(user, MediaType.APPLICATION_JSON)); // HACK
// Hack: Workaround to https://github.com/eclipse-ee4j/jersey/issues/3798
Assert.assertEquals(204, response.getStatus(), 0);
}

@Test
public void addTeamToUserTest() {
qm.createManagedUser("blackbeard", "Captain BlackBeard", "blackbeard@example.com", TEST_USER_PASSWORD_HASH, false, false, false);
Expand Down

0 comments on commit d84ee0f

Please sign in to comment.