From 9ccbb25a77196e5983a6649219ffe06032ab3036 Mon Sep 17 00:00:00 2001 From: Yuqi Du Date: Thu, 23 May 2024 08:42:04 -0700 Subject: [PATCH] fix --- .../v1/CreateCollectionIntegrationTest.java | 49 +++++++++++++++++-- .../v1/VectorizeSearchIntegrationTest.java | 43 ---------------- 2 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java index b1527420f5..f5e85f6db7 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/CreateCollectionIntegrationTest.java @@ -1,10 +1,7 @@ package io.stargate.sgv2.jsonapi.api.v1; import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.Matchers.startsWith; +import static org.hamcrest.Matchers.*; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusIntegrationTest; @@ -1265,6 +1262,50 @@ public void happyValidAuthKey() { deleteCollection("collection_with_vector_service"); } + + @Test + public void failForBadProviderKeyFormat() { + String json = + """ + { + "createCollection": { + "name": "incorrectProviderKeyFormat", + "options": { + "vector": { + "metric": "cosine", + "dimension": 5, + "service": { + "provider": "openai", + "modelName": "text-embedding-ada-002", + "authentication": { + "providerKey" : "shared_creds" + }, + "parameters": { + "projectId": "test project" + } + } + } + } + } + } + """; + given() + .headers(getHeaders()) + .contentType(ContentType.JSON) + .body(json) + .when() + .post(NamespaceResource.BASE_PATH, namespaceName) + .then() + .statusCode(200) + .body("status", is(nullValue())) + .body("data", is(nullValue())) + .body("errors[0].errorCode", is("VECTORIZE_INVALID_SHARED_KEY_VALUE_FORMAT")) + .body("errors[0].exceptionClass", is("JsonApiException")) + .body( + "errors[0].message", + startsWith( + "Invalid authentication value format: providerKey value should be formatted as '[keyName].providerKey'")); + } } @Nested diff --git a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java index c02523369c..ca73057d6c 100644 --- a/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java +++ b/src/test/java/io/stargate/sgv2/jsonapi/api/v1/VectorizeSearchIntegrationTest.java @@ -103,49 +103,6 @@ public void happyPathVectorSearch() { .statusCode(200) .body("status.ok", is(1)); } - - @Test - public void failForBadProviderKeyFormat() { - String json = - """ - { - "createCollection": { - "name": "incorrectProviderKeyFormat", - "options": { - "vector": { - "metric": "cosine", - "dimension": 5, - "service": { - "provider": "custom", - "modelName": "text-embedding-ada-002", - "authentication": { - "providerKey" : "shared_creds" - }, - "parameters": { - "projectId": "test project" - } - } - } - } - } - } - """; - given() - .headers(getHeaders()) - .contentType(ContentType.JSON) - .body(json) - .when() - .post(NamespaceResource.BASE_PATH, namespaceName) - .then() - .statusCode(200) - .body("errors", is(notNullValue())) - .body("errors", hasSize(1)) - .body("errors[0].errorCode", is("VECTORIZE_INVALID_SHARED_KEY_VALUE_FORMAT")) - .body("errors[0].exceptionClass", is("JsonApiException")) - .body( - "errors[0].message", - contains("providerKey value should be formatted as '[keyName].providerKey'")); - } } @Nested