use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientNetworkIssueTest method testGetConfiguration.
@Test
public void testGetConfiguration() {
final AWSConfiguration awsConfiguration = AWSMobileClient.getInstance().getConfiguration();
assertNotNull(awsConfiguration.optJsonObject("CognitoUserPool"));
try {
assertEquals("us-west-2", awsConfiguration.optJsonObject("CognitoUserPool").getString("Region"));
} catch (JSONException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class AWSMobileClientOfflineTest method testGetConfiguration.
@Test
public void testGetConfiguration() throws JSONException {
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 AWSMobileClientAuthFlowSettingTest method initMobileClientAndWait.
private void initMobileClientAndWait(String authFlowType, CognitoUserPool mockUserPool) throws JSONException, InterruptedException {
JSONObject awsConfig = getAWSConfig(authFlowType);
mobileClient.initialize(getApplicationContext(), new AWSConfiguration(awsConfig), new Callback<UserStateDetails>() {
@Override
public void onResult(UserStateDetails result) {
mobileClient.setUserPool(mockUserPool);
Log.i(TAG, "Mobile client initialized. Mock user pool injected.");
initComplete.set(true);
initLatch.countDown();
}
@Override
public void onError(Exception exception) {
Log.e(TAG, "Mobile client failed to initialize.", exception);
initLatch.countDown();
}
});
initLatch.await(5, TimeUnit.SECONDS);
assertTrue(initComplete.get());
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class TransferUtilityTest method testLocalTestingUnset.
/**
* Tests that transfer utility correctly ignored local testing branch
* if local testing flag is not specified.
*
* @throws Exception
*/
@Test
public void testLocalTestingUnset() throws Exception {
final String jsonString = "{\n" + " \"S3TransferUtility\": {\n" + " \"Default\": {\n" + " \"Bucket\": \"name\",\n" + " \"Region\": \"us-east-1\"\n" + " }\n" + " }\n" + "}";
try {
JSONObject jsonConfig = new JSONObject(jsonString);
awsConfig = new AWSConfiguration(jsonConfig);
} catch (JSONException e) {
fail("Error in constructing AWSConfiguration." + e.getLocalizedMessage());
}
AWSCredentials creds = new BasicAWSCredentials("accessKey", "secretKey");
Region region = Region.getRegion(Regions.DEFAULT_REGION);
AmazonS3Client s3 = new AmazonS3Client(creds, region);
TransferUtility.builder().context(RuntimeEnvironment.application.getApplicationContext()).awsConfiguration(awsConfig).s3Client(s3).build();
assertNotEquals(s3.getEndpoint(), Constants.LOCAL_TESTING_ENDPOINT);
assertFalse(s3.clientOptions.isPathStyleAccess());
assertFalse(s3.clientOptions.isContentMd5CheckSkipped());
}
use of com.amazonaws.mobile.config.AWSConfiguration in project aws-sdk-android by aws-amplify.
the class TransferUtilityTest method testLocalTestingDisabled.
/**
* Tests that transfer utility correctly ignored local testing branch
* if local testing flag is set to false.
*
* @throws Exception
*/
@Test
public void testLocalTestingDisabled() throws Exception {
final String jsonString = "{\n" + " \"S3TransferUtility\": {\n" + " \"Default\": {\n" + " \"Bucket\": \"name\",\n" + " \"Region\": \"us-east-1\",\n" + " \"DangerouslyConnectToHTTPEndpointForTesting\": false\n" + " }\n" + " }\n" + "}";
try {
JSONObject jsonConfig = new JSONObject(jsonString);
awsConfig = new AWSConfiguration(jsonConfig);
} catch (JSONException e) {
fail("Error in constructing AWSConfiguration." + e.getLocalizedMessage());
}
AWSCredentials creds = new BasicAWSCredentials("accessKey", "secretKey");
Region region = Region.getRegion(Regions.DEFAULT_REGION);
AmazonS3Client s3 = new AmazonS3Client(creds, region);
TransferUtility.builder().context(RuntimeEnvironment.application.getApplicationContext()).awsConfiguration(awsConfig).s3Client(s3).build();
assertNotEquals(s3.getEndpoint(), Constants.LOCAL_TESTING_ENDPOINT);
assertFalse(s3.clientOptions.isPathStyleAccess());
assertFalse(s3.clientOptions.isContentMd5CheckSkipped());
}
Aggregations