use of org.teiid.deployers.VDBRepository in project teiid by teiid.
the class TestSessionServiceImpl method testActiveVDBWithVersion.
@Test
public void testActiveVDBWithVersion() 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.getActiveVDB("name", "1");
Mockito.verify(repo, Mockito.times(1)).getLiveVDB("name", "1");
}
use of org.teiid.deployers.VDBRepository in project teiid by teiid.
the class TestSessionServiceImpl method testSecurityDomain.
@Test
public void testSecurityDomain() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
VDBMetaData vdb = new VDBMetaData();
vdb.setName("name");
vdb.setVersion(1);
vdb.setStatus(Status.ACTIVE);
vdb.addProperty(SessionServiceImpl.SECURITY_DOMAIN_PROPERTY, "domain");
Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
ssi.setVDBRepository(repo);
Properties properties = new Properties();
properties.setProperty(TeiidURL.JDBC.VDB_NAME, "name.1");
SessionMetadata s = ssi.createSession("name", "1", AuthenticationType.USERPASSWORD, "x", new Credentials(new char[] { 'y' }), "z", properties);
assertEquals("domain", s.getSecurityDomain());
}
use of org.teiid.deployers.VDBRepository 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());
}
use of org.teiid.deployers.VDBRepository in project teiid by teiid.
the class TestLogonImpl method testLogonAuthenticationType.
@Test
public void testLogonAuthenticationType() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
VDBMetaData vdb = new VDBMetaData();
vdb.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
vdb.setName("name");
vdb.setVersion(1);
vdb.setStatus(Status.ACTIVE);
Mockito.stub(repo.getLiveVDB("name", "1")).toReturn(vdb);
ssi.setVDBRepository(repo);
ssi.setSecurityDomain("SC");
// default transport - what Teiid has before TEIID-2863
// this is transport default
ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
DQPWorkContext.setWorkContext(new DQPWorkContext());
Properties p = buildProperties("fred", "name");
// $NON-NLS-1$
LogonImpl impl = new LogonImpl(ssi, "fakeCluster");
LogonResult result = impl.logon(p);
assertEquals("fred", result.getUserName());
// if no preference then choose USERPASSWORD
// this is transport default
ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
DQPWorkContext.setWorkContext(new DQPWorkContext());
p = buildProperties("fred", "name");
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
result = impl.logon(p);
assertEquals("fred", result.getUserName());
// if user name is set to "GSS", then the preference is set to "GSS"
// this is transport default
ssi.setAuthenticationType(AuthenticationType.USERPASSWORD);
DQPWorkContext.setWorkContext(new DQPWorkContext());
p = buildProperties("GSS", "name");
// $NON-NLS-1$
FakeGssLogonImpl fimpl = new FakeGssLogonImpl(ssi, "fakeCluster");
fimpl.addToken("bytes".getBytes(), new Subject());
p.put(ILogon.KRB5TOKEN, "bytes".getBytes());
result = fimpl.logon(p);
assertEquals("GSS", result.getUserName());
// if the transport default defined as GSS, then preference is USERPASSWORD, additional challenge
ssi.setAuthenticationType(AuthenticationType.GSS);
DQPWorkContext.setWorkContext(new DQPWorkContext());
p = buildProperties("fred", "name");
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
result = impl.logon(p);
assertEquals(AuthenticationType.GSS, result.getProperty("authType"));
}
use of org.teiid.deployers.VDBRepository in project teiid by teiid.
the class TestLogonImpl method testLogonAuthenticationTypeByVDB.
@Test
public void testLogonAuthenticationTypeByVDB() throws Exception {
VDBRepository repo = Mockito.mock(VDBRepository.class);
ssi.setVDBRepository(repo);
// when VDB value is is avavailble this will not be used
ssi.setAuthenticationType(AuthenticationType.GSS);
// default transport - what Teiid has before TEIID-2863
addVdb(repo, "name", "SC", AuthenticationType.USERPASSWORD.name());
DQPWorkContext.setWorkContext(new DQPWorkContext());
Properties p = buildProperties("fred", "name");
// $NON-NLS-1$
LogonImpl impl = new LogonImpl(ssi, "fakeCluster");
LogonResult result = impl.logon(p);
assertEquals("fred", result.getUserName());
// if no preference then choose USERPASSWORD
VDBMetaData metadata = addVdb(repo, "name1", "SC", AuthenticationType.USERPASSWORD.name());
metadata.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
DQPWorkContext.setWorkContext(new DQPWorkContext());
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
p = buildProperties("fred", "name1");
result = impl.logon(p);
assertEquals("fred", result.getUserName());
p = buildProperties("GSS", "name1");
// $NON-NLS-1$
FakeGssLogonImpl fimpl = new FakeGssLogonImpl(ssi, "fakeCluster");
fimpl.addToken("bytes".getBytes(), new Subject());
p.put(ILogon.KRB5TOKEN, "bytes".getBytes());
result = fimpl.logon(p);
assertEquals("GSS", result.getUserName());
// here preference is GSS
try {
p = buildProperties("GSS", "name");
result = impl.logon(p);
assertEquals("GSS", result.getUserName());
} catch (LogonException e) {
}
// if the transport default defined as GSS, then preference is USERPASSWORD, additional challenge
addVdb(repo, "name2", "SC", "GSS");
DQPWorkContext.setWorkContext(new DQPWorkContext());
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
p = buildProperties("fred", "name2");
result = impl.logon(p);
assertEquals(AuthenticationType.GSS, result.getProperty("authType"));
// doesn't match gss pattern
metadata.addProperty(SessionServiceImpl.GSS_PATTERN_PROPERTY, "GSS");
DQPWorkContext.setWorkContext(new DQPWorkContext());
// $NON-NLS-1$
impl = new LogonImpl(ssi, "fakeCluster");
p = buildProperties(null, "name1");
result = impl.logon(p);
assertEquals("anonymous", result.getUserName());
}
Aggregations