@@ -151,7 +151,14 @@ class HttpSecurityFilterSuite extends SparkFunSuite {
151151 val chain = mock(classOf [FilterChain ])
152152 val filter = new HttpSecurityFilter (conf, secMgr)
153153
154+ // First try with a non-admin so that the admin check is verified. This ensures that
155+ // the admin check is setting the expected error, since the impersonated user would
156+ // have permissions to process the request.
154157 when(req.getParameter(" doAs" )).thenReturn(" proxy" )
158+ when(req.getRemoteUser()).thenReturn(" bob" )
159+ filter.doFilter(req, res, chain)
160+ verify(res, times(1 )).sendError(meq(HttpServletResponse .SC_FORBIDDEN ), any())
161+
155162 when(req.getRemoteUser()).thenReturn(" admin" )
156163 filter.doFilter(req, res, chain)
157164 verify(chain, times(1 )).doFilter(any(), any())
@@ -165,10 +172,6 @@ class HttpSecurityFilterSuite extends SparkFunSuite {
165172 // Impersonating a user without view permissions should cause an error.
166173 when(req.getParameter(" doAs" )).thenReturn(" alice" )
167174 filter.doFilter(req, res, chain)
168- verify(res).sendError(meq(HttpServletResponse .SC_FORBIDDEN ), any())
169-
170- when(req.getRemoteUser()).thenReturn(" bob" )
171- filter.doFilter(req, res, chain)
172175 verify(res, times(2 )).sendError(meq(HttpServletResponse .SC_FORBIDDEN ), any())
173176 }
174177
0 commit comments