use of org.teiid.security.Credentials in project teiid by teiid.
the class TestSessionServiceImpl method testLegacySecurityDomain.
@Test
public void testLegacySecurityDomain() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
VDBMetaData vdb = new VDBMetaData();
vdb.setName("name");
vdb.setVersion(1);
vdb.setStatus(Status.ACTIVE);
Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
ssi.setVDBRepository(repo);
ssi.setSecurityDomain("sd");
Properties properties = new Properties();
properties.setProperty(TeiidURL.JDBC.VDB_NAME, "name.1");
SessionMetadata s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
ssi.setAllowSecurityDomainQualifier(true);
ssi.setSecurityDomain("sd");
s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
assertEquals("x", s.getUserName());
ssi.setAllowSecurityDomainQualifier(false);
s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x@sd", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("sd", s.getSecurityDomain());
assertEquals("x@sd", s.getUserName());
}
Aggregations