@Test
	public void testEndpointAuthentication() throws Exception {

		logger.info(String.format("Using parameters - httpMethod: %s, "
				+ "URL: %s, URL parameters: %s, user credentials: %s", this.httpMethod,
				this.url, this.urlParameters, userCredentials));

		final MockHttpServletRequestBuilder rb;

		switch (httpMethod) {
			case GET:
				rb = get(url);
				break;
			case POST:
				rb = post(url);
				break;
			case PUT:
				rb = put(url);
				break;
			case DELETE:
				rb = delete(url);
				break;
			default:
				throw new IllegalArgumentException("Unsupported Method: " + httpMethod);
		}

		if (this.userCredentials != null) {
			rb.header("Authorization",
					basicAuthorizationHeader(this.userCredentials.getUsername(), this.userCredentials.getPassword()));
		}

		if (!CollectionUtils.isEmpty(urlParameters)) {
			for (Map.Entry<String, String> mapEntry : urlParameters.entrySet()) {
				rb.param(mapEntry.getKey(), mapEntry.getValue());
			}
		}

		final ResultMatcher statusResultMatcher;

		switch (expectedHttpStatus) {
			case UNAUTHORIZED:
				statusResultMatcher = status().isUnauthorized();
				break;
			case FORBIDDEN:
				statusResultMatcher = status().isForbidden();
				break;
			case NOT_FOUND:
				statusResultMatcher = status().isNotFound();
				break;
			case OK:
				statusResultMatcher = status().isOk();
				break;
			case CREATED:
				statusResultMatcher = status().isCreated();
				break;
			case BAD_REQUEST:
				statusResultMatcher = status().isBadRequest();
				break;
			case INTERNAL_SERVER_ERROR:
				statusResultMatcher = status().isInternalServerError();
				break;
			default:
				throw new IllegalArgumentException("Unsupported Status: " + expectedHttpStatus);
		}

		try {
			springXdResource.getMockMvc().perform(rb).andDo(print()).andExpect(statusResultMatcher);
		}
		catch (AssertionError e) {
			throw new AssertionError(
					String.format("Assertion failed for parameters - httpMethod: %s, "
							+ "URL: %s, URL parameters: %s, user credentials: %s",
							this.httpMethod, this.url, this.urlParameters, this.userCredentials),
					e);
		}
	}
Tests for security configuration backed by a file-based user list.

@author Eric Bottard
@author Gunnar Hillert
spring-xd-dirt/src/test/java/org/springframework/xd/dirt/security/SingleNodeApplicationWithUsersFileTest.java