final String clientToken = BaseEncoding.base64().encode(
WindowsAccountImpl.getCurrentUsername().getBytes(Charsets.UTF_8));
request.addHeader("Authorization", securityPackage + " " + clientToken);
final SimpleHttpResponse response = new SimpleHttpResponse();
this.filter.doFilter(request, response, filterChain);
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
assertNotNull(auth);
final Collection<? extends GrantedAuthority> authorities = auth.getAuthorities();
assertNotNull(authorities);
assertEquals(3, authorities.size());
final Iterator<? extends GrantedAuthority> authoritiesIterator = authorities.iterator();
final List<String> list = new ArrayList<String>();
while (authoritiesIterator.hasNext()) {
list.add(authoritiesIterator.next().getAuthority());
}
Collections.sort(list);
assertEquals("ROLE_EVERYONE", list.get(0));
assertEquals("ROLE_USER", list.get(1));
assertEquals("ROLE_USERS", list.get(2));
assertEquals(0, response.getHeaderNamesSize());
}