Search in sources :

Example 36 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.

the class AgentRemoteInvokerServiceExporterTest method reportCompleting_allowedForSameUUID.

@Test
void reportCompleting_allowedForSameUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo(AGENT_UUID);
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("reportCompleting", new Class[] { AgentRuntimeInfo.class, JobIdentifier.class, JobResult.class }, new Object[] { agent, null, null }));
    invoker.handleRequest(req, res);
    verify(target, only()).reportCompleting(agent, null, null);
    assertEquals(SC_OK, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) JobResult(com.thoughtworks.go.domain.JobResult) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Test(org.junit.jupiter.api.Test)

Example 37 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.

the class AgentRemoteInvokerServiceExporterTest method ping_allowedForSameUUID.

@Test
void ping_allowedForSameUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo(AGENT_UUID);
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("ping", new Class[] { AgentRuntimeInfo.class }, new Object[] { agent }));
    invoker.handleRequest(req, res);
    verify(target, only()).ping(agent);
    assertEquals(SC_OK, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.jupiter.api.Test)

Example 38 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.

the class AgentRemoteInvokerServiceExporter method handleRequest.

@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    if (rejectRMI()) {
        // yes, ideally, this should be short-circuited in the agent auth filter, but keeping this logic here has
        // some advantages:
        // - it keeps all deprecated RMI logic in one place so it's easier to remove (just remove this class)
        // - it's 100% reliable by virtue of its proximity to the RMI invocation code and can't be thwarted by
        // some clever URI encoding to circumvent the uri path test that we would need to write at the filter
        // level in order to selectively apply this logic to the RMI endpoint and not the JSON API endpoint
        reject(response, SC_GONE, "This RMI endpoint is disabled.");
        return;
    }
    try {
        RemoteInvocation invocation = readRemoteInvocation(request);
        if (!authorized(request, response, invocation)) {
            return;
        }
        RemoteInvocationResult result = invokeAndCreateResult(invocation, getProxy());
        writeRemoteInvocationResult(request, response, result);
    } catch (ClassNotFoundException ex) {
        throw new NestedServletException("Class not found during deserialization", ex);
    }
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) NestedServletException(org.springframework.web.util.NestedServletException) RemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult)

Example 39 with RemoteInvocation

use of org.springframework.remoting.support.RemoteInvocation in project shiro by apache.

the class SecureRemoteInvocationFactoryTest method testSessionManagerProxyStartRemoteInvocation.

@Test
public void testSessionManagerProxyStartRemoteInvocation() throws Exception {
    SecureRemoteInvocationFactory factory = new SecureRemoteInvocationFactory();
    MethodInvocation mi = createMock(MethodInvocation.class);
    Method startMethod = getMethod("start", SessionManager.class);
    expect(mi.getMethod()).andReturn(startMethod).anyTimes();
    Object[] args = { "localhost" };
    expect(mi.getArguments()).andReturn(args).anyTimes();
    replay(mi);
    RemoteInvocation ri = factory.createRemoteInvocation(mi);
    verify(mi);
    assertNull(ri.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY));
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) MethodInvocation(org.aopalliance.intercept.MethodInvocation) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)39 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)16 Test (org.junit.jupiter.api.Test)16 RemoteInvocationResult (org.springframework.remoting.support.RemoteInvocationResult)14 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)8 Test (org.junit.Test)8 RemoteAccessException (org.springframework.remoting.RemoteAccessException)7 IOException (java.io.IOException)6 MethodInvocation (org.aopalliance.intercept.MethodInvocation)6 ITestBean (org.springframework.tests.sample.beans.ITestBean)5 JobResult (com.thoughtworks.go.domain.JobResult)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 TestBean (org.springframework.tests.sample.beans.TestBean)4 NestedServletException (org.springframework.web.util.NestedServletException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Method (java.lang.reflect.Method)3 ServletException (javax.servlet.ServletException)3 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)3