From 39a806741262af3f3b64a6f34755a12ce59fe570 Mon Sep 17 00:00:00 2001 From: Sergey Zinchenko Date: Thu, 26 Dec 2024 21:26:39 +0100 Subject: [PATCH] resource api tests --- .../aidial/core/server/ResourceApiTest.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/server/src/test/java/com/epam/aidial/core/server/ResourceApiTest.java b/server/src/test/java/com/epam/aidial/core/server/ResourceApiTest.java index 30dde444..472cbaaa 100644 --- a/server/src/test/java/com/epam/aidial/core/server/ResourceApiTest.java +++ b/server/src/test/java/com/epam/aidial/core/server/ResourceApiTest.java @@ -322,7 +322,7 @@ void testHeartbeat() { } @Test - void testApplicationWithTypeSchemaCreation_files_ok() { + void testApplicationWithTypeSchemaCreation_Ok_FilesAccessible() { Response response = upload(HttpMethod.PUT,"/v1/files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_file1.txt",null, """ Test1 """); @@ -357,7 +357,7 @@ void testApplicationWithTypeSchemaCreation_files_ok() { } @Test - void testApplicationWithTypeSchemaCreation_fail() { + void testApplicationWithTypeSchemaCreation_Ok_Folder() { Response response = send(HttpMethod.PUT,"/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_app_folder",null, """ { "displayName": "test_app", @@ -365,7 +365,7 @@ void testApplicationWithTypeSchemaCreation_fail() { "property1": "test property1", "property2": "test property2", "property3": [ - "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/unexisting_folder/unexisting_file.txt" + "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/xyz/" ], "userRoles": [ "Admin" @@ -375,19 +375,19 @@ void testApplicationWithTypeSchemaCreation_fail() { "description": "My application description" } """); - Assertions.assertEquals(400, response.status()); + Assertions.assertEquals(200, response.status()); } @Test - void testApplicationWithTypeSchemaCreation_folder_ok() { - Response response = send(HttpMethod.PUT,"/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_app",null, """ + void testApplicationWithTypeSchemaCreation_Failed_FailAccessFile() { + Response response = send(HttpMethod.PUT,"/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_app_files_failed",null, """ { "displayName": "test_app", "customAppSchemaId": "https://mydial.somewhere.com/custom_application_schemas/specific_application_type", "property1": "test property1", "property2": "test property2", "property3": [ - "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/xyz/" + "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/unexisting_folder/unexisting_file.txt" ], "userRoles": [ "Admin" @@ -397,6 +397,23 @@ void testApplicationWithTypeSchemaCreation_folder_ok() { "description": "My application description" } """); - Assertions.assertEquals(200, response.status()); + Assertions.assertEquals(400, response.status()); + } + + @Test + void testApplicationWithTypeSchemaCreation_Failed_FailMissingProps() { + Response response = send(HttpMethod.PUT,"/v1/applications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/test_app_props_failed",null, """ + { + "displayName": "test_app", + "customAppSchemaId": "https://mydial.somewhere.com/custom_application_schemas/specific_application_type", + "userRoles": [ + "Admin" + ], + "forwardAuthToken": true, + "iconUrl": "https://mydial.somewhere.com/app-icon.svg", + "description": "My application description" + } + """); + Assertions.assertEquals(400, response.status()); } } \ No newline at end of file