Java Code Examples for org.springframework.mock.web.mockhttpservletrequest#setAuthType()
The following examples show how to use
org.springframework.mock.web.mockhttpservletrequest#setAuthType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiListenerServletTest.java From iaf with Apache License 2.0 | 6 votes |
@Test public void authRoleAuthentication401() throws ServletException, IOException, ListenerException, ConfigurationException { String uri = "authRole2"; addListener(uri, Methods.POST, AuthMethods.AUTHROLE); Map<String, String> headers = new HashMap<String, String>(); headers.put("Authorization", "am9objpkb2U="); MockHttpServletRequest request = createRequest(uri, Methods.POST, "{\"tralalalallala\":true}", headers); request.setAuthType("BASIC_AUTH"); request.addUserRole("non-existing-role"); Response result = service(request); assertEquals(401, result.getStatus()); assertFalse(result.containsHeader("Allow")); assertNull(result.getErrorMessage()); }
Example 2
Source File: ApiListenerServletTest.java From iaf with Apache License 2.0 | 6 votes |
@Test public void authRoleAuthentication200() throws ServletException, IOException, ListenerException, ConfigurationException { String uri = "authRole2"; addListener(uri, Methods.POST, AuthMethods.AUTHROLE); Map<String, String> headers = new HashMap<String, String>(); headers.put("Authorization", "am9objpkb2U="); MockHttpServletRequest request = createRequest(uri, Methods.POST, "{\"tralalalallala\":true}", headers); request.setAuthType("BASIC_AUTH"); request.addUserRole("IbisObserver"); Response result = service(request); assertEquals(200, result.getStatus()); assertTrue(result.containsHeader("Allow")); assertNull(result.getErrorMessage()); }
Example 3
Source File: HtmlUnitRequestBuilder.java From spring-analysis-note with MIT License | 5 votes |
private void authType(MockHttpServletRequest request) { String authorization = header("Authorization"); String[] authSplit = StringUtils.split(authorization, ": "); if (authSplit != null) { request.setAuthType(authSplit[0]); } }
Example 4
Source File: HtmlUnitRequestBuilder.java From java-technology-stack with MIT License | 5 votes |
private void authType(MockHttpServletRequest request) { String authorization = header("Authorization"); String[] authSplit = StringUtils.split(authorization, ": "); if (authSplit != null) { request.setAuthType(authSplit[0]); } }
Example 5
Source File: HtmlUnitRequestBuilder.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void authType(MockHttpServletRequest request) { String authorization = header("Authorization"); if (authorization != null) { String[] authzParts = authorization.split(": "); request.setAuthType(authzParts[0]); } }