mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 15:53:28 +03:00
web: Add more data for jsonrpc responses. (#3296)
This change adds more richer error response
for JSON-RPC by interpreting object layer
errors to corresponding meaningful errors
for the web browser.
```go
&json2.Error{
Message: "Bucket Name Invalid, Only lowercase letters, full stops, and numbers are allowed.",
}
```
Additionally this patch also allows PresignedGetObject()
to take expiry parameter to have variable expiry.
This commit is contained in:
@@ -70,16 +70,10 @@ func TestNewJWT(t *testing.T) {
|
||||
cred *credential
|
||||
expectedErr error
|
||||
}{
|
||||
// Test non-existent config directory.
|
||||
{path.Join(path1, "non-existent-dir"), false, nil, errServerNotInitialized},
|
||||
// Test empty config directory.
|
||||
{path2, false, nil, errServerNotInitialized},
|
||||
// Test empty config file.
|
||||
{path3, false, nil, errServerNotInitialized},
|
||||
// Test initialized config file.
|
||||
{path4, true, nil, nil},
|
||||
// Test to read already created config file.
|
||||
{path4, false, nil, nil},
|
||||
{path4, true, nil, nil},
|
||||
// Access key is too small.
|
||||
{path4, false, &credential{"user", "pass"}, errInvalidAccessKeyLength},
|
||||
// Access key is too long.
|
||||
@@ -100,13 +94,10 @@ func TestNewJWT(t *testing.T) {
|
||||
t.Fatalf("unable initialize config file, %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if testCase.cred != nil {
|
||||
serverConfig.SetCredential(*testCase.cred)
|
||||
}
|
||||
|
||||
_, err := newJWT(defaultJWTExpiry)
|
||||
|
||||
_, err := newJWT(defaultJWTExpiry, serverConfig.GetCredential())
|
||||
if testCase.expectedErr != nil {
|
||||
if err == nil {
|
||||
t.Fatalf("%+v: expected: %s, got: <nil>", testCase, testCase.expectedErr)
|
||||
@@ -128,7 +119,7 @@ func TestGenerateToken(t *testing.T) {
|
||||
}
|
||||
defer removeAll(testPath)
|
||||
|
||||
jwt, err := newJWT(defaultJWTExpiry)
|
||||
jwt, err := newJWT(defaultJWTExpiry, serverConfig.GetCredential())
|
||||
if err != nil {
|
||||
t.Fatalf("unable get new JWT, %s", err)
|
||||
}
|
||||
@@ -175,7 +166,7 @@ func TestAuthenticate(t *testing.T) {
|
||||
}
|
||||
defer removeAll(testPath)
|
||||
|
||||
jwt, err := newJWT(defaultJWTExpiry)
|
||||
jwt, err := newJWT(defaultJWTExpiry, serverConfig.GetCredential())
|
||||
if err != nil {
|
||||
t.Fatalf("unable get new JWT, %s", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user