Author: rareddy
Date: 2009-08-31 15:41:28 -0400 (Mon, 31 Aug 2009)
New Revision: 1297
Added:
trunk/test-integration/src/test/resources/admin/admin-roles.properties
trunk/test-integration/src/test/resources/admin/dqp-membership.properties
trunk/test-integration/src/test/resources/admin/groups.properties
trunk/test-integration/src/test/resources/admin/membership-file.properties
trunk/test-integration/src/test/resources/admin/users.properties
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
Log:
TEIID-779, TEIID-697
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java
===================================================================
---
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2009-08-31
17:25:36 UTC (rev 1296)
+++
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractMMQueryTestCase.java 2009-08-31
19:41:28 UTC (rev 1297)
@@ -69,7 +69,7 @@
}
public static com.metamatrix.jdbc.api.Connection createConnection(String vdb, String
propsFile, String addtionalStuff) throws SQLException {
- String url = "jdbc:metamatrix:"+vdb+"@" +
propsFile+addtionalStuff; //$NON-NLS-1$ //$NON-NLS-2$
+ String url = "jdbc:teiid:"+vdb+"@" +
propsFile+addtionalStuff; //$NON-NLS-1$ //$NON-NLS-2$
return (com.metamatrix.jdbc.api.Connection)DriverManager.getConnection(url);
}
Modified:
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java
===================================================================
---
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-31
17:25:36 UTC (rev 1296)
+++
trunk/test-integration/src/test/java/com/metamatrix/server/integration/TestAdminApi.java 2009-08-31
19:41:28 UTC (rev 1297)
@@ -32,6 +32,8 @@
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
import java.util.Properties;
import org.junit.Before;
@@ -43,9 +45,11 @@
import org.teiid.adminapi.ConnectorType;
import org.teiid.adminapi.EmbeddedLogger;
import org.teiid.adminapi.ExtensionModule;
+import org.teiid.adminapi.Group;
import org.teiid.adminapi.LogConfiguration;
import org.teiid.adminapi.ProcessObject;
import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Role;
import org.teiid.adminapi.VDB;
import org.teiid.runtime.adminapi.Util;
@@ -59,6 +63,7 @@
private static final String STAR = "*"; //$NON-NLS-1$
private static final String PROPS_FILE =
UnitTestUtil.getTestDataPath()+"/admin/dqp.properties;user=admin;password=teiid";
//$NON-NLS-1$
+ private static final String MEMBERSHIP_PROPS_FILE =
UnitTestUtil.getTestDataPath()+"/admin/dqp-membership.properties";
//$NON-NLS-1$
private static final String BQT = "BQT"; //$NON-NLS-1$
private static final String ADMIN = "admin"; //$NON-NLS-1$
private static final String VDB_NAME = "TestEmpty"; //$NON-NLS-1$
@@ -1040,8 +1045,84 @@
closeConnection();
}
+
+ @Test public void testGetRolesForGroup() throws Exception {
+ getConnection(ADMIN, MEMBERSHIP_PROPS_FILE, ";user=admin;password=teiid");
//$NON-NLS-1$
+ cleanDeploy();
+ Collection<Role> r =
getAdmin().getRolesForGroup("group1@file");//$NON-NLS-1$
+ assertTrue(!r.isEmpty());
+ assertEquals(Role.ADMIN_SYSTEM, r.iterator().next().getIdentifier());
+
+ try {
+ r = getAdmin().getRolesForGroup("unknown");//$NON-NLS-1$
+ fail("must have failed to fetch the group"); //$NON-NLS-1$
+ }catch(Exception e) {
+
+ }
+ assertTrue(!r.isEmpty());
+
+ closeConnection();
+ }
+
+ @Test public void testGetGroupsForUser() throws Exception {
+ getConnection(ADMIN, MEMBERSHIP_PROPS_FILE, ";user=admin;password=teiid");
//$NON-NLS-1$
+ cleanDeploy();
+
+ Collection<Group> g = getAdmin().getGroupsForUser("paul@file");
//$NON-NLS-1$
+ assertEquals(2, g.size());
+ Iterator<Group> i = g.iterator();
+ assertEquals("group4@file", i.next().getIdentifier()); //$NON-NLS-1$
+ assertEquals("group1@file", i.next().getIdentifier()); //$NON-NLS-1$
+
+ // with out the @file
+ g = getAdmin().getGroupsForUser("paul"); //$NON-NLS-1$
+ assertEquals(2, g.size());
+
+ try {
+ g = getAdmin().getGroupsForUser("unknown");//$NON-NLS-1$
+ fail("should failed to resolve the unknown user"); //$NON-NLS-1$
+ }catch(Exception e) {
+ }
+
+ closeConnection();
+ }
+ @Test public void testGetGroups() throws Exception {
+ getConnection(ADMIN, MEMBERSHIP_PROPS_FILE, ";user=admin;password=teiid");
//$NON-NLS-1$
+ cleanDeploy();
+
+ Collection<Group> g = getAdmin().getGroups("*"); //$NON-NLS-1$
+ assertEquals(4, g.size());
+
+ closeConnection();
+ }
+
+ @Test public void testGetDomainNames() throws Exception {
+ getConnection(ADMIN, MEMBERSHIP_PROPS_FILE, ";user=admin;password=teiid");
//$NON-NLS-1$
+ cleanDeploy();
+
+ List<String> g = getAdmin().getDomainNames();
+ assertEquals(1, g.size());
+ assertEquals("file", g.get(0)); //$NON-NLS-1$
+ closeConnection();
+ }
+
+ @Test public void testGetGroupsForDomain() throws Exception {
+ getConnection(ADMIN, MEMBERSHIP_PROPS_FILE, ";user=admin;password=teiid");
//$NON-NLS-1$
+ cleanDeploy();
+
+ Collection<Group> g = getAdmin().getGroupsForDomain("file");
//$NON-NLS-1$
+ assertEquals(4, g.size());
+
+ g = getAdmin().getGroupsForDomain("unknown"); //$NON-NLS-1$
+ assertEquals(0, g.size());
+
+ closeConnection();
+ }
+
+
+
VDB addVDB(String name, String vdbFile) {
try {
return getAdmin().addVDB(name, Util.getBinaryFile(vdbFile), new
AdminOptions(AdminOptions.OnConflict.IGNORE));
Added: trunk/test-integration/src/test/resources/admin/admin-roles.properties
===================================================================
--- trunk/test-integration/src/test/resources/admin/admin-roles.properties
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/admin-roles.properties 2009-08-31
19:41:28 UTC (rev 1297)
@@ -0,0 +1,18 @@
+# This file defines admin role grants for each user "group" in the system.
+# based on the this permission the user will be able to call the admin
+# function calls into the system. The following format needs to be used
+# define the permissions
+
+# role1 = groupA,groupB
+# role2 = groupB,groupC
+
+# for group names check your membership provider configuration.
+
+# This role grants full permissions to any configuration, runtime-management and
monitoring of the system
+Admin.SystemAdmin=group1@file,group4@file
+
+# This role grants runtime-management and monitoring of the system
+Admin.ProductAdmin=group2@file
+
+# This role grants only monitoring of the system.
+Admin.ReadOnlyAdmin=group3@file
Property changes on:
trunk/test-integration/src/test/resources/admin/admin-roles.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/dqp-membership.properties
===================================================================
--- trunk/test-integration/src/test/resources/admin/dqp-membership.properties
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/dqp-membership.properties 2009-08-31
19:41:28 UTC (rev 1297)
@@ -0,0 +1,21 @@
+dqp.configFile=../../../../target/scratch/configuration.xml
+dqp.buffer.usedisk=false
+xa.enable_recovery=false
+dqp.deploydir=../../../../target/scratch
+dqp.workdir=../../../../target/scratch/work
+
+membership.enabled=true
+membership.superUser=admin
+membership.superUserPassword=teiid
+membership.DomainOrder=file
+
+file.activate=true
+file.AuthDomainClass=com.metamatrix.platform.security.membership.spi.file.FileMembershipDomain
+file.propertiesFile=membership-file.properties
+
+auth.check_entitlements=false
+auth.adminRolesFile=./admin-roles.properties
+
+dqp.userDefinedFunctionsFile=extensionjar:FunctionDefinitions.xmi
+processName=localhost
+dqp.extensions=../../../../target/scratch/extensions/;./extensions
\ No newline at end of file
Property changes on:
trunk/test-integration/src/test/resources/admin/dqp-membership.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/groups.properties
===================================================================
--- trunk/test-integration/src/test/resources/admin/groups.properties
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/groups.properties 2009-08-31 19:41:28
UTC (rev 1297)
@@ -0,0 +1,4 @@
+group1=paul
+group2=ramesh
+group3=steve
+group4=bob,paul
Property changes on: trunk/test-integration/src/test/resources/admin/groups.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/membership-file.properties
===================================================================
--- trunk/test-integration/src/test/resources/admin/membership-file.properties
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/membership-file.properties 2009-08-31
19:41:28 UTC (rev 1297)
@@ -0,0 +1,11 @@
+#File based membership domain configuration properties
+
+#Location of the properties file containing user name and password entries.
+usersFile=users.properties
+
+#Location of the properties file containing group assignments
+groupsFile=groups.properties
+
+#Check passwords against the users file.
+checkPassword=true
+
Property changes on:
trunk/test-integration/src/test/resources/admin/membership-file.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/src/test/resources/admin/users.properties
===================================================================
--- trunk/test-integration/src/test/resources/admin/users.properties
(rev 0)
+++ trunk/test-integration/src/test/resources/admin/users.properties 2009-08-31 19:41:28
UTC (rev 1297)
@@ -0,0 +1,5 @@
+john=mm
+paul=mm
+ramesh=mm
+steve=mm
+bob=mm
Property changes on: trunk/test-integration/src/test/resources/admin/users.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain