### Question:
SamlIdentityProvider implements OAuth2IdentityProvider { @Override public void init(InitContext context) { try { Auth auth = newAuth(initSettings(context.getCallbackUrl()), context.getRequest(), context.getResponse()); auth.login(context.generateCsrfState()); } catch (IOException | SettingsException e) { throw new IllegalStateException("Fail to intialize SAML authentication plugin", e); } } SamlIdentityProvider(SamlSettings samlSettings); @Override String getKey(); @Override String getName(); @Override Display getDisplay(); @Override boolean isEnabled(); @Override boolean allowsUsersToSignUp(); @Override void init(InitContext context); @Override void callback(CallbackContext context);  }### Answer:
@Test public void init() throws IOException { setSettings(true); DumbInitContext context = new DumbInitContext(); underTest.init(context); verify(context.response).sendRedirect(anyString()); assertThat(context.generateCsrfState.get()).isTrue(); }
@Test public void fail_to_init_when_login_url_is_invalid() { setSettings(true); settings.setProperty("sonar.auth.saml.loginUrl", "invalid"); DumbInitContext context = new DumbInitContext(); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("Fail to create Auth"); underTest.init(context); }