Search in sources :

Example 11 with BasicAPIKeyAuthProvider

use of com.amazonaws.mobileconnectors.appsync.sigv4.BasicAPIKeyAuthProvider in project aws-mobile-appsync-sdk-android by awslabs.

the class MultiClientInstrumentationTest method testCodeHasInvalidClientDatabasePrefix.

@Test
public void testCodeHasInvalidClientDatabasePrefix() {
    AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
    JSONObject appSyncConfig = awsConfiguration.optJsonObject("AppSync");
    RuntimeException exception = assertThrows(RuntimeException.class, () -> AWSAppSyncClient.builder().context(getTargetContext()).apiKey(new BasicAPIKeyAuthProvider(appSyncConfig.getString("ApiKey"))).serverUrl(appSyncConfig.getString("ApiUrl")).region(Regions.fromName(appSyncConfig.getString("Region"))).useClientDatabasePrefix(true).clientDatabasePrefix(// This is the problem!!
    "MultiAuthAndroidIntegTestApp_!@#$%^&*()").build());
    String expected = "ClientDatabasePrefix validation failed. Please pass in characters " + "that matches the pattern: ^[_a-zA-Z0-9]+$";
    assertTrue(exception.getLocalizedMessage().startsWith(expected));
}
Also used : JSONObject(org.json.JSONObject) AWSConfiguration(com.amazonaws.mobile.config.AWSConfiguration) BasicAPIKeyAuthProvider(com.amazonaws.mobileconnectors.appsync.sigv4.BasicAPIKeyAuthProvider) Test(org.junit.Test)

Aggregations

BasicAPIKeyAuthProvider (com.amazonaws.mobileconnectors.appsync.sigv4.BasicAPIKeyAuthProvider)11 Test (org.junit.Test)11 AWSConfiguration (com.amazonaws.mobile.config.AWSConfiguration)9 JSONObject (org.json.JSONObject)9 AWSAppSyncClient (com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient)3 APIKeyAuthProvider (com.amazonaws.mobileconnectors.appsync.sigv4.APIKeyAuthProvider)2 BasicCognitoUserPoolsAuthProvider (com.amazonaws.mobileconnectors.appsync.sigv4.BasicCognitoUserPoolsAuthProvider)2 CognitoUserPool (com.amazonaws.mobileconnectors.cognitoidentityprovider.CognitoUserPool)2 AWSAppSyncClientException (com.amazonaws.mobileconnectors.appsync.AWSAppSyncClientException)1 ClearCacheException (com.amazonaws.mobileconnectors.appsync.ClearCacheException)1 JSONException (org.json.JSONException)1