@GET
    @ApiOperation(value = "Retrieve the list of all fields present in the system")
    public Set<MappedFieldTypeDTO> allFieldTypes(@Context SearchUser searchUser) {
        final ImmutableSet<String> streams = searchUser.streams().loadAllMessageStreams();
        return mappedFieldTypesService.fieldTypesByStreamIds(streams, RelativeRange.allTime());
    }
@Test
    public void allFieldTypesChecksPermissionsForStream() {

        final SearchUser searchUser = TestSearchUser.builder()
                .allowStream("4242")
                .denyStream("2323")
                .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.allFieldTypes(searchUser);

        // field for allowed stream has to be present
        assertThat(fields.stream().anyMatch(f -> f.name().equals("4242"))).isTrue();

        // field for denied stream must not be present
        assertThat(fields.stream().anyMatch(f -> f.name().equals("2323"))).isFalse();
    }