use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.
the class AuthenticationInfoTest method testAuthenticationInfoStringString.
@Test
public void testAuthenticationInfoStringString() {
final AuthenticationInfo info = new AuthenticationInfo("test", "name");
Assert.assertEquals("test", info.getAuthType());
Assert.assertEquals("name", info.getUser());
assertNull(info.getPassword());
}
use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.
the class AuthenticationInfoTest method testGetUser.
@Test
public void testGetUser() {
final AuthenticationInfo info = new AuthenticationInfo("test");
info.put(ResourceResolverFactory.USER, "name");
Assert.assertEquals("name", info.getUser());
Assert.assertEquals("name", info.get(ResourceResolverFactory.USER));
Assert.assertEquals(info.get(ResourceResolverFactory.USER), info.getUser());
}
use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.
the class AuthenticationInfoTest method testSetAuthType.
@Test
public void testSetAuthType() {
final AuthenticationInfo info = new AuthenticationInfo("test");
Assert.assertEquals("test", info.getAuthType());
info.setAuthType(null);
Assert.assertEquals("test", info.getAuthType());
info.setAuthType("dummy");
Assert.assertEquals("dummy", info.getAuthType());
info.setAuthType("");
Assert.assertEquals("", info.getAuthType());
}
use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.
the class AuthenticationInfoTest method testSetCredentials.
@Test
public void testSetCredentials() {
final Credentials creds = new SimpleCredentials("user", new char[0]);
final AuthenticationInfo info = new AuthenticationInfo("test");
info.put(CREDENTIALS, creds);
Assert.assertSame(creds, info.get(CREDENTIALS));
}
use of org.apache.sling.auth.core.spi.AuthenticationInfo in project sling by apache.
the class AuthenticationInfoTest method testPutStringObject.
@Test
public void testPutStringObject() {
final AuthenticationInfo info = new AuthenticationInfo("test", "user", new char[2]);
info.put(CREDENTIALS, new SimpleCredentials("user", new char[2]));
test_put_fail(info, AuthenticationInfo.AUTH_TYPE, null);
test_put_fail(info, ResourceResolverFactory.USER, null);
test_put_fail(info, ResourceResolverFactory.PASSWORD, null);
test_put_fail(info, AuthenticationInfo.AUTH_TYPE, 42);
test_put_fail(info, ResourceResolverFactory.USER, 42);
test_put_fail(info, ResourceResolverFactory.PASSWORD, "string");
test_put_success(info, AuthenticationInfo.AUTH_TYPE, "new_type");
test_put_success(info, ResourceResolverFactory.USER, "new_user");
test_put_success(info, ResourceResolverFactory.PASSWORD, "new_pwd".toCharArray());
}
Aggregations