[KEYCLOAK-8646] - Error deleting policies when admin events are enabled

This commit is contained in:
Pedro Igor 2018-11-05 13:19:27 -02:00
parent 94f2ce2eae
commit bce2aee144
2 changed files with 38 additions and 3 deletions

View file

@ -56,8 +56,6 @@ import org.keycloak.util.JsonSerialization;
*/
public class PolicyResourceService {
@Context
private KeycloakSession session;
private final Policy policy;
protected final ResourceServer resourceServer;
protected final AuthorizationProvider authorization;
@ -260,7 +258,7 @@ public class PolicyResourceService {
private void audit(AbstractPolicyRepresentation policy, OperationType operation) {
if (authorization.getRealm().isAdminEventsEnabled()) {
adminEvent.operation(operation).resourcePath(session.getContext().getUri()).representation(policy).success();
adminEvent.operation(operation).resourcePath(authorization.getKeycloakSession().getContext().getUri()).representation(policy).success();
}
}
}

View file

@ -0,0 +1,37 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.admin.client.authorization;
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
import org.keycloak.testsuite.util.RealmBuilder;
/**
* @author <a href="mailto:psilva@redhat.com">Pedro Igor</a>
*/
public class GenericPolicyManagementAdminEventTest extends GenericPolicyManagementTest {
@Override
protected void afterAbstractKeycloakTestRealmImport() {
super.afterAbstractKeycloakTestRealmImport();
RealmEventsConfigRepresentation rep = new RealmEventsConfigRepresentation();
rep.setAdminEventsEnabled(true);
rep.setEventsEnabled(true);
testRealmResource().updateRealmEventsConfig(rep);
}
}