-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #189 - Update utils authority package to handle proper encoding…
…/decoding of uri with reserved characters.
- Loading branch information
Showing
13 changed files
with
210 additions
and
154 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1125,6 +1125,12 @@ func (ts *fileTestSuite) TestPath() { | |
func (ts *fileTestSuite) TestURI() { | ||
expected := "ftp://[email protected]:22/some/path/to/file.txt" | ||
ts.Equal(expected, ts.testFile.URI(), "URI test") | ||
|
||
expected = "ftp://domain.com%[email protected]:22/some/path/to/file.txt" | ||
fs := NewFileSystem() | ||
f, err := fs.NewFile("domain.com%[email protected]:22", "/some/path/to/file.txt") | ||
ts.NoError(err) | ||
ts.Equal(expected, f.URI(), "URI test") | ||
} | ||
|
||
func (ts *fileTestSuite) TestStringer() { | ||
|
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 |
---|---|---|
|
@@ -322,6 +322,16 @@ func (lt *locationTestSuite) TestURI() { | |
file, err := lt.ftpfs.NewFile(authority, "/blah/file.txt") | ||
lt.NoError(err) | ||
lt.Equal("ftp://[email protected]/blah/file.txt", file.URI(), "file uri with user, pass, host") | ||
|
||
authority = `domain.com\[email protected]` | ||
file, err = lt.ftpfs.NewFile(authority, "/blah/file.txt") | ||
lt.Error(err) | ||
lt.ErrorContains(err, "net/url: invalid userinfo", "file uri with bad user") | ||
|
||
authority = `domain.com%[email protected]` | ||
file, err = lt.ftpfs.NewFile(authority, "/blah/file.txt") | ||
lt.NoError(err) | ||
lt.Equal(`ftp://domain.com%[email protected]/blah/file.txt`, file.URI(), "file uri with percent-encoded character in user") | ||
} | ||
|
||
func (lt *locationTestSuite) TestString() { | ||
|
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 |
---|---|---|
|
@@ -835,6 +835,12 @@ func (ts *fileTestSuite) TestPath() { | |
func (ts *fileTestSuite) TestURI() { | ||
expected := "sftp://[email protected]:22/some/path/to/file.txt" | ||
ts.Equal(expected, ts.testFile.URI(), "URI test") | ||
|
||
expected = "sftp://domain.com%[email protected]:22/some/path/to/file.txt" | ||
fs := NewFileSystem() | ||
f, err := fs.NewFile("domain.com%[email protected]:22", "/some/path/to/file.txt") | ||
ts.NoError(err) | ||
ts.Equal(expected, f.URI(), "URI test") | ||
} | ||
|
||
func (ts *fileTestSuite) TestStringer() { | ||
|
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 |
---|---|---|
|
@@ -155,6 +155,16 @@ func (lt *locationTestSuite) TestURI() { | |
file, err := lt.sftpfs.NewFile(authority, "/blah/file.txt") | ||
lt.NoError(err) | ||
lt.Equal("sftp://[email protected]/blah/file.txt", file.URI(), "file uri with user, pass, host") | ||
|
||
authority = `domain.com\[email protected]` | ||
file, err = lt.sftpfs.NewFile(authority, "/blah/file.txt") | ||
lt.Error(err) | ||
lt.ErrorContains(err, "net/url: invalid userinfo", "file uri with bad user") | ||
|
||
authority = `domain.com%[email protected]` | ||
file, err = lt.sftpfs.NewFile(authority, "/blah/file.txt") | ||
lt.NoError(err) | ||
lt.Equal(`sftp://domain.com%[email protected]/blah/file.txt`, file.URI(), "file uri with percent-encoded character in user") | ||
} | ||
|
||
func (lt *locationTestSuite) TestString() { | ||
|
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.