use of com.amplifyframework.storage.result.StorageListResult in project amplify-android by aws-amplify.
the class RxStorageBindingTest method listReturnsResult.
/**
* When {@link StorageCategoryBehavior#list(String, Consumer, Consumer)} emits a result,
* then the {@link Single} returned by {@link RxStorageCategoryBehavior#list(String)}
* should emit an {@link StorageListResult}.
*/
@Test
public void listReturnsResult() {
StorageListResult result = StorageListResult.fromItems(Collections.emptyList());
doAnswer(invocation -> {
// 0 localPath, 1 onResult, 2 onError
final int indexOfResultConsumer = 1;
Consumer<StorageListResult> resultConsumer = invocation.getArgument(indexOfResultConsumer);
resultConsumer.accept(result);
return mock(StorageListOperation.class);
}).when(delegate).list(eq(remoteKey), anyConsumer(), anyConsumer());
rxStorage.list(remoteKey).test().assertValues(result);
}
use of com.amplifyframework.storage.result.StorageListResult in project amplify-android by aws-amplify.
the class AWSS3StorageListAccessLevelTest method testListUnauthenticatedProtectedAccess.
/**
* Test listing files with protected access without signing in.
*
* A protected resource is READ-ONLY to guest users. List is
* allowed even without authentication.
*
* @throws Exception if list is unsuccessful
*/
@Test
public void testListUnauthenticatedProtectedAccess() throws Exception {
listOptions = StorageListOptions.builder().accessLevel(StorageAccessLevel.PROTECTED).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 testListUnauthenticatedPrivateAccess.
/**
* Test listing files with private access without signing in.
*
* A user cannot list any private access file without proper
* authentication. 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 testListUnauthenticatedPrivateAccess() throws Exception {
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 testListUnauthenticatedPublicAccess.
/**
* Test listing files with public access without signing in.
*
* @throws Exception if list is unsuccessful
*/
@Test
public void testListUnauthenticatedPublicAccess() throws Exception {
listOptions = StorageListOptions.builder().accessLevel(StorageAccessLevel.PUBLIC).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 testListAuthenticatedProtectedAccess.
/**
* Test listing files with protected access after signing in.
*
* @throws Exception if list is unsuccessful
*/
@Test
public void testListAuthenticatedProtectedAccess() throws Exception {
mobileClient.signIn(userOne.getUsername(), userOne.getPassword());
listOptions = StorageListOptions.builder().accessLevel(StorageAccessLevel.PROTECTED).targetIdentityId(userOne.getIdentityId()).build();
StorageListResult result = storage.list(TEST_DIR_NAME, listOptions);
assertListContainsUploadedFile(result);
}
Aggregations