Search in sources :

Example 1 with CloseAwareListener

use of io.camunda.zeebe.test.util.grpc.CloseAwareListener in project zeebe by zeebe-io.

the class TestInterceptor method interceptCall.

@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(final ServerCall<ReqT, RespT> call, final Metadata headers, final ServerCallHandler<ReqT, RespT> next) {
    final var listener = next.startCall(call, headers);
    return new CloseAwareListener<>(listener) {

        @Override
        public void onMessage(final ReqT message) {
            if (message instanceof DeployResourceRequest) {
                call.close(Status.PERMISSION_DENIED.augmentDescription(ERROR_MESSAGE), new Metadata());
                isClosed = true;
                return;
            }
            super.onMessage(message);
        }
    };
}
Also used : Metadata(io.grpc.Metadata) CloseAwareListener(io.camunda.zeebe.test.util.grpc.CloseAwareListener) DeployResourceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest)

Example 2 with CloseAwareListener

use of io.camunda.zeebe.test.util.grpc.CloseAwareListener in project zeebe by camunda-cloud.

the class TestInterceptor method interceptCall.

@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(final ServerCall<ReqT, RespT> call, final Metadata headers, final ServerCallHandler<ReqT, RespT> next) {
    final var listener = next.startCall(call, headers);
    return new CloseAwareListener<>(listener) {

        @Override
        public void onMessage(final ReqT message) {
            if (message instanceof DeployResourceRequest) {
                call.close(Status.PERMISSION_DENIED.augmentDescription(ERROR_MESSAGE), new Metadata());
                isClosed = true;
                return;
            }
            super.onMessage(message);
        }
    };
}
Also used : Metadata(io.grpc.Metadata) CloseAwareListener(io.camunda.zeebe.test.util.grpc.CloseAwareListener) DeployResourceRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest)

Example 3 with CloseAwareListener

use of io.camunda.zeebe.test.util.grpc.CloseAwareListener in project zeebe by camunda.

the class TestInterceptor method interceptCall.

@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(final ServerCall<ReqT, RespT> call, final Metadata headers, final ServerCallHandler<ReqT, RespT> next) {
    final var listener = next.startCall(call, headers);
    return new CloseAwareListener<>(listener) {

        @Override
        public void onMessage(final ReqT message) {
            if (message instanceof DeployProcessRequest) {
                call.close(Status.PERMISSION_DENIED.augmentDescription(ERROR_MESSAGE), new Metadata());
                isClosed = true;
                return;
            }
            super.onMessage(message);
        }
    };
}
Also used : Metadata(io.grpc.Metadata) CloseAwareListener(io.camunda.zeebe.test.util.grpc.CloseAwareListener) DeployProcessRequest(io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployProcessRequest)

Aggregations

CloseAwareListener (io.camunda.zeebe.test.util.grpc.CloseAwareListener)3 Metadata (io.grpc.Metadata)3 DeployResourceRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployResourceRequest)2 DeployProcessRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.DeployProcessRequest)1