use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientNetworkIssueTest method useAppContext.
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = ApplicationProvider.getApplicationContext();
final AWSConfiguration awsConfiguration = new AWSConfiguration(appContext);
assertNotNull(awsConfiguration.optJsonObject("CognitoUserPool"));
assertEquals("us-west-2", awsConfiguration.optJsonObject("CognitoUserPool").getString("Region"));
assertEquals("com.amazonaws.mobile.client.test", appContext.getPackageName());
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientNetworkIssueTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
Context appContext = ApplicationProvider.getApplicationContext();
// Initialize
final CountDownLatch latch = new CountDownLatch(1);
AWSMobileClient.getInstance().initialize(appContext, new Callback<UserStateDetails>() {
@Override
public void onResult(UserStateDetails result) {
latch.countDown();
}
@Override
public void onError(Exception e) {
latch.countDown();
}
});
latch.await();
final AWSConfiguration awsConfiguration = new AWSConfiguration(appContext);
JSONObject userPoolConfig = awsConfiguration.optJsonObject("CognitoUserPool");
assertNotNull(userPoolConfig);
JSONObject identityPoolConfig = awsConfiguration.optJsonObject("CredentialsProvider").getJSONObject("CognitoIdentity").getJSONObject("Default");
assertNotNull(identityPoolConfig);
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientOfflineTest method beforeSuite.
@BeforeClass
public static void beforeSuite() throws Exception {
goOffline();
CountDownLatch latch = new CountDownLatch(1);
auth = AWSMobileClient.getInstance();
AWSConfiguration config = new AWSConfiguration(getApplicationContext(), R.raw.fakeawsconfiguration);
auth.initialize(getApplicationContext(), config, new Callback<UserStateDetails>() {
@Override
public void onResult(UserStateDetails result) {
latch.countDown();
}
@Override
public void onError(Exception e) {
latch.countDown();
}
});
latch.await();
AWSConfiguration awsConfiguration = auth.getConfiguration();
JSONObject userPoolConfig = awsConfiguration.optJsonObject("CognitoUserPool");
assertNotNull(userPoolConfig);
assertEquals("us-west-2", userPoolConfig.getString("Region"));
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientOfflineTest method useAppContext.
@Test
public void useAppContext() throws JSONException {
AWSConfiguration awsConfiguration = new AWSConfiguration(getApplicationContext(), R.raw.fakeawsconfiguration);
JSONObject userPoolConfig = awsConfiguration.optJsonObject("CognitoUserPool");
assertNotNull(userPoolConfig);
assertEquals("us-west-2", userPoolConfig.getString("Region"));
assertEquals("com.amazonaws.mobile.client.test", getApplicationContext().getPackageName());
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientPersistenceTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
setUpCredentials();
Context appContext = ApplicationProvider.getApplicationContext();
final CountDownLatch latch = new CountDownLatch(1);
AWSMobileClient.getInstance().initialize(appContext, new Callback<UserStateDetails>() {
@Override
public void onResult(UserStateDetails result) {
latch.countDown();
}
@Override
public void onError(Exception e) {
latch.countDown();
}
});
latch.await();
final AWSConfiguration awsConfiguration = AWSMobileClient.getInstance().getConfiguration();
JSONObject userPoolConfig = awsConfiguration.optJsonObject("CognitoUserPool");
assertNotNull(userPoolConfig);
clientRegion = Regions.fromName(userPoolConfig.getString("Region"));
userPoolId = userPoolConfig.getString("PoolId");
JSONObject identityPoolConfig = awsConfiguration.optJsonObject("CredentialsProvider").getJSONObject("CognitoIdentity").getJSONObject("Default");
assertNotNull(identityPoolConfig);
deleteAllUsers(userPoolId);
}
Aggregations