AbstractOAuth2Authenticator implements IAuthenticator { @Override public final void validate(final Authenticator authenticator) throws KangarooException { if (authenticator == null || authenticator.getConfiguration() == null) { throw new MisconfiguredAuthenticatorException(); } Map<String, String> config = authenticator.getConfiguration(); String clientId = config.getOrDefault(CLIENT_ID_KEY, null); String clientSecret = config.getOrDefault(CLIENT_SECRET_KEY, null); if (Strings.isNullOrEmpty(clientSecret) || Strings.isNullOrEmpty(clientId)) { throw new MisconfiguredAuthenticatorException(); } }  final Client getClient(); final void setClient(final Client client); final Session getSession(); final void setSession(final Session session); @Override final Response delegate(final Authenticator authenticator,
                                   final URI callback); @Override final void validate(final Authenticator authenticator); @Override final UserIdentity authenticate(final Authenticator authenticator,
                                           final MultivaluedMap<String, String>
                                                   parameters,
                                           final URI callback); static final GenericType<HashMap<String, String>> MAP_TYPE; static final String CLIENT_ID_KEY; static final String CLIENT_SECRET_KEY; }
@Test(expected = MisconfiguredAuthenticatorException.class) public void testValidateNullInput() throws Exception { authenticator.validate(null); }
@Test(expected = MisconfiguredAuthenticatorException.class) public void testValidateNullConfig() throws Exception { Authenticator config = new Authenticator(); config.setConfiguration(null); authenticator.validate(config); }
@Test(expected = MisconfiguredAuthenticatorException.class) public void testValidateEmptyConfig() throws Exception { Authenticator config = new Authenticator(); authenticator.validate(config); }
@Test(expected = MisconfiguredAuthenticatorException.class) public void testValidateNoAppId() throws Exception { Authenticator config = new Authenticator(); config.getConfiguration() .put(AbstractOAuth2Authenticator.CLIENT_SECRET_KEY, "foo"); authenticator.validate(config); }
@Test(expected = MisconfiguredAuthenticatorException.class) public void testValidateNoAppSecret() throws Exception { Authenticator config = new Authenticator(); config.getConfiguration() .put(AbstractOAuth2Authenticator.CLIENT_ID_KEY, "foo"); authenticator.validate(config); }
@Test public void testValidate() throws Exception { Authenticator config = new Authenticator(); config.getConfiguration() .put(AbstractOAuth2Authenticator.CLIENT_ID_KEY, "foo"); config.getConfiguration() .put(AbstractOAuth2Authenticator.CLIENT_SECRET_KEY, "bar"); authenticator.validate(config); }