@POST
    @ApiOperation(value = "Retrieve the field list of a given set of streams")
    @NoAuditEvent("This is not changing any data")
    public Set<MappedFieldTypeDTO> byStreams(@ApiParam(name = "JSON body", required = true)
                                             @Valid @NotNull FieldTypesForStreamsRequest request,
                                             @Context SearchUser searchUser) {
        final ImmutableSet<String> streams = searchUser.streams().readableOrAllIfEmpty(request.streams());
        return mappedFieldTypesService.fieldTypesByStreamIds(streams, request.timerange().orElse(RelativeRange.allTime()));
    }
@Test
    public void byStreamChecksPermissionsForStream() {
        final SearchUser searchUser = TestSearchUser.builder()
                .allowStream("2323")
                .allowStream("4242")
                .build();

        final FieldTypesForStreamsRequest req = FieldTypesForStreamsRequest.Builder.builder()
                .streams(ImmutableSet.of("2323", "4242"))
                .build();

        final MappedFieldTypesService fieldTypesService = (streamIds, timeRange) -> {
            // for each streamID return a field that's called exactly like the streamID
            return streamIds.stream()
                    .map(streamID -> MappedFieldTypeDTO.create(streamID, FieldTypes.Type.builder().type("text").build()))
                    .collect(Collectors.toSet());
        };

        final FieldTypesResource resource = new FieldTypesResource(fieldTypesService, mock(IndexFieldTypePollerPeriodical.class));
        final Set<MappedFieldTypeDTO> fields = resource.byStreams(req, searchUser);

        assertThat(fields)
                .hasSize(2)
                .extracting(MappedFieldTypeDTO::name)
                .containsOnly("2323", "4242");
    }