-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Avoid rooting URIs (issues when working with Minio on localhost) 2. Use special version of URI encoder 3. Support continuation tokens in listing bucket objects
- Loading branch information
Showing
14 changed files
with
992 additions
and
820 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,105 @@ | ||
using Xunit; | ||
|
||
namespace Stowage.Test | ||
{ | ||
public class IOPathTest | ||
{ | ||
[Theory] | ||
[InlineData("/dev/one", new[] { "dev", "one" })] | ||
[InlineData("/one/two/three", new[] { "one", "two", "three" })] | ||
[InlineData("/three", new[] { "one", "..", "three" })] | ||
[InlineData("/dev/one/", new[] { "dev", "one/" })] | ||
public void Combine_theory(string expected, string[] parts) | ||
{ | ||
Assert.Equal(expected, IOPath.Combine(parts)); | ||
} | ||
namespace Stowage.Test { | ||
public class IOPathTest { | ||
[Theory] | ||
[InlineData("/dev/one", new[] { "dev", "one" })] | ||
[InlineData("/one/two/three", new[] { "one", "two", "three" })] | ||
[InlineData("/three", new[] { "one", "..", "three" })] | ||
[InlineData("/dev/one/", new[] { "dev", "one/" })] | ||
public void Combine_theory(string expected, string[] parts) { | ||
Assert.Equal(expected, IOPath.Combine(parts)); | ||
} | ||
|
||
[Theory] | ||
[InlineData(new[] { "one", "two" }, "one/two")] | ||
[InlineData(new[] { "one", "two" }, "/one/two")] | ||
[InlineData(new[] { "one", "two/" }, "one/two/")] | ||
[InlineData(new[] { "one", "two/" }, "/one/two/")] | ||
public void Split_theory(string[] expected, string input) | ||
{ | ||
Assert.Equal(expected, IOPath.Split(input)); | ||
} | ||
[Theory] | ||
[InlineData("file", "container", "/container/file")] | ||
[InlineData("file/", "container", "/container/file/")] | ||
[InlineData("/", "container", "/container/")] | ||
public void Prefix_theory(string path, string prefix, string expected) { | ||
IOPath pathPath = path; | ||
IOPath prefixPath = prefix; | ||
Assert.Equal(expected, pathPath.Prefix(prefixPath).Full); | ||
} | ||
|
||
[Theory] | ||
[InlineData("dev/..", "/")] | ||
[InlineData("dev/../storage", "/storage")] | ||
[InlineData("/one", "/one")] | ||
[InlineData("/one/", "/one/")] | ||
[InlineData("/one/../../../..", "/")] | ||
public void Normalize_theory(string path, string expected) | ||
{ | ||
Assert.Equal(expected, IOPath.Normalize(path)); | ||
} | ||
[Theory] | ||
[InlineData(new[] { "one", "two" }, "one/two")] | ||
[InlineData(new[] { "one", "two" }, "/one/two")] | ||
[InlineData(new[] { "one", "two/" }, "one/two/")] | ||
[InlineData(new[] { "one", "two/" }, "/one/two/")] | ||
public void Split_theory(string[] expected, string input) { | ||
Assert.Equal(expected, IOPath.Split(input)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("dev1", "/dev1/")] | ||
public void Normalize_trailing_theory(string path, string expected) | ||
{ | ||
Assert.Equal(expected, IOPath.Normalize(path, appendTrailingSlash: true)); | ||
} | ||
[Theory] | ||
[InlineData("dev/..", "/")] | ||
[InlineData("dev/../storage", "/storage")] | ||
[InlineData("/one", "/one")] | ||
[InlineData("/one/", "/one/")] | ||
[InlineData("/one/../../../..", "/")] | ||
public void Normalize_theory(string path, string expected) { | ||
Assert.Equal(expected, IOPath.Normalize(path)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("one/two/three", "/one/two/")] | ||
[InlineData("one/two", "/one/")] | ||
[InlineData("one/../two/three", "/two/")] | ||
[InlineData("one/../two/three/four/..", "/two/")] | ||
public void Get_parent_theory(string path, string expected) | ||
{ | ||
Assert.Equal(expected, IOPath.GetParent(path)); | ||
} | ||
[Theory] | ||
[InlineData("dev1", "/dev1/")] | ||
public void Normalize_trailing_theory(string path, string expected) { | ||
Assert.Equal(expected, IOPath.Normalize(path, appendTrailingSlash: true)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("/one/two", "/one", "/two")] | ||
[InlineData("/one/two/", "/one", "/two/")] | ||
[InlineData("/one/two", "one", "/two")] | ||
[InlineData("/one/two", "/", "/one/two")] | ||
[InlineData("/one/two", "x", "/")] | ||
[InlineData("/one/two", "/1/2/3/4", "/")] | ||
[InlineData("/one/two", null, "/")] | ||
[InlineData(null, null, "/")] | ||
[InlineData(null, "/", "/")] | ||
public void Relative_theory(string path, string relativeTo, string expected) | ||
{ | ||
Assert.Equal(expected, IOPath.RelativeTo(path, relativeTo)); | ||
} | ||
[Theory] | ||
[InlineData("one/two/three", "/one/two/")] | ||
[InlineData("one/two", "/one/")] | ||
[InlineData("one/../two/three", "/two/")] | ||
[InlineData("one/../two/three/four/..", "/two/")] | ||
public void Get_parent_theory(string path, string expected) { | ||
Assert.Equal(expected, IOPath.GetParent(path)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("/", null, true)] | ||
[InlineData(null, "/", true)] | ||
[InlineData("/", "", true)] | ||
[InlineData("/path1", "path1", true)] | ||
public void Compare_theory(string path1, string path2, bool expected) | ||
{ | ||
Assert.Equal(expected, IOPath.Compare(path1, path2)); | ||
} | ||
[Theory] | ||
[InlineData("/one/two", "/one", "/two")] | ||
[InlineData("/one/two/", "/one", "/two/")] | ||
[InlineData("/one/two", "one", "/two")] | ||
[InlineData("/one/two", "/", "/one/two")] | ||
[InlineData("/one/two", "x", "/")] | ||
[InlineData("/one/two", "/1/2/3/4", "/")] | ||
[InlineData("/one/two", null, "/")] | ||
[InlineData(null, null, "/")] | ||
[InlineData(null, "/", "/")] | ||
public void Relative_theory(string path, string relativeTo, string expected) { | ||
Assert.Equal(expected, IOPath.RelativeTo(path, relativeTo)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("/one/", "/one/")] | ||
[InlineData("/one", "/one/")] | ||
[InlineData("one/", "/one/")] | ||
public void WTS_theory(string input, string expected) | ||
{ | ||
Assert.Equal(expected, new IOPath(input).WTS); | ||
} | ||
[Theory] | ||
[InlineData("/", null, true)] | ||
[InlineData(null, "/", true)] | ||
[InlineData("/", "", true)] | ||
[InlineData("/path1", "path1", true)] | ||
public void Compare_theory(string path1, string path2, bool expected) { | ||
Assert.Equal(expected, IOPath.Compare(path1, path2)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("/one/", "one/")] | ||
[InlineData("/one", "one")] | ||
[InlineData("one/", "one/")] | ||
public void NLS_theory(string input, string expected) | ||
{ | ||
Assert.Equal(expected, new IOPath(input).NLS); | ||
} | ||
[Theory] | ||
[InlineData("/one/", "/one/")] | ||
[InlineData("/one", "/one/")] | ||
[InlineData("one/", "/one/")] | ||
public void WTS_theory(string input, string expected) { | ||
Assert.Equal(expected, new IOPath(input).WTS); | ||
} | ||
|
||
[Theory] | ||
[InlineData("/one/", "one/")] | ||
[InlineData("/one", "one/")] | ||
[InlineData("one/", "one/")] | ||
public void NLWTS_theory(string input, string expected) | ||
{ | ||
Assert.Equal(expected, new IOPath(input).NLWTS); | ||
} | ||
} | ||
} | ||
[Theory] | ||
[InlineData("/one/", "one/")] | ||
[InlineData("/one", "one")] | ||
[InlineData("one/", "one/")] | ||
public void NLS_theory(string input, string expected) { | ||
Assert.Equal(expected, new IOPath(input).NLS); | ||
} | ||
|
||
[Theory] | ||
[InlineData("/one/", "one/")] | ||
[InlineData("/one", "one/")] | ||
[InlineData("one/", "one/")] | ||
public void NLWTS_theory(string input, string expected) { | ||
Assert.Equal(expected, new IOPath(input).NLWTS); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,29 +1,33 @@ | ||
using System; | ||
|
||
namespace Stowage.Test | ||
{ | ||
public interface ITestSettings | ||
{ | ||
string AzureStorageAccount { get; } | ||
namespace Stowage.Test { | ||
public interface ITestSettings { | ||
string AzureStorageAccount { get; } | ||
|
||
string AzureStorageKey { get; } | ||
string AzureStorageKey { get; } | ||
|
||
string AzureContainerName { get; } | ||
string AzureContainerName { get; } | ||
|
||
string AwsBucket { get; } | ||
string AwsBucket { get; } | ||
|
||
string AwsKey { get; } | ||
string AwsKey { get; } | ||
|
||
string AwsSecret { get; } | ||
string AwsSecret { get; } | ||
|
||
string AwsRegion { get; } | ||
string AwsRegion { get; } | ||
|
||
string GcpBucket { get; } | ||
Uri MinioEndpoint { get; } | ||
|
||
string GcpCred { get; } | ||
string MinioKey { get; } | ||
|
||
Uri DatabricksBaseUri { get; } | ||
string MinioSecret { get; } | ||
|
||
string DatabricksToken { get; } | ||
} | ||
} | ||
string GcpBucket { get; } | ||
|
||
string GcpCred { get; } | ||
|
||
Uri DatabricksBaseUri { get; } | ||
|
||
string DatabricksToken { get; } | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Stowage { | ||
static class Extensions { | ||
public static string GetAbsolutePathUnencoded(this Uri uri) { | ||
string result = uri.ToString(); | ||
|
||
// remove protocol | ||
int i = result.IndexOf("://"); | ||
if(i >= 0) | ||
result = result.Substring(i + 3); | ||
|
||
// remove host and port | ||
i = result.IndexOf('/'); | ||
if(i >= 0) | ||
result = result.Substring(i); | ||
|
||
// remove query string | ||
i = result.IndexOf('?'); | ||
if(i >= 0) | ||
result = result.Substring(0, i); | ||
|
||
return result; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.