Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuqi-Du committed May 23, 2024
1 parent 5546b21 commit 9ccbb25
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ccbb25

Please sign in to comment.