mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
fs: validate filesystem path argument properly. (#3470)
FS should fail for invalid paths like - file:/// - ftp:// - http://
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -182,15 +183,25 @@ func TestParseStorageEndpoints(t *testing.T) {
|
||||
expectedErr error
|
||||
}{
|
||||
{"", "http://localhost/export", nil},
|
||||
{"testhost", "http://localhost/export", errInvalidArgument},
|
||||
{"", "http://localhost:9000/export", errInvalidArgument},
|
||||
{
|
||||
"testhost",
|
||||
"http://localhost/export",
|
||||
errors.New("Invalid Argument localhost, port mandatory when --address <host>:<port> is used"),
|
||||
},
|
||||
{
|
||||
"",
|
||||
"http://localhost:9000/export",
|
||||
errors.New("Invalid Argument localhost:9000, port configurable using --address :<port>"),
|
||||
},
|
||||
{"testhost", "http://localhost:9000/export", nil},
|
||||
}
|
||||
for i, test := range testCases {
|
||||
globalMinioHost = test.globalMinioHost
|
||||
_, err := parseStorageEndpoints([]string{test.host})
|
||||
if err != test.expectedErr {
|
||||
t.Errorf("Test %d : got %v, expected %v", i+1, err, test.expectedErr)
|
||||
if err != nil {
|
||||
if err.Error() != test.expectedErr.Error() {
|
||||
t.Errorf("Test %d : got %v, expected %v", i+1, err, test.expectedErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Should be reset back to "" so that we don't affect other tests.
|
||||
|
||||
Reference in New Issue
Block a user