Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit files tests #43946

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

import java.io.File;
import java.time.Duration;
Expand Down Expand Up @@ -1579,6 +1581,33 @@ public void deleteFile() {
.assertResponseStatusCode(primaryDirectoryClient.deleteFileWithResponse(fileName, null, null), 202);
}

@Test
public void deleteFileLease() {
String fileName = "testCreateFile";
primaryDirectoryClient.create();
primaryDirectoryClient.createFile(fileName, 1024);
String leaseId = createLeaseClient(primaryDirectoryClient.getFileClient(fileName)).acquireLease();
ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
Response<Void> response
= primaryDirectoryClient.deleteFileWithResponse(fileName, requestConditions, null, null);
assertEquals(202, response.getStatusCode());
}

@Test
public void deleteFileLeaseFail() {
String fileName = "testCreateFile";
primaryDirectoryClient.create();
primaryDirectoryClient.createFile(fileName, 1024);
createLeaseClient(primaryDirectoryClient.getFileClient(fileName)).acquireLease();

ShareRequestConditions requestConditions
= new ShareRequestConditions().setLeaseId(testResourceNamer.randomUuid());
ShareStorageException exception = assertThrows(ShareStorageException.class, () -> {
primaryDirectoryClient.deleteFileWithResponse(fileName, requestConditions, null, null);
});
assertNotNull(exception);
}

@Test
public void deleteFileError() {
primaryDirectoryClient.create();
Expand Down Expand Up @@ -1607,6 +1636,34 @@ public void deleteIfExistsFile() {
.assertResponseStatusCode(primaryDirectoryClient.deleteFileIfExistsWithResponse(fileName, null, null), 202);
}

@Test
public void deleteIfExistsFileLease() {
String fileName = "testCreateFile";
primaryDirectoryClient.create();
primaryDirectoryClient.createFile(fileName, 1024);
String leaseId = createLeaseClient(primaryDirectoryClient.getFileClient(fileName)).acquireLease();
ShareRequestConditions requestConditions = new ShareRequestConditions().setLeaseId(leaseId);
Response<Boolean> response
= primaryDirectoryClient.deleteFileIfExistsWithResponse(fileName, requestConditions, null, null);
assertEquals(202, response.getStatusCode());
assertTrue(response.getValue());
}

@Test
public void deleteIfExistsFileLeaseFail() {
String fileName = "testCreateFile";
primaryDirectoryClient.create();
primaryDirectoryClient.createFile(fileName, 1024);
createLeaseClient(primaryDirectoryClient.getFileClient(fileName)).acquireLease();

ShareRequestConditions requestConditions
= new ShareRequestConditions().setLeaseId(testResourceNamer.randomUuid());
ShareStorageException exception = assertThrows(ShareStorageException.class, () -> {
primaryDirectoryClient.deleteFileIfExistsWithResponse(fileName, requestConditions, null, null);
});
assertNotNull(exception);
}

@Test
public void deleteIfExistsFileThatDoesNotExist() {
primaryDirectoryClient.create();
Expand Down
Loading
Loading