use of org.graylog2.rest.models.configuration.responses.TextField in project graylog2-server by Graylog2.
the class InputsResourceMaskingPasswordsTest method testRetrievalOfAllInputsWithPasswordFieldForUserNotAllowedToEditInput.
@Test
public void testRetrievalOfAllInputsWithPasswordFieldForUserNotAllowedToEditInput() throws NotFoundException {
final String inputId = "myinput";
final String inputType = "dummyinput";
final Input input = getInput(inputId, inputType);
final ConfigurationField fooInput = mock(ConfigurationField.class);
when(fooInput.getName()).thenReturn("foo");
final TextField passwordInput = getPasswordField("password");
final ConfigurationRequest configurationRequest = ConfigurationRequest.createWithFields(fooInput, passwordInput);
final InputDescription inputDescription = getInputDescription(configurationRequest);
this.availableInputs.put(inputType, inputDescription);
when(currentSubject.isPermitted(RestPermissions.INPUTS_READ + ":" + inputId)).thenReturn(true);
when(currentSubject.isPermitted(RestPermissions.INPUTS_EDIT + ":" + inputId)).thenReturn(false);
final Map<String, Object> configuration = ImmutableMap.of("foo", 42, "password", "verysecret");
when(input.getConfiguration()).thenReturn(configuration);
when(inputService.all()).thenReturn(Collections.singletonList(input));
final InputsList inputsList = this.inputsResource.list();
assertThat(inputsList.inputs()).isNotEmpty();
assertThat(inputsList.inputs()).allMatch(summary -> {
assertThat(summary.attributes()).hasSize(2);
assertThat(summary.attributes()).containsEntry("password", "<password set>");
assertThat(summary.attributes()).containsEntry("foo", 42);
return true;
});
}
Aggregations