Search in sources :

Example 1 with Credential

use of com.amplifyframework.storage.s3.UserCredentials.Credential in project amplify-android by aws-amplify.

the class AWSS3StorageListAccessLevelTest method setUpOnce.

/**
 * Upload the required resources in cloud prior to running the tests.
 * @throws Exception from failure to sign in with Cognito User Pools
 */
@BeforeClass
public static void setUpOnce() throws Exception {
    Context context = getApplicationContext();
    // Init auth stuff
    mobileClient = SynchronousMobileClient.instance();
    mobileClient.initialize();
    IdentityIdSource identityIdSource = MobileClientIdentityIdSource.create(mobileClient);
    UserCredentials credentials = UserCredentials.create(context, identityIdSource);
    Iterator<Credential> users = credentials.iterator();
    userOne = users.next();
    userTwo = users.next();
    // Get a handle to storage
    StorageCategory asyncDelegate = TestStorageCategory.create(context, R.raw.amplifyconfiguration);
    storage = SynchronousStorage.delegatingTo(asyncDelegate);
    // Upload test file in S3 ahead of time
    uploadTestFiles();
}
Also used : Context(android.content.Context) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) Credential(com.amplifyframework.storage.s3.UserCredentials.Credential) IdentityIdSource(com.amplifyframework.storage.s3.UserCredentials.IdentityIdSource) StorageCategory(com.amplifyframework.storage.StorageCategory) BeforeClass(org.junit.BeforeClass)

Example 2 with Credential

use of com.amplifyframework.storage.s3.UserCredentials.Credential in project amplify-android by aws-amplify.

the class AWSS3StorageDownloadAccessLevelTest method setUpOnce.

/**
 * Upload the required resources in cloud prior to running the tests.
 * @throws Exception from failure to sign in with Cognito User Pools
 */
@BeforeClass
public static void setUpOnce() throws Exception {
    Context context = getApplicationContext();
    mobileClient = SynchronousMobileClient.instance();
    mobileClient.initialize();
    IdentityIdSource identityIdSource = MobileClientIdentityIdSource.create(mobileClient);
    UserCredentials userCredentials = UserCredentials.create(context, identityIdSource);
    Iterator<Credential> users = userCredentials.iterator();
    userOne = users.next();
    userTwo = users.next();
    StorageCategory asyncDelegate = TestStorageCategory.create(context, R.raw.amplifyconfiguration);
    storage = SynchronousStorage.delegatingTo(asyncDelegate);
    // Upload test file in S3 ahead of time
    uploadTestFile();
}
Also used : Context(android.content.Context) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) Credential(com.amplifyframework.storage.s3.UserCredentials.Credential) IdentityIdSource(com.amplifyframework.storage.s3.UserCredentials.IdentityIdSource) StorageCategory(com.amplifyframework.storage.StorageCategory) BeforeClass(org.junit.BeforeClass)

Example 3 with Credential

use of com.amplifyframework.storage.s3.UserCredentials.Credential in project amplify-android by aws-amplify.

the class AWSS3StorageUploadAccessLevelTest method setUpOnce.

/**
 * Obtain the user IDs prior to running the tests.
 * @throws MobileClientException On failure to initialize mobile client
 */
@BeforeClass
public static void setUpOnce() throws MobileClientException {
    Context context = getApplicationContext();
    // Initialize identity. Bundle username, password, Identity Id up into a UserCredentials.
    mobileClient = SynchronousMobileClient.instance();
    mobileClient.initialize();
    IdentityIdSource identityIdSource = MobileClientIdentityIdSource.create(mobileClient);
    UserCredentials userCredentials = UserCredentials.create(context, identityIdSource);
    Iterator<Credential> iterator = userCredentials.iterator();
    userOne = iterator.next();
    userTwo = iterator.next();
    // Setup storage.
    StorageCategory asyncDelegate = TestStorageCategory.create(context, R.raw.amplifyconfiguration);
    storage = SynchronousStorage.delegatingTo(asyncDelegate);
}
Also used : Context(android.content.Context) ApplicationProvider.getApplicationContext(androidx.test.core.app.ApplicationProvider.getApplicationContext) Credential(com.amplifyframework.storage.s3.UserCredentials.Credential) IdentityIdSource(com.amplifyframework.storage.s3.UserCredentials.IdentityIdSource) StorageCategory(com.amplifyframework.storage.StorageCategory) BeforeClass(org.junit.BeforeClass)

Aggregations

Context (android.content.Context)3 ApplicationProvider.getApplicationContext (androidx.test.core.app.ApplicationProvider.getApplicationContext)3 StorageCategory (com.amplifyframework.storage.StorageCategory)3 Credential (com.amplifyframework.storage.s3.UserCredentials.Credential)3 IdentityIdSource (com.amplifyframework.storage.s3.UserCredentials.IdentityIdSource)3 BeforeClass (org.junit.BeforeClass)3