Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SELC-6156] feat: Fixed path of endpoint #656

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/onboarding-ms/src/main/docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
"tags" : [ "internal-v1" ],
"summary" : "Retrieves the list of files on the azure storage on the given path",
"description" : "Fetches a list of files associated with the specified path on the storage.",
"operationId" : "getFiles",
"operationId" : "getFilesFromPath",
"parameters" : [ {
"name" : "path",
"in" : "path",
Expand Down
2 changes: 1 addition & 1 deletion apps/onboarding-ms/src/main/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ paths:
summary: Retrieves the list of files on the azure storage on the given path
description: Fetches a list of files associated with the specified path on the
storage.
operationId: getFiles
operationId: getFilesFromPath
parameters:
- name: path
in: path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import java.util.Base64;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -60,8 +61,9 @@ public Uni<List<String>> getFiles() {
@Tag(name = "internal-v1")
@Path("/{path}")
@Produces(MediaType.APPLICATION_JSON)
public Uni<List<String>> getFiles(@PathParam(value = "path") String path) {
return Uni.createFrom().item(blobClient.getFiles(path));
public Uni<List<String>> getFilesFromPath(@PathParam(value = "path") String path) {
var buildPath = new String(Base64.getDecoder().decode(path));
return Uni.createFrom().item(blobClient.getFiles(buildPath));
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package it.pagopa.selfcare.onboarding.controller;

import static io.restassured.RestAssured.given;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import io.quarkus.test.InjectMock;
Expand All @@ -14,9 +16,10 @@
import io.restassured.http.ContentType;
import it.pagopa.selfcare.azurestorage.AzureBlobClient;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.ArgumentCaptor;

@QuarkusTest
@TestHTTPEndpoint(DocumentController.class)
Expand All @@ -28,25 +31,27 @@ class DocumentControllerTest {

@Test
@TestSecurity(user = "userJwt")
void getFiles_ByPath_OK() {
void getFilesFromPath_ByPath_OK() {
// given
ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
final String path = "/test/test";
var builderPath = Base64.getEncoder().encodeToString(path.getBytes());
List<String> result = new ArrayList<>();

// when
when(blobClient.getFiles(anyString())).thenReturn(result);
when(blobClient.getFiles(captor.capture())).thenReturn(result);

given()
.when()
.contentType(ContentType.JSON)
.pathParam("path", path)
.pathParam("path", builderPath)
.get("{path}")
.then()
.statusCode(200);

// then
Mockito.verify(blobClient, times(1)).getFiles(anyString());

verify(blobClient, times(1)).getFiles(anyString());
assertEquals(captor.getValue(), path);
}

@Test
Expand All @@ -66,7 +71,7 @@ void getFiles_OK() {
.statusCode(200);

// then
Mockito.verify(blobClient, times(1)).getFiles();
verify(blobClient, times(1)).getFiles();

}

Expand Down
Loading