Search in sources :

Example 31 with RemoteInvocation

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

the class AgentRemoteInvokerServiceExporterTest method reportCompleting_rejectedForDifferentUUID.

@Test
void reportCompleting_rejectedForDifferentUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo("other");
    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, never()).reportCompleting(any(AgentRuntimeInfo.class), any(JobIdentifier.class), any(JobResult.class));
    assertEquals(SC_FORBIDDEN, 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 32 with RemoteInvocation

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

the class AgentRemoteInvokerServiceExporterTest method getWork_allowedForSameUUID.

@Test
void getWork_allowedForSameUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo(AGENT_UUID);
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("getWork", new Class[] { AgentRuntimeInfo.class }, new Object[] { agent }));
    invoker.handleRequest(req, res);
    verify(target, only()).getWork(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 33 with RemoteInvocation

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

the class AgentRemoteInvokerServiceExporterTest method reportCurrentStatus_rejectedForDifferentUUID.

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

Example 34 with RemoteInvocation

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

the class AgentRemoteInvokerServiceExporterTest method rejectsWhenLegacyDisabled.

@Test
void rejectsWhenLegacyDisabled() throws Exception {
    when(env.get(AGENT_EXTRA_PROPERTIES)).thenReturn("");
    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, never()).ping(agent);
    assertEquals(SC_GONE, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.jupiter.api.Test)

Example 35 with RemoteInvocation

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

the class AgentRemoteInvokerServiceExporterTest method ping_rejectedForDifferentUUID.

@Test
void ping_rejectedForDifferentUUID() throws Exception {
    final AgentRuntimeInfo agent = runtimeInfo("other");
    final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("ping", new Class[] { AgentRuntimeInfo.class }, new Object[] { agent }));
    invoker.handleRequest(req, res);
    verify(target, never()).ping(any(AgentRuntimeInfo.class));
    assertEquals(SC_FORBIDDEN, res.getStatus());
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) Test(org.junit.jupiter.api.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