requestHeaders = new Metadata();
attributes = Attributes.newBuilder()
.set(Grpc.TRANSPORT_ATTR_SSL_SESSION, sslSession)
.build();
when(call.getAttributes()).thenReturn(attributes);
when(call.getMethodDescriptor()).thenReturn(methodDescriptor);
when(sslSession.getPeerPrincipal()).thenReturn(peerPrincipal);
validator = new CertAuthInterceptor(true, AUTH_MAP);
...
when(peerPrincipal.getName()).thenReturn("my peer principal");
when(methodDescriptor.getFullMethodName()).thenReturn("my method...");
validator.interceptCall(call, requestHeaders, next);
This doesn't work any more because MethodDescriptor has been marked final and ServerCall has @DoNotMock annotation. How do I do this now? The annotation suggests using InProcessTransport, but it seems that Attributes are hard-coded in it, so I cannot provide sslSession. I also don't understand why I now have to jump through hoops to do such a simple test.
(CertAuthInterceptor is a ServerInterceptor that allows/denies a method call depending on the client certificate and AUTH_MAP).
thanks,
Eugene
MethodDescriptor<Object, Object> methodDescriptor = MethodDescriptor.newBuilder()
.setFullMethodName(fullMethodName)
.setType(MethodType.UNARY)
.setRequestMarshaller(marshaller)
.setResponseMarshaller(marshaller)
.build();