use of org.apache.knox.gateway.identityasserter.common.function.UsernameFunctionProcessor in project knox by apache.
the class UsernameFunctionProcessorTest method testDestroy.
@Test
public void testDestroy() throws Exception {
UsernameFunctionProcessor processor = new UsernameFunctionProcessor();
// Shouldn't fail.
processor.destroy();
}
use of org.apache.knox.gateway.identityasserter.common.function.UsernameFunctionProcessor in project knox by apache.
the class UsernameFunctionProcessorTest method testResolve.
@Test
public void testResolve() throws Exception {
final UsernameFunctionProcessor processor = new UsernameFunctionProcessor();
assertThat(processor.resolve(null, null), nullValue());
assertThat(processor.resolve(null, Arrays.asList("test-input")), contains("test-input"));
Subject subject = new Subject();
subject.getPrincipals().add(new PrimaryPrincipal("test-username"));
subject.setReadOnly();
Subject.doAs(subject, new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
assertThat(processor.resolve(null, null), contains("test-username"));
assertThat(processor.resolve(null, Arrays.asList("test-ignored")), contains("test-username"));
return null;
}
});
}
use of org.apache.knox.gateway.identityasserter.common.function.UsernameFunctionProcessor in project knox by apache.
the class UsernameFunctionProcessorTest method testInitialize.
@Test
public void testInitialize() throws Exception {
UsernameFunctionProcessor processor = new UsernameFunctionProcessor();
// Shouldn't fail.
processor.initialize(null, null);
}
use of org.apache.knox.gateway.identityasserter.common.function.UsernameFunctionProcessor in project knox by apache.
the class UsernameFunctionProcessorTest method testServiceLoader.
@Test
public void testServiceLoader() throws Exception {
ServiceLoader loader = ServiceLoader.load(UrlRewriteFunctionProcessor.class);
Iterator iterator = loader.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
if (object instanceof UsernameFunctionProcessor) {
return;
}
}
fail("Failed to find UsernameFunctionProcessor via service loader.");
}
Aggregations