Search in sources :

Example 1 with SecureHasher

use of org.neo4j.server.security.enterprise.auth.SecureHasher in project neo4j by neo4j.

the class PluginAuthenticationInfoTest method shouldCreateCorrectAuthenticationInfoFromCacheable.

@Test
public void shouldCreateCorrectAuthenticationInfoFromCacheable() {
    SecureHasher hasher = mock(SecureHasher.class);
    when(hasher.hash(Matchers.any())).thenReturn(new SimpleHash("some-hash"));
    PluginAuthenticationInfo internalAuthInfo = PluginAuthenticationInfo.createCacheable(CacheableAuthenticationInfo.of("thePrincipal", new byte[] { 1 }), "theRealm", hasher);
    assertThat((List<String>) internalAuthInfo.getPrincipals().asList(), containsInAnyOrder("thePrincipal"));
}
Also used : SecureHasher(org.neo4j.server.security.enterprise.auth.SecureHasher) SimpleHash(org.apache.shiro.crypto.hash.SimpleHash) Test(org.junit.Test)

Example 2 with SecureHasher

use of org.neo4j.server.security.enterprise.auth.SecureHasher in project neo4j by neo4j.

the class PluginAuthenticationInfoTest method shouldCreateCorrectAuthenticationInfoFromCustomCacheable.

@Test
public void shouldCreateCorrectAuthenticationInfoFromCustomCacheable() {
    SecureHasher hasher = mock(SecureHasher.class);
    when(hasher.hash(Matchers.any())).thenReturn(new SimpleHash("some-hash"));
    PluginAuthenticationInfo internalAuthInfo = PluginAuthenticationInfo.createCacheable(CustomCacheableAuthenticationInfo.of("thePrincipal", ignoredAuthToken -> true), "theRealm", hasher);
    assertThat((List<String>) internalAuthInfo.getPrincipals().asList(), containsInAnyOrder("thePrincipal"));
}
Also used : List(java.util.List) CacheableAuthenticationInfo(org.neo4j.server.security.enterprise.auth.plugin.spi.CacheableAuthenticationInfo) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers(org.mockito.Matchers) Test(org.junit.Test) SecureHasher(org.neo4j.server.security.enterprise.auth.SecureHasher) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Mockito.when(org.mockito.Mockito.when) SimpleHash(org.apache.shiro.crypto.hash.SimpleHash) AuthenticationInfo(org.neo4j.server.security.enterprise.auth.plugin.spi.AuthenticationInfo) CustomCacheableAuthenticationInfo(org.neo4j.server.security.enterprise.auth.plugin.spi.CustomCacheableAuthenticationInfo) Mockito.mock(org.mockito.Mockito.mock) SecureHasher(org.neo4j.server.security.enterprise.auth.SecureHasher) SimpleHash(org.apache.shiro.crypto.hash.SimpleHash) Test(org.junit.Test)

Aggregations

SimpleHash (org.apache.shiro.crypto.hash.SimpleHash)2 Test (org.junit.Test)2 SecureHasher (org.neo4j.server.security.enterprise.auth.SecureHasher)2 List (java.util.List)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)1 Matchers (org.mockito.Matchers)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 AuthenticationInfo (org.neo4j.server.security.enterprise.auth.plugin.spi.AuthenticationInfo)1 CacheableAuthenticationInfo (org.neo4j.server.security.enterprise.auth.plugin.spi.CacheableAuthenticationInfo)1 CustomCacheableAuthenticationInfo (org.neo4j.server.security.enterprise.auth.plugin.spi.CustomCacheableAuthenticationInfo)1