Skip to content

Commit 2b87e3c

Browse files
committed
Use withRoles
Issue gh-17843
1 parent ed344ec commit 2b87e3c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

config/src/integration-test/java/org/springframework/security/config/ldap/LdapBindAuthenticationManagerFactoryITests.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.security.config.ldap;
1818

1919
import java.util.Collection;
20-
import java.util.Collections;
2120
import java.util.HashSet;
2221
import java.util.Set;
2322

@@ -38,7 +37,6 @@
3837
import org.springframework.security.config.test.SpringTestContextExtension;
3938
import org.springframework.security.core.GrantedAuthority;
4039
import org.springframework.security.core.authority.AuthorityUtils;
41-
import org.springframework.security.core.authority.SimpleGrantedAuthority;
4240
import org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper;
4341
import org.springframework.security.core.userdetails.User;
4442
import org.springframework.security.core.userdetails.UserDetails;
@@ -82,8 +80,7 @@ protected Set<GrantedAuthority> getAdditionalRoles(DirContextOperations user, St
8280
this.spring.register(CustomAuthoritiesPopulatorConfig.class).autowire();
8381

8482
this.mockMvc.perform(formLogin().user("bob").password("bobspassword"))
85-
.andExpect(
86-
authenticated().withAuthorities(Collections.singleton(new SimpleGrantedAuthority("ROLE_EXTRA"))));
83+
.andExpect(authenticated().withRoles("EXTRA"));
8784
}
8885

8986
@Test
@@ -94,8 +91,7 @@ public void authenticationManagerFactoryWhenCustomAuthoritiesMapperThenUsed() th
9491
this.spring.register(CustomAuthoritiesMapperConfig.class).autowire();
9592

9693
this.mockMvc.perform(formLogin().user("bob").password("bobspassword"))
97-
.andExpect(
98-
authenticated().withAuthorities(Collections.singleton(new SimpleGrantedAuthority("ROLE_CUSTOM"))));
94+
.andExpect(authenticated().withRoles("CUSTOM"));
9995
}
10096

10197
@Test

0 commit comments

Comments
 (0)