/**
* Grant authority to a test user, with admin privileges, and put the token in the context. This means your tests
* will be authorized to do anything an administrator would be able to do.
*/
protected void grantAdminAuthority( ApplicationContext ctx ) {
ProviderManager providerManager = ( ProviderManager ) ctx.getBean( "authenticationManager" );
providerManager.getProviders().add( new TestingAuthenticationProvider() );
// Grant all roles to test user.
TestingAuthenticationToken token = new TestingAuthenticationToken( "administrator", "administrator",
Arrays.asList( new GrantedAuthority[] { new SimpleGrantedAuthority(
AuthorityConstants.ADMIN_GROUP_AUTHORITY ) } ) );
token.setAuthenticated( true );
putTokenInContext( token );
}
BaseSpringContextTest.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:modinvreg
作者:
评论列表
文章目录