Examples of AgentRegistrationRequest


Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

                            String installId = System.getProperty(AgentRegistrationRequest.SYSPROP_INSTALL_ID);
                            String installLocation = getAgentHomeDirectory();
                            if (installLocation != null && installLocation.trim().length() == 0) {
                                installLocation = null; // tells the server we don't know it
                            }
                            AgentRegistrationRequest request = new AgentRegistrationRequest(agent_name, address, port,
                                remote_endpoint, regenerate_token, token, agentVersion, installId, installLocation);

                            Thread.sleep(retry_interval);

                            if (sender.isSending()) {
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

        // this tests the case where someone purged an agent from the DB, but then
        // changed their mind and want to re-run that agent and re-register it again.
        // In this case, the agent (if not using --cleanallconfig) would still have the old token.
        // The agent should still be allowed to register again.
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request = createRequest(prefixName("old"), "hostOld", 12345, "oldtoken");
        AgentRegistrationResults results = service.registerAgent(request);
        assert results != null : "cannot re-register an old agent";
        Agent agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(request.getName());
        assert agent.getAddress().equals(request.getAddress());
        assert agent.getPort() == request.getPort();
        LookupUtil.getAgentManager().deleteAgent(agent);
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test
    public void testChangeAddressPort() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;
        AgentRegistrationResults results;

        String tuid = "" + new Random().nextInt();
        //let's make this unique per run to support repeated individual runs.
        String zName = prefixName("Z" + "-" + tuid);

        // create a new agent Z with host/port of hostZ/55550
        request = createRequest(zName, "hostZ", 55550, null);
        results = service.registerAgent(request);
        assert results != null : "got null results";

        // now change Z's host to hostZprime
        request = createRequest(zName, "hostZprime", 55550, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        Agent agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZprime");
        assert agent.getPort() == 55550;

        // now change Z's port to 55551
        request = createRequest(zName, "hostZprime", 55551, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZprime");
        assert agent.getPort() == 55551;

        // now change Z's host/port to hostZdoubleprime/55552
        request = createRequest(zName, "hostZdoubleprime" + tuid, 55552, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZdoubleprime" + tuid);
        assert agent.getPort() == 55552;

        // now don't change Z's host/port but re-register everything the same with its token
        request = createRequest(zName, "hostZdoubleprime" + tuid, 55552, results.getAgentToken());
        results = service.registerAgent(request);
        assert results != null;
        agent = LookupUtil.getAgentManager().getAgentByAgentToken(results.getAgentToken());
        assert agent.getName().equals(zName);
        assert agent.getAddress().equals("hostZdoubleprime" + tuid);
        assert agent.getPort() == 55552;

        // remember this agent so our later tests can use it
        AgentRegistrationRequest zReq = request;
        AgentRegistrationResults zResults = results;

        writeObjects("b.obj", zReq, zResults);

        // Try to re-register changes to host and/or port but do not send any token.
        // Because there is no token, these should fail.
        request = createRequest(zName, B_HOST, zReq.getPort(), null);
        try {
            service.registerAgent(request);
            assert false : "(1) Should not have been able to register without a token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(zName, zReq.getAddress(), B_PORT, null);
        try {
            service.registerAgent(request);
            assert false : "(2) Should not have been able to register without a token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(zName, B_HOST, B_PORT, null);
        try {
            service.registerAgent(request);
            assert false : "(3) Should not have been able to register without a token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(zName, zReq.getAddress(), zReq.getPort(), null);
        try {
            service.registerAgent(request);
            assert false : "(4) Should not have been able to register without a token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test(dependsOnMethods = "testChangeAddressPort")
    public void testNormalAgentRegistration() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest aReq = createRequest(prefixName("A"), A_HOST, A_PORT, null);
        AgentRegistrationResults aResults = service.registerAgent(aReq);
        assert aResults != null : "got null results";

        writeObjects("a.obj", aReq, aResults);
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test(dependsOnMethods = "testNormalAgentRegistration")
    public void testHijackExistingAgentAddressPort() throws Exception {
        List<Object> objs = readObjects("a.obj", 1);
        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;
        request = createRequest(prefixName("B"), aReq.getAddress(), aReq.getPort(), null);
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used host/port with new agent name";
        } catch (AgentRegistrationException ok) {
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test(dependsOnMethods = "testNormalAgentRegistration")
    public void testHijackExistingAgentName() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;

        List<Object> objs = readObjects("a.obj", 1);
        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);

        request = createRequest(aReq.getName(), aReq.getAddress(), B_PORT, null);
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used agent name without a token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(aReq.getName(), B_HOST, aReq.getPort(), null);
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used agent name without a token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(aReq.getName(), B_HOST, B_PORT, null);
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used agent name without a token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test(dependsOnMethods = "testNormalAgentRegistration")
    public void testHijackExistingAgentAddressPortWithBogusToken() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;

        List<Object> objs = readObjects("a.obj", 1);
        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);

        request = createRequest(prefixName("B"), aReq.getAddress(), aReq.getPort(), "badtoken");
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used host/port with new agent name and invalid token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test(dependsOnMethods = "testNormalAgentRegistration")
    public void testHijackExistingAgentNameWithBogusToken() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;

        List<Object> objs = readObjects("a.obj", 1);
        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);

        request = createRequest(aReq.getName(), aReq.getAddress(), aReq.getPort(), "badtoken");
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used agent name with an invalid token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }

        request = createRequest(aReq.getName(), aReq.getAddress(), B_PORT, "badtoken");
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used agent name with an invalid token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(aReq.getName(), B_HOST, aReq.getPort(), "badtoken");
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used agent name with an invalid token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
        }
        request = createRequest(aReq.getName(), B_HOST, B_PORT, "badtoken");
        try {
            service.registerAgent(request);
            assert false : "Should not have been able to hijack a used agent name with an invalid token";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test(dependsOnMethods = "testNormalAgentRegistration")
    public void testHijackExistingAgentNameWithAnotherAgentToken() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;

        List<Object> objs = readObjects("a.obj", 1);
        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);

        objs = readObjects("b.obj", 2);
        @SuppressWarnings("unused")
        AgentRegistrationRequest zReq = (AgentRegistrationRequest) objs.get(0);
        AgentRegistrationResults zResults = (AgentRegistrationResults) objs.get(1);

        request = createRequest(aReq.getName(), aReq.getAddress(), aReq.getPort(), zResults.getAgentToken());
        try {
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationRequest

    }

    @Test(dependsOnMethods = "testNormalAgentRegistration")
    public void testAgentHijackingAnotherAgentAddressPort() throws Exception {
        CoreServerServiceImpl service = new CoreServerServiceImpl();
        AgentRegistrationRequest request;
        List<Object> objs = readObjects("a.obj", 2);
        AgentRegistrationRequest aReq = (AgentRegistrationRequest) objs.get(0);
        AgentRegistrationResults aResults = (AgentRegistrationResults) objs.get(1);

        objs = readObjects("b.obj", 1);
        AgentRegistrationRequest zReq = (AgentRegistrationRequest) objs.get(0);

        request = createRequest(aReq.getName(), zReq.getAddress(), zReq.getPort(), aResults.getAgentToken());
        try {
            service.registerAgent(request);
            assert false : "An agent should not have been able to hijack another agent's host/port";
        } catch (AgentRegistrationException ok) {
            debugPrintThrowable(ok);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.