mirror of
https://github.com/minio/minio.git
synced 2025-11-22 18:47:43 -05:00
Extend further validation of config values (#8469)
- This PR allows config KVS to be validated properly without being affected by ENV overrides, rejects invalid values during set operation - Expands unit tests and refactors the error handling for notification targets, returns error instead of ignoring targets for invalid KVS - Does all the prep-work for implementing safe-mode style operation for MinIO server, introduces a new global variable to toggle safe mode based operations NOTE: this PR itself doesn't provide safe mode operations
This commit is contained in:
committed by
kannappanr
parent
599aae5ba6
commit
9e7a3e6adc
57
cmd/config/compress/compress_test.go
Normal file
57
cmd/config/compress/compress_test.go
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* MinIO Cloud Storage, (C) 2019 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package compress
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseCompressIncludes(t *testing.T) {
|
||||
testCases := []struct {
|
||||
str string
|
||||
expectedPatterns []string
|
||||
success bool
|
||||
}{
|
||||
// invalid input
|
||||
{",,,", []string{}, false},
|
||||
{"", []string{}, false},
|
||||
{",", []string{}, false},
|
||||
{"/", []string{}, false},
|
||||
{"text/*,/", []string{}, false},
|
||||
|
||||
// valid input
|
||||
{".txt,.log", []string{".txt", ".log"}, true},
|
||||
{"text/*,application/json", []string{"text/*", "application/json"}, true},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.str, func(t *testing.T) {
|
||||
gotPatterns, err := parseCompressIncludes(testCase.str)
|
||||
if !testCase.success && err == nil {
|
||||
t.Error("expected failure but success instead")
|
||||
}
|
||||
if testCase.success && err != nil {
|
||||
t.Errorf("expected success but failed instead %s", err)
|
||||
}
|
||||
if testCase.success && !reflect.DeepEqual(testCase.expectedPatterns, gotPatterns) {
|
||||
t.Errorf("expected patterns %s but got %s", testCase.expectedPatterns, gotPatterns)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user