@SuppressWarnings("unchecked")
  @Test
  public void testAuthenticateAdministrator_SSO() throws Throwable {
    // given
    Map<String, String> settings = getProxySettingsForMode("SAML_SP");
    VOUserDetails admin = createVOUserDetails(1000, "admin", "org");
    admin.setUserRoles(Collections.singleton(UserRoleType.ORGANIZATION_ADMIN));

    Mockito.doReturn(admin)
        .when(besDAO)
        .getUserDetails(
            Matchers.any(ServiceInstance.class), Matchers.any(VOUser.class), Matchers.anyString());
    Mockito.doReturn(new PasswordAuthentication("nobody", ""))
        .when(configService)
        .getWebServiceAuthentication(Matchers.any(ServiceInstance.class), Matchers.anyMap());
    Mockito.doReturn(settings).when(configService).getAllProxyConfigurationSettings();

    // when
    authService.authenticateAdministrator(
        new PasswordAuthentication(admin.getUserId(), "admin123"));

    // then
    Mockito.verify(besDAO, Mockito.times(0))
        .getUser(Matchers.any(ServiceInstance.class), Matchers.any(VOUser.class));
  }
  @Ignore
  // TODO test in besDAO
  @Test(expected = ConfigurationException.class)
  public void testAuthenticateAdministrator_SSO_WithoutConfiguredPassword() throws Throwable {

    proxyConfigSettings.put(PlatformConfigurationKey.BSS_AUTH_MODE.name(), "SAML_SP");
    proxyConfigSettings.put(PlatformConfigurationKey.BSS_USER_PWD.name(), null);

    authService.authenticateAdministrator(new PasswordAuthentication("admin", "admin123"));
  }
  @Test
  public void testAuthenticateAdministrator_Params() throws Throwable {
    // given
    VOUserDetails admin = createVOUserDetails(1000, "admin", "app");
    admin.setUserRoles(Collections.singleton(UserRoleType.ORGANIZATION_ADMIN));
    Mockito.doReturn(new VOUserDetails())
        .when(authService)
        .authenticateUser(
            Matchers.any(ServiceInstance.class),
            Matchers.anyString(),
            Matchers.any(PasswordAuthentication.class),
            Matchers.any(UserRoleType.class));

    // when
    authService.authenticateAdministrator(defaultAuth);

    // then
    Mockito.verify(authService)
        .authenticateUser(null, null, defaultAuth, UserRoleType.ORGANIZATION_ADMIN);
  }
 @Test(expected = IllegalArgumentException.class)
 public void testAuthenticateAdministrator_noUserId() throws Throwable {
   authService.authenticateAdministrator(new PasswordAuthentication(null, "admin123"));
 }
 @Test(expected = ConfigurationException.class)
 public void testAuthenticateTMForController_noOrgConfigured() throws Throwable {
   authService.authenticateTMForController("ess.test", defaultAuth);
 }
 @Test(expected = IllegalArgumentException.class)
 public void testAuthenticateTMForInstance_NullUser() throws Throwable {
   authService.authenticateTMForInstance(CTRL_ID, "service1", null);
 }
 @Test(expected = ConfigurationException.class)
 public void testAuthenticateTMForController_NullOrganization() throws Throwable {
   authService.authenticateTMForController("controllerId", defaultAuth);
 }
 @Test(expected = IllegalArgumentException.class)
 public void testAuthenticateTMForController_NullAuth() throws Throwable {
   authService.authenticateTMForController("controllerId", null);
 }
 @Test(expected = IllegalArgumentException.class)
 public void testAuthenticateTMForController_NullController() throws Throwable {
   authService.authenticateTMForController(null, defaultAuth);
 }