Search in sources :

Example 16 with ErrorResponse

use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.

the class ProduceActionIntegrationTest method produceAvroWithTypeAndSchemaId_returnsBadRequest.

@Test
public void produceAvroWithTypeAndSchemaId_returnsBadRequest() throws Exception {
    String clusterId = testEnv.kafkaCluster().getClusterId();
    String request = "{ \"key\": { \"type\": \"AVRO\", \"schema_id\": 1 } }";
    Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    ErrorResponse actual = response.readEntity(ErrorResponse.class);
    assertEquals(400, actual.getErrorCode());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 17 with ErrorResponse

use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.

the class ProduceActionIntegrationTest method produceAvroWithSchemaSubjectAndSchemaSubjectStrategy_returnsBadRequest.

@Test
public void produceAvroWithSchemaSubjectAndSchemaSubjectStrategy_returnsBadRequest() throws Exception {
    String clusterId = testEnv.kafkaCluster().getClusterId();
    String request = "{ \"key\": { \"subject\": \"foobar\", \"subject_name_strategy\": \"TOPIC\" } }";
    Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    ErrorResponse actual = response.readEntity(ErrorResponse.class);
    assertEquals(400, actual.getErrorCode());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 18 with ErrorResponse

use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.

the class ProduceActionIntegrationTest method produceProtobufWithRawSchemaAndInvalidData_throwsBadRequest.

@Test
public void produceProtobufWithRawSchemaAndInvalidData_throwsBadRequest() throws Exception {
    String clusterId = testEnv.kafkaCluster().getClusterId();
    ProtobufSchema keySchema = new ProtobufSchema("syntax = \"proto3\"; message MyKey { string foo = 1; }");
    ProtobufSchema valueSchema = new ProtobufSchema("syntax = \"proto3\"; message MyValue { string bar = 1; }");
    ProduceRequest request = ProduceRequest.builder().setKey(ProduceRequestData.builder().setFormat(EmbeddedFormat.PROTOBUF).setRawSchema(keySchema.canonicalString()).setData(IntNode.valueOf(1)).build()).setValue(ProduceRequestData.builder().setFormat(EmbeddedFormat.PROTOBUF).setRawSchema(valueSchema.canonicalString()).setData(IntNode.valueOf(2)).build()).setOriginalSize(0L).build();
    Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    ErrorResponse actual = response.readEntity(ErrorResponse.class);
    assertEquals(400, actual.getErrorCode());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ProduceRequest(io.confluent.kafkarest.entities.v3.ProduceRequest) ProtobufSchema(io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 19 with ErrorResponse

use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.

the class ProduceActionIntegrationTest method produceAvroWithTypeAndSchemaVersion_returnsBadRequest.

@Test
public void produceAvroWithTypeAndSchemaVersion_returnsBadRequest() throws Exception {
    String clusterId = testEnv.kafkaCluster().getClusterId();
    String request = "{ \"key\": { \"type\": \"AVRO\", \"schema_version\": 1 } }";
    Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    ErrorResponse actual = response.readEntity(ErrorResponse.class);
    assertEquals(400, actual.getErrorCode());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Example 20 with ErrorResponse

use of io.jans.scim.model.scim2.ErrorResponse in project kafka-rest by confluentinc.

the class ProduceActionIntegrationTest method produceBinaryWithSchemaVersion_returnsBadRequest.

@Test
public void produceBinaryWithSchemaVersion_returnsBadRequest() throws Exception {
    String clusterId = testEnv.kafkaCluster().getClusterId();
    String request = "{ \"key\": { \"type\": \"BINARY\", \"schema_version\": 1 } }";
    Response response = testEnv.kafkaRest().target().path("/v3/clusters/" + clusterId + "/topics/" + TOPIC_NAME + "/records").request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(request, MediaType.APPLICATION_JSON));
    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    ErrorResponse actual = response.readEntity(ErrorResponse.class);
    assertEquals(400, actual.getErrorCode());
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) ProduceResponse(io.confluent.kafkarest.entities.v3.ProduceResponse) ByteString(com.google.protobuf.ByteString) ErrorResponse(io.confluent.kafkarest.exceptions.v3.ErrorResponse) Test(org.junit.jupiter.api.Test)

Aggregations

ErrorResponse (io.confluent.kafkarest.exceptions.v3.ErrorResponse)23 Test (org.junit.jupiter.api.Test)23 ProduceResponse (io.confluent.kafkarest.entities.v3.ProduceResponse)21 Response (javax.ws.rs.core.Response)20 ByteString (com.google.protobuf.ByteString)19 ProduceRequest (io.confluent.kafkarest.entities.v3.ProduceRequest)8 RequestRateLimiter (io.confluent.kafkarest.ratelimit.RequestRateLimiter)3 ChunkedOutputFactory (io.confluent.kafkarest.response.ChunkedOutputFactory)3 FakeAsyncResponse (io.confluent.kafkarest.response.FakeAsyncResponse)3 ResultOrError (io.confluent.kafkarest.response.StreamingResponse.ResultOrError)3 Properties (java.util.Properties)3 RateLimitExceededException (io.confluent.kafkarest.ratelimit.RateLimitExceededException)2 ArrayList (java.util.ArrayList)2 ErrorResponse (org.gluu.oxtrust.model.scim2.ErrorResponse)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ProtobufSchema (io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema)1 ErrorResponse (io.jans.scim.model.scim2.ErrorResponse)1