GrpcLeaderServerInterceptor implements ServerInterceptor { public static GrpcLeaderServerInterceptor clusterMembershipAllowed(LeaderActivationStatus leaderActivationStatus) { return new GrpcLeaderServerInterceptor(leaderActivationStatus, Collections.singletonList(ClusterMembershipServiceGrpc.getServiceDescriptor())); } GrpcLeaderServerInterceptor(LeaderActivationStatus leaderActivationStatus,
                                       List<ServiceDescriptor> notProtectedServices); @Override ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next); static GrpcLeaderServerInterceptor clusterMembershipAllowed(LeaderActivationStatus leaderActivationStatus);  }
@Test public void testClusterMembershipMethodIsAllowed() { testIsCallAllowed( GrpcLeaderServerInterceptor.clusterMembershipAllowed(() -> false), newServerCall(getMethod(ClusterMembershipServiceGrpc.getServiceDescriptor(), "GetMembers")) ); }
@Test public void testBusinessMethodIsNotAllowed() { testIsNotCallAllowed( GrpcLeaderServerInterceptor.clusterMembershipAllowed(() -> false), newServerCall(getMethod(SampleServiceGrpc.getServiceDescriptor(), "GetOneValue")) ); }
@Test public void testActiveLeaderIsAlwaysAllowed() { testIsCallAllowed( GrpcLeaderServerInterceptor.clusterMembershipAllowed(() -> true), newServerCall(getMethod(ClusterMembershipServiceGrpc.getServiceDescriptor(), "GetMembers")) ); testIsCallAllowed( GrpcLeaderServerInterceptor.clusterMembershipAllowed(() -> true), newServerCall(getMethod(SampleServiceGrpc.getServiceDescriptor(), "GetOneValue")) ); }