//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPassThroughRequestToAnUnsecuredPath() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldPassThroughRequestToAnUnsecuredPath() { // given SecurityRule rule = mock(typeof(SecurityRule)); when(rule.ForUriPath()).thenReturn("/some-path"); FilterChain filterChain = mock(typeof(FilterChain)); SecurityFilter securityFilter = new SecurityFilter(rule); HttpServletRequest request = mock(typeof(HttpServletRequest)); when(request.ContextPath).thenReturn("/some-other-path"); // when securityFilter.DoFilter(request, mock(typeof(HttpServletResponse)), filterChain); // then verify(filterChain).doFilter(any(typeof(HttpServletRequest)), any(typeof(HttpServletResponse))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldActivateRuleThatRejectsTheRequestForAMatchingPath() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldActivateRuleThatRejectsTheRequestForAMatchingPath() { // given SecurityRule rule = mock(typeof(SecurityRule)); when(rule.ForUriPath()).thenReturn("/some-path"); when(rule.IsAuthorized(any(typeof(HttpServletRequest)))).thenReturn(false); FilterChain filterChain = mock(typeof(FilterChain)); SecurityFilter securityFilter = new SecurityFilter(rule); HttpServletRequest request = mock(typeof(HttpServletRequest)); when(request.ContextPath).thenReturn("/some-path"); // when securityFilter.DoFilter(request, mock(typeof(HttpServletResponse)), filterChain); // then verify(filterChain, never()).doFilter(any(typeof(HttpServletRequest)), any(typeof(HttpServletResponse))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldRemoveRules() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldRemoveRules() { // given SecurityRule securityRule1 = mock(typeof(SecurityRule)); when(securityRule1.ForUriPath()).thenReturn("/securityRule1"); SecurityRule securityRule2 = mock(typeof(SecurityRule)); when(securityRule2.ForUriPath()).thenReturn("/securityRule2"); SecurityFilter securityFilter = new SecurityFilter(securityRule1, securityRule2); HttpServletRequest request = mock(typeof(HttpServletRequest)); HttpServletResponse response = mock(typeof(HttpServletResponse)); FilterChain filterChain = mock(typeof(FilterChain)); // when securityFilter.Destroy(); securityFilter.DoFilter(request, response, filterChain); // then verify(filterChain).doFilter(request, response); }