use of com.amplifyframework.storage.result.StorageListResult in project amplify-android by aws-amplify.
the class AWSS3StorageListAccessLevelTest method testListDifferentUsersProtectedAccess.
/**
* Test listing files with protected access after signing in
* as another user.
*
* A protected resource is READ-ONLY to all users. List is
* allowed even if signed-in user does not own the resource.
*
* @throws Exception if list is unsuccessful
*/
@Test
public void testListDifferentUsersProtectedAccess() throws Exception {
mobileClient.signIn(userOne.getUsername(), userOne.getPassword());
listOptions = StorageListOptions.builder().accessLevel(StorageAccessLevel.PROTECTED).targetIdentityId(userTwo.getIdentityId()).build();
StorageListResult result = storage.list(TEST_DIR_NAME, listOptions);
assertListContainsUploadedFile(result);
}
use of com.amplifyframework.storage.result.StorageListResult in project amplify-android by aws-amplify.
the class AWSS3StorageListAccessLevelTest method testListAuthenticatedPrivateAccess.
/**
* Test listing files with private access after signing in.
*
* @throws Exception if list is unsuccessful
*/
@Test
public void testListAuthenticatedPrivateAccess() throws Exception {
mobileClient.signIn(userOne.getUsername(), userOne.getPassword());
listOptions = StorageListOptions.builder().accessLevel(StorageAccessLevel.PRIVATE).targetIdentityId(userOne.getIdentityId()).build();
StorageListResult result = storage.list(TEST_DIR_NAME, listOptions);
assertListContainsUploadedFile(result);
}
use of com.amplifyframework.storage.result.StorageListResult in project amplify-android by aws-amplify.
the class AWSS3StorageListAccessLevelTest method testListDifferentUsersPrivateAccess.
/**
* Test listing files with private access after signing in
* as another user.
*
* Private resources are only accessible to owners. This test
* will throw an exception.
*
* @throws Exception if list is unsuccessful
*/
@Test(expected = StorageException.class)
public void testListDifferentUsersPrivateAccess() throws Exception {
mobileClient.signIn(userOne.getUsername(), userTwo.getPassword());
listOptions = StorageListOptions.builder().accessLevel(StorageAccessLevel.PRIVATE).targetIdentityId(userTwo.getIdentityId()).build();
StorageListResult result = storage.list(TEST_DIR_NAME, listOptions);
assertListContainsUploadedFile(result);
}
use of com.amplifyframework.storage.result.StorageListResult in project amplify-android by aws-amplify.
the class StorageComponentTest method testListObject.
/**
* Test that calling list method from Storage category correctly
* invokes the registered AWSS3StoragePlugin instance and returns a
* {@link StorageListResult} with list of stored items.
*
* @throws StorageException when an error is encountered while listing
* files inside storage
*/
@Test
public void testListObject() throws StorageException {
final String path = RandomString.string();
final StorageItem item = new StorageItem(RandomString.string(), 0L, new Date(), RandomString.string(), null);
when(storageService.listFiles(anyString(), anyString())).thenReturn(Collections.singletonList(item));
StorageListResult result = Await.<StorageListResult, StorageException>result((onResult, onError) -> storage.list(path, onResult, onError));
assertEquals(item, result.getItems().get(0));
}
Aggregations