Skip to content

Commit

Permalink
Adding tests for encoded file names for file shares (#38451)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimrabab authored Jan 25, 2024
1 parent ee06062 commit d7178c3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-share/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/storage/azure-storage-file-share",
"Tag": "java/storage/azure-storage-file-share_47012b0179"
"Tag": "java/storage/azure-storage-file-share_f461f13849"
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,25 @@ public void getFileClient() {
assertInstanceOf(ShareFileClient.class, fileClient);
}

private static Stream<Arguments> getNonEncodedFileNameSupplier() {
return Stream.of(
Arguments.of("test%test"),
Arguments.of("%Россия 한국 中国!"),
Arguments.of("%E6%96%91%E9%BB%9E"),
Arguments.of("斑點")
);
}

@ParameterizedTest
@MethodSource("getNonEncodedFileNameSupplier")
public void getNonEncodedFileName(String fileName) {
primaryDirectoryClient.create();
ShareFileClient fileClient = primaryDirectoryClient.getFileClient(fileName);
assertEquals(primaryDirectoryClient.getDirectoryPath() + "/" + fileName, fileClient.getFilePath());
fileClient.create(1024);
assertTrue(fileClient.exists());
}

@Test
public void exists() {
primaryDirectoryClient.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,24 @@ public void getFilePath() {
assertEquals(filePath, primaryFileClient.getFilePath());
}

private static Stream<Arguments> getNonEncodedFileNameSupplier() {
return Stream.of(
Arguments.of("test%test"),
Arguments.of("%Россия 한국 中国!"),
Arguments.of("%E6%96%91%E9%BB%9E"),
Arguments.of("斑點")
);
}

@ParameterizedTest
@MethodSource("getNonEncodedFileNameSupplier")
public void getNonEncodedFileName(String fileName) {
ShareFileClient fileClient = shareClient.getFileClient(fileName);
assertEquals(fileName, fileClient.getFilePath());
fileClient.create(1024);
assertTrue(fileClient.exists());
}

// This tests the policy is in the right place because if it were added per retry, it would be after the credentials
// and auth would fail because we changed a signed header.
public void perCallPolicy() {
Expand Down

0 comments on commit d7178c3

Please sign in to comment.