Closed KasperVaessen closed 2 years ago
This is quite strange:
AccessTokenBuilderHelper.java:61 provides explicitely Authorization::setPermissions
with a List<Permission>
which is (implements) a Collection<Permission>
Do you have executable code somewhere?
If not, could you clone my repo and update com.c4_soft.springaddons.samples.webmvc.keycloak.KeycloakSpringBootSampleApp
to reproduce? (currently the tests pass...)
By the way, @KasperVaessen , did you carfully inspect your test classpath? Have you double checked the version of the keycloak-core
that is loaded?
Maybe you did not include keycloak dependencies explicitly in your project and it is just missing when your test run: in this repo, Keycloak dependencies are flagged as optional
=> you must reference keycloak libs explicitely if you use it.
Libs in this repo can be used without Keycloak libs (I personally don't use Keycloak libs any more), reason for keycloak being flaged as optional
here.
You could try with somthing like that in your pom:
<properties>
<com.c4-soft.springaddons.version>3.1.7-jdk1.8-SNAPSHOT</com.c4-soft.springaddons.version>
<keycloak.version>15.0.2</keycloak.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>${keycloak.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.c4-soft.springaddons</groupId>
<artifactId>spring-security-oauth2-test-addons</artifactId>
<version>${com.c4-soft.springaddons.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-security-adapter</artifactId>
<optional>false</optional><!-- default value is false, so removing this tag should work as well -->
</dependency>
<dependency>
<groupId>com.c4-soft.springaddons</groupId>
<artifactId>spring-security-oauth2-test-addons</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Thanks for both your replies! It was indeed a problem with my keycloak version. I used a dependencyManager which set the keycloak version to 4.0.0.FINAL. I oversaw this. Sorry for the trouble an thank you so much for your help!
Describe the bug When I use the @WithMockKeycloakAuth tag above my test, I get the following error:
It seems that the .setPermissions method expects a list instead of a collection.
Code sample I use Keycloak 15
Test:
SecurityConfig:
Expected behavior I would expect no error. Do I need a specific version of something?