//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testHttpBasicAuthenticationCheck() throws java.io.IOException, javax.servlet.ServletException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testHttpBasicAuthenticationCheck() { if (authenticationExpected) { when(identityServiceMock.checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD)).thenReturn(true); } MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletRequest request = new MockHttpServletRequest(); request.RequestURI = SERVICE_PATH + servletPath + requestUrl; request.ContextPath = SERVICE_PATH; request.ServletPath = servletPath; applyFilter(request, response, MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD); Assert.assertEquals(Status.OK.StatusCode, response.Status); if (authenticationExpected) { verify(identityServiceMock).setAuthentication(MockProvider.EXAMPLE_USER_ID, groupIds, tenantIds); verify(identityServiceMock).clearAuthentication(); } else { verify(identityServiceMock, never()).setAuthentication(any(typeof(string)), anyListOf(typeof(string)), anyListOf(typeof(string))); verify(identityServiceMock, never()).clearAuthentication(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected void applyFilter(org.springframework.mock.web.MockHttpServletRequest request, org.springframework.mock.web.MockHttpServletResponse response, String username, String password) throws java.io.IOException, javax.servlet.ServletException protected internal virtual void applyFilter(MockHttpServletRequest request, MockHttpServletResponse response, string username, string password) { string credentials = username + ":" + password; request.addHeader("Authorization", "Basic " + StringHelper.NewString(Base64.encodeBase64(credentials.GetBytes()))); FilterChain filterChain = new MockFilterChain(); authenticationFilter.doFilter(request, response, filterChain); }