Pass the UserId to the function that runs the inner function in the server as it was losing its value when defined globally for Wildfly and Quarkus

This commit is contained in:
Daniel Gozalo 2022-01-28 13:30:01 +01:00 committed by Marek Posolda
parent df7ddbf9b3
commit dc814b85c7
2 changed files with 4 additions and 7 deletions

View file

@ -88,7 +88,7 @@ public abstract class AbstractRARParserTest extends AbstractTestRealmKeycloakTes
* @return the {@link AuthorizationRequestContextHolder} local testsuite representation of the Authorization Request Context
* with all the parsed authorization_detail objects.
*/
protected AuthorizationRequestContextHolder fetchAuthorizationRequestContextHolder() {
protected AuthorizationRequestContextHolder fetchAuthorizationRequestContextHolder(String userId) {
AuthorizationRequestContextHolder authorizationRequestContextHolder = testingClient.server("test").fetch(session -> {
final RealmModel realm = session.realms().getRealmByName("test");
final UserModel user = session.users().getUserById(realm, userId);

View file

@ -46,7 +46,6 @@ import static org.junit.Assert.assertEquals;
public class DynamicScopesRARParseTest extends AbstractRARParserTest {
@Test
@Ignore("ignored until we figure out why it fails on Quarkus and Wildfly")
public void generatedAuthorizationRequestsShouldMatchDefaultScopes() {
ClientResource testApp = ApiUtil.findClientByClientId(testRealm(), "test-app");
List<ClientScopeRepresentation> defScopes = testApp.getDefaultClientScopes();
@ -56,7 +55,7 @@ public class DynamicScopesRARParseTest extends AbstractRARParserTest {
events.expectLogin()
.user(userId)
.assertEvent();
AuthorizationRequestContextHolder contextHolder = fetchAuthorizationRequestContextHolder();
AuthorizationRequestContextHolder contextHolder = fetchAuthorizationRequestContextHolder(userId);
List<AuthorizationRequestContextHolder.AuthorizationRequestHolder> authorizationRequestHolders = contextHolder.getAuthorizationRequestHolders().stream()
.filter(authorizationRequestHolder -> authorizationRequestHolder.getSource().equals(AuthorizationRequestSource.SCOPE))
.collect(Collectors.toList());
@ -73,7 +72,6 @@ public class DynamicScopesRARParseTest extends AbstractRARParserTest {
}
@Test
@Ignore("ignored until we figure out why it fails on Quarkus and Wildfly")
public void generatedAuthorizationRequestsShouldMatchRequestedAndDefaultScopes() {
Response response = createScope("static-scope", false);
String scopeId = ApiUtil.getCreatedId(response);
@ -93,7 +91,7 @@ public class DynamicScopesRARParseTest extends AbstractRARParserTest {
.user(userId)
.assertEvent();
AuthorizationRequestContextHolder contextHolder = fetchAuthorizationRequestContextHolder();
AuthorizationRequestContextHolder contextHolder = fetchAuthorizationRequestContextHolder(userId);
List<AuthorizationRequestContextHolder.AuthorizationRequestHolder> authorizationRequestHolders = contextHolder.getAuthorizationRequestHolders().stream()
.filter(authorizationRequestHolder -> authorizationRequestHolder.getSource().equals(AuthorizationRequestSource.SCOPE))
.collect(Collectors.toList());
@ -112,7 +110,6 @@ public class DynamicScopesRARParseTest extends AbstractRARParserTest {
}
@Test
@Ignore("ignored until we figure out why it fails on Quarkus and Wildfly")
public void generatedAuthorizationRequestsShouldMatchRequestedDynamicAndDefaultScopes() {
Response response = createScope("dynamic-scope", true);
String scopeId = ApiUtil.getCreatedId(response);
@ -132,7 +129,7 @@ public class DynamicScopesRARParseTest extends AbstractRARParserTest {
.user(userId)
.assertEvent();
AuthorizationRequestContextHolder contextHolder = fetchAuthorizationRequestContextHolder();
AuthorizationRequestContextHolder contextHolder = fetchAuthorizationRequestContextHolder(userId);
List<AuthorizationRequestContextHolder.AuthorizationRequestHolder> authorizationRequestHolders = contextHolder.getAuthorizationRequestHolders().stream()
.filter(authorizationRequestHolder -> authorizationRequestHolder.getSource().equals(AuthorizationRequestSource.SCOPE))
.collect(Collectors.toList());