use of org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2UtilTest method testAuthenticateClientCacheHit.
@Test
public void testAuthenticateClientCacheHit() throws Exception {
OAuthAppDO appDO = new OAuthAppDO();
appDO.setOauthConsumerKey(clientId);
appDO.setOauthConsumerSecret(clientSecret);
AppInfoCache appInfoCache = mock(AppInfoCache.class);
when(appInfoCache.getValueFromCache(clientId)).thenReturn(appDO);
mockStatic(AppInfoCache.class);
when(AppInfoCache.getInstance()).thenReturn(appInfoCache);
when(oauthServerConfigurationMock.getPersistenceProcessor()).thenReturn(new PlainTextPersistenceProcessor());
assertTrue(OAuth2Util.authenticateClient(clientId, clientSecret));
}
use of org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuthConsumerDAOTest method testGetOAuthConsumerSecret.
@Test
public void testGetOAuthConsumerSecret() throws Exception {
mockStatic(OAuthServerConfiguration.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(mockedServerConfig);
PlainTextPersistenceProcessor processor = new PlainTextPersistenceProcessor();
when(mockedServerConfig.getPersistenceProcessor()).thenReturn(processor);
try (Connection connection1 = getConnection(DB_NAME)) {
mockStatic(IdentityDatabaseUtil.class);
when(IdentityDatabaseUtil.getDBConnection(false)).thenReturn(connection1);
OAuthConsumerDAO consumerDAO = new OAuthConsumerDAO();
assertEquals(consumerDAO.getOAuthConsumerSecret(CLIENT_ID), SECRET);
}
}
use of org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuthConsumerDAOTest method testIsConsumerSecretExist.
@Test
public void testIsConsumerSecretExist() throws Exception {
mockStatic(OAuthServerConfiguration.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(mockedServerConfig);
PlainTextPersistenceProcessor processor = new PlainTextPersistenceProcessor();
when(mockedServerConfig.getPersistenceProcessor()).thenReturn(processor);
try (Connection connection1 = getConnection(DB_NAME)) {
mockStatic(IdentityDatabaseUtil.class);
when(IdentityDatabaseUtil.getDBConnection(false)).thenReturn(connection1);
OAuthConsumerDAO consumerDAO = new OAuthConsumerDAO();
assertEquals(consumerDAO.isConsumerSecretExist(CLIENT_ID, SECRET), true);
}
}
use of org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuthConsumerDAOTest method testGetRequestToken.
@Test
public void testGetRequestToken() throws Exception {
mockStatic(OAuthServerConfiguration.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(mockedServerConfig);
PlainTextPersistenceProcessor processor = new PlainTextPersistenceProcessor();
when(mockedServerConfig.getPersistenceProcessor()).thenReturn(processor);
whenNew(Parameters.class).withNoArguments().thenReturn(mockedParameters);
try (Connection connection3 = getConnection(DB_NAME)) {
mockStatic(IdentityDatabaseUtil.class);
when(IdentityDatabaseUtil.getDBConnection(false)).thenReturn(connection3);
OAuthConsumerDAO consumerDAO = new OAuthConsumerDAO();
assertEquals(consumerDAO.getRequestToken(REQ_TOKEN), mockedParameters);
}
}
use of org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuthConsumerDAOTest method testGetOAuthTokenSecret.
@Test(dataProvider = "provideTokens")
public void testGetOAuthTokenSecret(String token, Boolean isAccessToken, String expected) throws Exception {
mockStatic(OAuthServerConfiguration.class);
when(OAuthServerConfiguration.getInstance()).thenReturn(mockedServerConfig);
PlainTextPersistenceProcessor processor = new PlainTextPersistenceProcessor();
when(mockedServerConfig.getPersistenceProcessor()).thenReturn(processor);
try (Connection connection3 = getConnection(DB_NAME)) {
mockStatic(IdentityDatabaseUtil.class);
when(IdentityDatabaseUtil.getDBConnection(false)).thenReturn(connection3);
OAuthConsumerDAO consumerDAO = new OAuthConsumerDAO();
assertEquals(consumerDAO.getOAuthTokenSecret(token, isAccessToken), expected);
}
}
Aggregations