Search in sources :

Example 11 with RoleInfo

use of org.voltdb.compiler.VoltProjectBuilder.RoleInfo in project voltdb by VoltDB.

the class TestCatalogDiffs method testChangeSecurityEnabled.

public void testChangeSecurityEnabled() throws IOException {
    RoleInfo[] gi = new RoleInfo[2];
    gi[0] = new RoleInfo("group1", true, true, true, true, false, true);
    gi[1] = new RoleInfo("group2", true, true, true, true, false, false);
    UserInfo[] ui = new UserInfo[2];
    ui[0] = new UserInfo("user1", "password", new String[] { "group1" });
    ui[1] = new UserInfo("user2", "password", new String[] { "group2" });
    String original = compileWithGroups(false, null, gi, ui, "base", BASEPROCS);
    Catalog catOriginal = catalogForJar(original);
    // just turn on security
    String updated = compileWithGroups(true, "hash", gi, ui, "base", BASEPROCS);
    Catalog catUpdated = catalogForJar(updated);
    verifyDiff(catOriginal, catUpdated, false);
}
Also used : RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo) UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo)

Example 12 with RoleInfo

use of org.voltdb.compiler.VoltProjectBuilder.RoleInfo in project voltdb by VoltDB.

the class TestCatalogDiffs method testAddGroup.

public void testAddGroup() throws IOException {
    String original = compile("base", BASEPROCS);
    Catalog catOriginal = catalogForJar(original);
    RoleInfo[] gi = new RoleInfo[1];
    gi[0] = new RoleInfo("group1", true, true, true, true, true, true);
    String updated = compileWithGroups(false, null, gi, null, "base", BASEPROCS);
    Catalog catUpdated = catalogForJar(updated);
    verifyDiff(catOriginal, catUpdated, false);
}
Also used : RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo)

Example 13 with RoleInfo

use of org.voltdb.compiler.VoltProjectBuilder.RoleInfo in project voltdb by VoltDB.

the class TestJSONInterface method testJSONAuth.

public void testJSONAuth() throws Exception {
    try {
        String simpleSchema = "CREATE TABLE HELLOWORLD (\n" + "    HELLO VARCHAR(15),\n" + "    WORLD VARCHAR(20),\n" + "    DIALECT VARCHAR(15) NOT NULL,\n" + "    PRIMARY KEY (DIALECT)\n" + ");";
        File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
        String schemaPath = schemaFile.getPath();
        schemaPath = URLEncoder.encode(schemaPath, "UTF-8");
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addSchema(schemaPath);
        builder.addPartitionInfo("HELLOWORLD", "DIALECT");
        RoleInfo gi = new RoleInfo("foo", true, false, true, true, false, false);
        builder.addRoles(new RoleInfo[] { gi });
        // create 20 users, only the first one has an interesting user/pass
        UserInfo[] ui = new UserInfo[15];
        ui[0] = new UserInfo("ry@nlikesthe", "y@nkees", new String[] { "foo" });
        for (int i = 1; i < ui.length; i++) {
            ui[i] = new UserInfo("USER" + String.valueOf(i), "PASS" + String.valueOf(i), new String[] { "foo" });
        }
        builder.addUsers(ui);
        builder.setSecurityEnabled(true, true);
        ProcedureInfo[] pi = new ProcedureInfo[2];
        pi[0] = new ProcedureInfo(new String[] { "foo" }, "Insert", "insert into HELLOWORLD values (?,?,?);", null);
        pi[1] = new ProcedureInfo(new String[] { "foo" }, "Select", "select * from HELLOWORLD;", null);
        builder.addProcedures(pi);
        builder.setHTTPDPort(8095);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("json.jar"));
        assertTrue(success);
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = config.setPathToCatalogForTest("json.jar");
        config.m_pathToDeployment = builder.getPathToDeployment();
        server = new ServerThread(config);
        server.start();
        server.waitForInitialization();
        ParameterSet pset;
        // test good auths
        for (UserInfo u : ui) {
            pset = ParameterSet.fromArrayNoCopy(u.name, u.password, u.name);
            String response = callProcOverJSON("Insert", pset, u.name, u.password, true);
            Response r = responseFromJSON(response);
            assertEquals(ClientResponse.SUCCESS, r.status);
        }
        // test re-using auths
        for (UserInfo u : ui) {
            pset = ParameterSet.fromArrayNoCopy(u.name + "-X", u.password + "-X", u.name + "-X");
            String response = callProcOverJSON("Insert", pset, u.name, u.password, false);
            Response r = responseFromJSON(response);
            assertEquals(ClientResponse.SUCCESS, r.status);
        }
        // test bad auth
        UserInfo u = ui[0];
        pset = ParameterSet.fromArrayNoCopy(u.name + "-X1", u.password + "-X1", u.name + "-X1");
        String response = callProcOverJSON("Insert", pset, u.name, "ick", true, false, 401, ClientAuthScheme.HASH_SHA256);
        Response r = responseFromJSON(response);
        assertEquals(ClientResponse.UNEXPECTED_FAILURE, r.status);
        response = callProcOverJSON("Insert", pset, u.name, "ick", false, false, 401, ClientAuthScheme.HASH_SHA256);
        r = responseFromJSON(response);
        assertEquals(ClientResponse.UNEXPECTED_FAILURE, r.status);
        // test malformed auth (too short hash)
        pset = ParameterSet.fromArrayNoCopy(u.name + "-X2", u.password + "-X2", u.name + "-X2");
        String paramsInJSON = pset.toJSONString();
        HashMap<String, String> params = new HashMap<>();
        params.put("Procedure", "Insert");
        params.put("Parameters", paramsInJSON);
        params.put("User", u.name);
        params.put("Password", Encoder.hexEncode(new byte[] { 1, 2, 3 }));
        response = callProcOverJSONRaw(params, 401);
        r = responseFromJSON(response);
        assertEquals(ClientResponse.UNEXPECTED_FAILURE, r.status);
        // test malformed auth (gibberish password, but good length)
        pset = ParameterSet.fromArrayNoCopy(u.name + "-X3", u.password + "-X3", u.name + "-X3");
        paramsInJSON = pset.toJSONString();
        params = new HashMap<>();
        params.put("Procedure", "Insert");
        params.put("Parameters", paramsInJSON);
        params.put("User", u.name);
        params.put("Password", "abcdefghiabcdefghiabcdefghiabcdefghi");
        response = callProcOverJSONRaw(params, 401);
        r = responseFromJSON(response);
        assertEquals(ClientResponse.UNEXPECTED_FAILURE, r.status);
        // the update catalog test below is for enterprise only
        if (VoltDB.instance().getConfig().m_isEnterprise == false) {
            return;
        }
        // ENG-963 below here
        // do enough to get a new deployment file
        VoltProjectBuilder builder2 = new VoltProjectBuilder();
        builder2.addSchema(schemaPath);
        builder2.addPartitionInfo("HELLOWORLD", "DIALECT");
        // Same groups
        builder2.addRoles(new RoleInfo[] { gi });
        // create same 15 users, hack the last 14 passwords
        ui = new UserInfo[15];
        ui[0] = new UserInfo("ry@nlikesthe", "y@nkees", new String[] { "foo" });
        for (int i = 1; i < ui.length; i++) {
            ui[i] = new UserInfo("USER" + String.valueOf(i), "welcomehackers" + String.valueOf(i), new String[] { "foo" });
        }
        builder2.addUsers(ui);
        builder2.setSecurityEnabled(true, true);
        builder2.addProcedures(pi);
        builder2.setHTTPDPort(8095);
        success = builder2.compile(Configuration.getPathToCatalogForTest("json-update.jar"));
        assertTrue(success);
        pset = ParameterSet.fromArrayNoCopy(Encoder.hexEncode(MiscUtils.fileToBytes(new File(config.m_pathToCatalog))), new String(MiscUtils.fileToBytes(new File(builder2.getPathToDeployment())), "UTF-8"));
        response = callProcOverJSON("@UpdateApplicationCatalog", pset, ui[0].name, ui[0].password, true);
        r = responseFromJSON(response);
        assertEquals(ClientResponse.SUCCESS, r.status);
        // retest the good auths above
        for (UserInfo user : ui) {
            ParameterSet ps = ParameterSet.fromArrayNoCopy(user.name + "-X3", user.password + "-X3", user.name + "-X3");
            String respstr = callProcOverJSON("Insert", ps, user.name, user.password, false);
            Response resp = responseFromJSON(respstr);
            assertEquals(ClientResponse.SUCCESS, resp.status);
        }
        VoltProjectBuilder builder3 = new VoltProjectBuilder();
        builder3.addSchema(schemaPath);
        builder3.addPartitionInfo("HELLOWORLD", "DIALECT");
        // Same groups
        builder3.addRoles(new RoleInfo[] { gi });
        ui = new UserInfo[1];
        ui[0] = new UserInfo("ry@nlikesthe", "D033E22AE348AEB5660FC2140AEC35850C4DA9978C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918", new String[] { "foo" }, false);
        builder3.addUsers(ui);
        builder3.setSecurityEnabled(true, true);
        builder3.addProcedures(pi);
        builder3.setHTTPDPort(8095);
        success = builder3.compile(Configuration.getPathToCatalogForTest("json-update.jar"));
        assertTrue(success);
        pset = ParameterSet.fromArrayNoCopy(Encoder.hexEncode(MiscUtils.fileToBytes(new File(config.m_pathToCatalog))), new String(MiscUtils.fileToBytes(new File(builder3.getPathToDeployment())), "UTF-8"));
        response = callProcOverJSON("@UpdateApplicationCatalog", pset, "ry@nlikesthe", "y@nkees", true);
        r = responseFromJSON(response);
        assertEquals(ClientResponse.SUCCESS, r.status);
        // retest the good auths above
        ParameterSet ps = ParameterSet.fromArrayNoCopy(ui[0].name + "-X4", "admin-X4", ui[0].name + "-X4");
        String respstr = callProcOverJSON("Insert", ps, ui[0].name, "admin", false);
        Response resp = responseFromJSON(respstr);
        assertEquals(ClientResponse.SUCCESS, resp.status);
    } finally {
        if (server != null) {
            server.shutdown();
            server.join();
        }
        server = null;
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) HashMap(java.util.HashMap) ProcedureInfo(org.voltdb.compiler.VoltProjectBuilder.ProcedureInfo) UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo) ClientResponse(org.voltdb.client.ClientResponse) HttpResponse(org.apache.http.HttpResponse) RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) File(java.io.File)

Example 14 with RoleInfo

use of org.voltdb.compiler.VoltProjectBuilder.RoleInfo in project voltdb by VoltDB.

the class TestJSONInterface method runConnectionsWithUpdateCatalog.

public void runConnectionsWithUpdateCatalog(boolean securityOn) throws Exception {
    try {
        String simpleSchema = "CREATE TABLE test1 (\n" + "    fld1 BIGINT NOT NULL,\n" + "    PRIMARY KEY (fld1)\n" + ");";
        File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
        String schemaPath = schemaFile.getPath();
        schemaPath = URLEncoder.encode(schemaPath, "UTF-8");
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addSchema(schemaPath);
        builder.addPartitionInfo("test1", "fld1");
        builder.addProcedures(WorkerProc.class);
        UserInfo[] ui = new UserInfo[5];
        if (securityOn) {
            RoleInfo ri = new RoleInfo("role1", true, false, true, true, false, false);
            builder.addRoles(new RoleInfo[] { ri });
            for (int i = 0; i < ui.length; i++) {
                ui[i] = new UserInfo("user" + String.valueOf(i), "password" + String.valueOf(i), new String[] { "role1" });
            }
            builder.addUsers(ui);
            builder.setSecurityEnabled(true, true);
        }
        builder.setHTTPDPort(8095);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("json.jar"));
        assertTrue(success);
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = config.setPathToCatalogForTest("json.jar");
        config.m_pathToDeployment = builder.getPathToDeployment();
        server = new ServerThread(config);
        server.start();
        server.waitForInitialization();
        TestWorker.s_insertCount = new AtomicLong(0);
        int poolSize = 25;
        ExecutorService executor = Executors.newFixedThreadPool(poolSize);
        int workCount = 200;
        for (int i = 0; i < workCount; i++) {
            executor.execute(new TestWorker(i, workCount / 10, (securityOn ? ui[workCount % ui.length].name : null), (securityOn ? ui[workCount % ui.length].password : null)));
        }
        // wait for everything to be done and check status
        executor.shutdown();
        if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {
            fail("Workers should have finished execution by now");
        }
        assertTrue(TestWorker.s_success);
    } finally {
        if (server != null) {
            server.shutdown();
            server.join();
        }
        server = null;
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo) AtomicLong(java.util.concurrent.atomic.AtomicLong) RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Configuration(org.voltdb.VoltDB.Configuration) ExecutorService(java.util.concurrent.ExecutorService) File(java.io.File)

Example 15 with RoleInfo

use of org.voltdb.compiler.VoltProjectBuilder.RoleInfo in project voltdb by VoltDB.

the class TestQueryTimeout method suite.

public static junit.framework.Test suite() {
    VoltServerConfig config = null;
    MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestQueryTimeout.class);
    VoltProjectBuilder project = new VoltProjectBuilder();
    final String literalSchema = "CREATE TABLE R1 ( " + "phone_number INTEGER NOT NULL, " + "state VARCHAR(2) NOT NULL, " + "contestant_number INTEGER NOT NULL);" + "CREATE TABLE P1 ( " + "phone_number INTEGER NOT NULL, " + "state VARCHAR(2) NOT NULL, " + "contestant_number INTEGER NOT NULL);" + "PARTITION TABLE P1 ON COLUMN phone_number;" + "";
    try {
        project.addLiteralSchema(literalSchema);
    } catch (IOException e) {
        fail();
    }
    project.addProcedures(PROCEDURES);
    project.setQueryTimeout(TIMEOUT);
    UserInfo[] users = new UserInfo[] { new UserInfo("adminUser", "password", new String[] { "AdMINISTRATOR" }), new UserInfo("userWithAllProc", "password", new String[] { "GroupWithAllProcPerm" }) };
    project.addUsers(users);
    RoleInfo[] groups = new RoleInfo[] { new RoleInfo("GroupWithAllProcPerm", true, true, false, true, true, true) };
    project.addRoles(groups);
    // suite defines its own ADMINISTRATOR user
    project.setSecurityEnabled(true, false);
    boolean success;
    config = new LocalCluster("querytimeout-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    /* disabled until we work the kinks out of ipc support for fragment progress updates
        config = new LocalCluster("querytimeout-onesite.jar", 1, 1, 0, BackendTarget.NATIVE_EE_IPC);
        success = config.compile(project);
        assertTrue(success);
        builder.addServerConfig(config);
*/
    // Cluster
    config = new LocalCluster("querytimeout-cluster.jar", 2, 3, 1, BackendTarget.NATIVE_EE_JNI);
    success = config.compile(project);
    assertTrue(success);
    builder.addServerConfig(config);
    return builder;
}
Also used : RoleInfo(org.voltdb.compiler.VoltProjectBuilder.RoleInfo) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) UserInfo(org.voltdb.compiler.VoltProjectBuilder.UserInfo) IOException(java.io.IOException)

Aggregations

RoleInfo (org.voltdb.compiler.VoltProjectBuilder.RoleInfo)15 UserInfo (org.voltdb.compiler.VoltProjectBuilder.UserInfo)14 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)4 File (java.io.File)3 IOException (java.io.IOException)3 Configuration (org.voltdb.VoltDB.Configuration)3 TPCCProjectBuilder (org.voltdb.benchmark.tpcc.TPCCProjectBuilder)3 ProcedureInfo (org.voltdb.compiler.VoltProjectBuilder.ProcedureInfo)3 Test (org.junit.Test)2 ClientResponse (org.voltdb.client.ClientResponse)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 HttpResponse (org.apache.http.HttpResponse)1 VoltDB (org.voltdb.VoltDB)1 VoltTable (org.voltdb.VoltTable)1 Catalog (org.voltdb.catalog.Catalog)1 Client (org.voltdb.client.Client)1 ClientConfig (org.voltdb.client.ClientConfig)1