use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-mobile-appsync-sdk-android by awslabs.
the class AppSyncClientUnitTest method testConfigMismatch_AmazonCognitoUserPools.
@Test(expected = RuntimeException.class)
public void testConfigMismatch_AmazonCognitoUserPools() {
awsConfiguration.setConfiguration("ApiKey");
APIKeyAuthProvider apiKeyAuthProvider = new BasicAPIKeyAuthProvider(awsConfiguration);
awsConfiguration.setConfiguration("AmazonCognitoUserPools");
CognitoUserPool cognitoUserPool = new CognitoUserPool(shadowContext, awsConfiguration);
BasicCognitoUserPoolsAuthProvider basicCognitoUserPoolsAuthProvider = new BasicCognitoUserPoolsAuthProvider(cognitoUserPool);
final AWSAppSyncClient awsAppSyncClient = AWSAppSyncClient.builder().context(shadowContext).awsConfiguration(awsConfiguration).apiKey(apiKeyAuthProvider).build();
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-mobile-appsync-sdk-android by awslabs.
the class AppSyncClientUnitTest method testAmazonCognitoUserPoolsAuthProvider.
@Test
public void testAmazonCognitoUserPoolsAuthProvider() {
awsConfiguration.setConfiguration("AmazonCognitoUserPools");
CognitoUserPool cognitoUserPool = new CognitoUserPool(shadowContext, awsConfiguration);
BasicCognitoUserPoolsAuthProvider basicCognitoUserPoolsAuthProvider = new BasicCognitoUserPoolsAuthProvider(cognitoUserPool);
final AWSAppSyncClient awsAppSyncClient = AWSAppSyncClient.builder().context(shadowContext).awsConfiguration(awsConfiguration).cognitoUserPoolsAuthProvider(basicCognitoUserPoolsAuthProvider).build();
assertNotNull(awsAppSyncClient);
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class AWSMobileClientAuthFlowSettingTest method verifyScenario.
/**
* Verify that the correct auth type (aka challenge name) is passed in based on the
* auth flow type from the config file.
* @param configAuthFlowType The auth flow type from the config.
* @param expectedAuthType The auth type expected.
* @param overridenAuthFlowType The authType passed to the API
* @throws JSONException Not expected.
* @throws InterruptedException Not expected.
*/
private void verifyScenario(String configAuthFlowType, String overridenAuthFlowType, String expectedAuthType) throws JSONException, InterruptedException {
AuthenticationContinuation mockContinuation = setupMockContinuation();
CognitoUserPool mockUserPool = setupMockUserPool(mockContinuation);
initMobileClientAndWait(configAuthFlowType, mockUserPool);
signinAndWait(overridenAuthFlowType);
ArgumentCaptor<AuthenticationDetails> argumentCaptor = ArgumentCaptor.forClass(AuthenticationDetails.class);
verify(mockContinuation).setAuthenticationDetails(argumentCaptor.capture());
AuthenticationDetails actualAuthDetails = argumentCaptor.getValue();
assertEquals(expectedAuthType, actualAuthDetails.getAuthenticationType());
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class AWSMobileClientAuthFlowSettingTest method setupMockUserPool.
private CognitoUserPool setupMockUserPool(AuthenticationContinuation mockContinuation) {
CognitoUserPool mockUserPool = mock(CognitoUserPool.class);
CognitoUser mockUser = mock(CognitoUser.class);
doAnswer(invocation -> {
int indexOfHandler = 1;
AuthenticationHandler handler = invocation.getArgument(indexOfHandler, AuthenticationHandler.class);
handler.getAuthenticationDetails(mockContinuation, "FAKE_USER_ID");
return null;
}).when(mockUser).getSession(any(), any());
when(mockUserPool.getUser(anyString())).thenReturn(mockUser);
return mockUserPool;
}
use of com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool in project aws-sdk-android by aws-amplify.
the class SignUpActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
signUpView = (SignUpView) findViewById(R.id.signup_view);
Context appContext = getApplicationContext();
mUserPool = new CognitoUserPool(appContext, new AWSConfiguration(appContext));
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
Aggregations