Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public Project retrieveByName(@NonNull String projectName) {
});

return projects
.flatMap(project -> verifyVisibility(project, requestContext.get().getVisibility()))
.map(project -> {
Map<UUID, Instant> projectLastUpdatedTraceAtMap = transactionTemplateAsync
.nonTransaction(connection -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class RemoteAuthService implements AuthService {
Set.of("GET"));
put("^/v1/private/projects/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/metrics/?$",
Set.of("POST"));
put("^/v1/private/projects/retrieve/?$", Set.of("POST"));
Comment thread
ldaugusto marked this conversation as resolved.
put("^/v1/private/spans/?$", Set.of("GET"));
put("^/v1/private/spans/stats/?$", Set.of("GET"));
put("^/v1/private/spans/feedback-scores/names/?$", Set.of("GET"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,39 @@ Stream<Arguments> getProjectById__whenRetrieveRequestIsInvalid__thenReturnError(
404));
}

@Test
@DisplayName("when retrieving project from another workspace, then return 404")
void retrieveProject__whenProjectBelongsToAnotherWorkspace__thenReturn404() {
// Set up workspace A with a project
String workspaceNameA = UUID.randomUUID().toString();
String apiKeyA = UUID.randomUUID().toString();
String workspaceIdA = UUID.randomUUID().toString();
mockTargetWorkspace(apiKeyA, workspaceNameA, workspaceIdA);

var project = factory.manufacturePojo(Project.class);
createProject(project, apiKeyA, workspaceNameA);

// Set up workspace B with a different API key
String workspaceNameB = UUID.randomUUID().toString();
String apiKeyB = UUID.randomUUID().toString();
String workspaceIdB = UUID.randomUUID().toString();
mockTargetWorkspace(apiKeyB, workspaceNameB, workspaceIdB);

// Try to retrieve workspace A's project using workspace B's credentials
try (var actualResponse = client.target(URL_TEMPLATE.formatted(baseURI))
.path("retrieve")
.request()
.header(HttpHeaders.AUTHORIZATION, apiKeyB)
.header(WORKSPACE_HEADER, workspaceNameB)
.post(Entity.json(ProjectRetrieve.builder().name(project.name()).build()))) {

assertThat(actualResponse.getStatusInfo().getStatusCode()).isEqualTo(404);
assertThat(actualResponse.hasEntity()).isTrue();
assertThat(actualResponse.readEntity(ErrorMessage.class).errors())
.contains("Project not found");
}
}

}

@Nested
Expand Down
Loading