@SuppressWarnings("unchecked")
@Test
public void testAdminUnauthorizedByRedirect() throws Exception {

  HttpURLConnection conn = EasyMock.createMock(HttpURLConnection.class);
  expect(conn.getResponseCode()).andReturn(200);
  expect(conn.getInputStream()).andReturn(new ByteArrayInputStream(BAD_LOGIN_RESPONSE.getBytes()));
  expect(m_streamProvider.processURL((String) anyObject(), (String) anyObject(),
      (InputStream) anyObject(), (Map<String, List<String>>) anyObject())).andReturn(conn).anyTimes();
  replay(conn, m_streamProvider);
  PrerequisiteCheck check = new PrerequisiteCheck(CheckDescription.SERVICES_RANGER_PASSWORD_VERIFY, null);
  m_rpc.perform(check, new PrereqCheckRequest("cluster"));
  assertEquals(PrereqCheckStatus.FAIL, check.getStatus());
  assertEquals("Credentials for user 'admin' in Ambari do not match Ranger.", check.getFailReason());
  verify(conn, m_streamProvider);
}