-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow configuring endpoint for Azure FS
- Loading branch information
Showing
7 changed files
with
83 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,18 +26,23 @@ class TestAzureLocation | |
@Test | ||
void test() | ||
{ | ||
assertValid("abfs://[email protected]/some/path/file", "account", "container", "some/path/file"); | ||
assertValid("abfss://[email protected]/some/path/file", "account", "container", "some/path/file", "abfss"); | ||
assertValid("abfs://[email protected]/some/path/file", "account", "container", "some/path/file", "abfs", "core.windows.net"); | ||
assertValid("abfss://[email protected]/some/path/file", "account", "container", "some/path/file", "abfss", "core.windows.net"); | ||
|
||
assertValid("abfs://[email protected]/some/path/file", "account", "container-stuff", "some/path/file"); | ||
assertValid("abfs://[email protected]/some/path/file", "account", "container2", "some/path/file"); | ||
assertValid("abfs://account.dfs.core.windows.net/some/path/file", "account", null, "some/path/file"); | ||
assertValid("abfs://[email protected]/some/path/file", "account", "container-stuff", "some/path/file", "abfs", "core.windows.net"); | ||
assertValid("abfs://[email protected]/some/path/file", "account", "container2", "some/path/file", "abfs", "core.windows.net"); | ||
assertValid("abfs://account.dfs.core.windows.net/some/path/file", "account", null, "some/path/file", "abfs", "core.windows.net"); | ||
|
||
assertValid("abfs://[email protected]/file", "account", "container", "file"); | ||
assertValid("abfs://[email protected]///f///i///l///e///", "account0", "container", "//f///i///l///e///"); | ||
assertValid("abfs://[email protected]/file", "account", "container", "file", "abfs", "core.windows.net"); | ||
assertValid("abfs://[email protected]///f///i///l///e///", "account0", "container", "//f///i///l///e///", "abfs", "core.windows.net"); | ||
|
||
// other endpoints are allowed | ||
assertValid("abfs://[email protected]/some/path/file", "account", "container", "some/path/file", "abfs", "core.usgovcloudapi.net"); | ||
assertValid("abfss://[email protected]/some/path/file", "account", "container", "some/path/file", "abfss", "core.usgovcloudapi.net"); | ||
|
||
// only abfs and abfss schemes allowed | ||
assertInvalid("https://[email protected]/some/path/file"); | ||
|
||
// host must have at least to labels | ||
assertInvalid("abfs://container@account/some/path/file"); | ||
assertInvalid("abfs://container@/some/path/file"); | ||
|
@@ -54,32 +59,29 @@ void test() | |
assertInvalid("abfs://[email protected]/some/path/file"); | ||
assertInvalid("abfs://[email protected]/some/path/file"); | ||
assertInvalid("abfs://[email protected]/some/path/file"); | ||
|
||
// account is only a-z and 0-9 | ||
assertInvalid("abfs://[email protected]/some/path/file"); | ||
assertInvalid("abfs://container@ac_count.dfs.core.windows.net/some/path/file"); | ||
assertInvalid("abfs://container@ac$count.dfs.core.windows.net/some/path/file"); | ||
// host must end with .dfs.core.windows.net | ||
|
||
// host must contain .dfs. after account | ||
assertInvalid("abfs://[email protected]/some/path/file"); | ||
// host must be just account.dfs.core.windows.net | ||
assertInvalid("abfs://[email protected]/some/path/file"); | ||
} | ||
|
||
private static void assertValid(String uri, String expectedAccount, String expectedContainer, String expectedPath, String expectedScheme) | ||
private static void assertValid(String uri, String expectedAccount, String expectedContainer, String expectedPath, String expectedScheme, String expectedEndpoint) | ||
{ | ||
Location location = Location.of(uri); | ||
AzureLocation azureLocation = new AzureLocation(location); | ||
assertThat(azureLocation.location()).isEqualTo(location); | ||
assertThat(azureLocation.account()).isEqualTo(expectedAccount); | ||
assertThat(azureLocation.endpoint()).isEqualTo(expectedEndpoint); | ||
assertThat(azureLocation.container()).isEqualTo(Optional.ofNullable(expectedContainer)); | ||
assertThat(azureLocation.path()).contains(expectedPath); | ||
assertThat(azureLocation.baseLocation().scheme()).isEqualTo(Optional.of(expectedScheme)); | ||
} | ||
|
||
private static void assertValid(String uri, String expectedAccount, String expectedContainer, String expectedPath) | ||
{ | ||
assertValid(uri, expectedAccount, expectedContainer, expectedPath, "abfs"); | ||
} | ||
|
||
private static void assertInvalid(String uri) | ||
{ | ||
Location location = Location.of(uri); | ||
|