Package org.voltdb.compiler.VoltProjectBuilder

Examples of org.voltdb.compiler.VoltProjectBuilder.UserInfo


        GroupInfo gi = new GroupInfo("foo", true, false, true, true, false, false);
        builder.addGroups(new GroupInfo[] { 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);

        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);
        Response r = responseFromJSON(response);
        assertEquals(ClientResponse.UNEXPECTED_FAILURE, r.status);
        response = callProcOverJSON("Insert", pset, u.name, "ick", false);
        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<String,String>();
        params.put("Procedure", "Insert");
        params.put("Parameters", paramsInJSON);
        params.put("User", u.name);
        params.put("Password", Encoder.hexEncode(new byte[] {1,2,3}));
        String varString = getHTTPVarString(params);
        response = callProcOverJSONRaw(varString, 200);
        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<String,String>();
        params.put("Procedure", "Insert");
        params.put("Parameters", paramsInJSON);
        params.put("User", u.name);
        params.put("Password", "abcdefghiabcdefghiabcdefghiabcdefghi");
        varString = getHTTPVarString(params);
        response = callProcOverJSONRaw(varString, 200);
        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.addGroups(new GroupInfo[] { 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);

View Full Code Here


        GroupInfo groups[] = new GroupInfo[] {
                new GroupInfo("foo", false, false, false, false, false, false),
                new GroupInfo("blah", false, false, false, false, false, false)
        };
        project.addGroups(groups);
        UserInfo users[] = new UserInfo[] {
                new UserInfo("john", "hugg", new String[] {"foo"}),
                new UserInfo("ryan", "betts", new String[] {"foo", "bar"}),
                new UserInfo("ariel", "weisberg", new String[] {"bar"})
        };
        project.addUsers(users);

        String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
        String jarName = "compile-deployment.jar";
View Full Code Here

            this.builder.addGroups(GroupInfo.fromTemplate(template, roles));
        }

        void createUser(String user, String password, String... roles)
        {
            this.builder.addUsers(new UserInfo[] {new UserInfo(user, password, roles)});
        }
View Full Code Here

        procedures.add(new ProcedureInfo(new String[0], PROCEDURES[0]));
        procedures.add(new ProcedureInfo(new String[] {"group1"}, PROCEDURES[1]));
        procedures.add(new ProcedureInfo(new String[] {"group1", "group2"}, PROCEDURES[2]));
        project.addProcedures(procedures);

        UserInfo users[] = new UserInfo[] {
                new UserInfo("user1", "password", new String[] {"grouP1"}),
                new UserInfo("user2", "password", new String[] {"grouP2"}),
                new UserInfo("user3", "password", new String[] {"grouP3"}),
                new UserInfo("user4", "password", new String[] {"AdMINISTRATOR"}),
                new UserInfo("userWithDefaultUserPerm", "password", new String[] {"User"}),
                new UserInfo("userWithAllProc", "password", new String[] {"GroupWithAllProcPerm"}),
                new UserInfo("userWithDefaultProcPerm", "password", new String[] {"groupWithDefaultProcPerm"}),
                new UserInfo("userWithoutDefaultProcPerm", "password", new String[] {"groupWiThoutDefaultProcPerm"}),
                new UserInfo("userWithDefaultProcReadPerm", "password", new String[] {"groupWiThDefaultProcReadPerm"})
        };
        project.addUsers(users);

        GroupInfo groups[] = new GroupInfo[] {
                new GroupInfo("Group1", false, false, false, false, false, false),
View Full Code Here

        builder.setUseDDLSchema(true);
        GroupInfo groups[] = new GroupInfo[] {
            new GroupInfo("adhoc", true, false, false, false, false, false),
            new GroupInfo("sysproc", false, false, true, false, false, false)
        };
        UserInfo users[] = new UserInfo[] {
            new UserInfo("adhocuser", "adhocuser", new String[] {"adhoc"}),
            new UserInfo("sysuser", "sysuser", new String[] {"sysproc"})
        };
        builder.addGroups(groups);
        builder.addUsers(users);
        builder.setSecurityEnabled(true);
        boolean success = builder.compile(pathToCatalog, 2, 1, 0);
View Full Code Here

        Catalog catOriginal = catalogForJar(original);

        GroupInfo gi[] = new GroupInfo[1];
        gi[0] = new GroupInfo("group1", true, true, true, true, true, false);

        UserInfo ui[] = new UserInfo[1];
        ui[0] = new UserInfo("user1", "password", new String[] {"group1"});

        String updated = compileWithGroups(false, null, gi, ui, "base", BASEPROCS);
        Catalog catUpdated = catalogForJar(updated);

        verifyDiff(catOriginal, catUpdated);
View Full Code Here

    public void testModifyUser() throws IOException {
        GroupInfo gi[] = new GroupInfo[1];
        gi[0] = new GroupInfo("group1", true, true, true, true, false, false);

        UserInfo ui[] = new UserInfo[1];
        ui[0] = new UserInfo("user1", "password", new String[] {"group1"});

        String original = compileWithGroups(false, null, gi, ui, "base", BASEPROCS);
        Catalog catOriginal = catalogForJar(original);

        GroupInfo gi2[] = new GroupInfo[1];
        gi2[0] = new GroupInfo("group2", true, true, true, true, true, true);
        // change a user.
        ui[0] = new UserInfo("user1", "drowssap", new String[] {"group2"});
        String updated = compileWithGroups(false, null, gi2, ui, "base", BASEPROCS);
        Catalog catUpdated = catalogForJar(updated);

        verifyDiff(catOriginal, catUpdated);
    }
View Full Code Here

    public void testDeleteUser() throws IOException {
        GroupInfo gi[] = new GroupInfo[1];
        gi[0] = new GroupInfo("group1", true, true, true, true, false, false);

        UserInfo ui[] = new UserInfo[1];
        ui[0] = new UserInfo("user1", "password", new String[] {"group1"});

        String original = compileWithGroups(false, null, gi, ui, "base", BASEPROCS);
        Catalog catOriginal = catalogForJar(original);

        // no users this time
View Full Code Here

    public void testDeleteGroupAndUser() throws IOException {
        GroupInfo gi[] = new GroupInfo[1];
        gi[0] = new GroupInfo("group1", true, true, true, true, false, false);

        UserInfo ui[] = new UserInfo[1];
        ui[0] = new UserInfo("user1", "password", new String[] {"group1"});

        String original = compileWithGroups(false, null, gi, ui, "base", BASEPROCS);
        Catalog catOriginal = catalogForJar(original);

        // no groups or users this time
View Full Code Here

    public void testChangeUsersAssignedGroups() throws IOException {
        GroupInfo gi[] = new GroupInfo[2];
        gi[0] = new GroupInfo("group1", true, true, true, true, false, false);
        gi[1] = new GroupInfo("group2", true, true, true, true, false, true);

        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);

        // swap the user's group assignments
        ui[0] = new UserInfo("user1", "password", new String[] {"group2"});
        ui[1] = new UserInfo("user2", "password", new String[] {"group1"});
        String updated = compileWithGroups(false, null, gi, ui, "base", BASEPROCS);
        Catalog catUpdated = catalogForJar(updated);

        verifyDiff(catOriginal, catUpdated);
    }
View Full Code Here

TOP

Related Classes of org.voltdb.compiler.VoltProjectBuilder.UserInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.