mirror of
https://github.com/minio/minio.git
synced 2025-07-26 00:40:08 -04:00
Fix WORM and BROWSER status calculation (#6360)
One typo introduced in a recent commit miscalculates if worm and browser are enabled or not. A simple test is also added to detect this issue in the future if it ever happens again.
This commit is contained in:
parent
d547873b17
commit
06d2dfa31c
@ -128,8 +128,8 @@ func (s *serverConfig) GetStorageClass() (storageClass, storageClass) {
|
|||||||
|
|
||||||
// GetBrowser get current credentials.
|
// GetBrowser get current credentials.
|
||||||
func (s *serverConfig) GetBrowser() bool {
|
func (s *serverConfig) GetBrowser() bool {
|
||||||
if globalIsEnvWORM {
|
if globalIsEnvBrowser {
|
||||||
return globalWORMEnabled
|
return globalIsBrowserEnabled
|
||||||
}
|
}
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return true
|
return true
|
||||||
@ -139,8 +139,8 @@ func (s *serverConfig) GetBrowser() bool {
|
|||||||
|
|
||||||
// GetWorm get current credentials.
|
// GetWorm get current credentials.
|
||||||
func (s *serverConfig) GetWorm() bool {
|
func (s *serverConfig) GetWorm() bool {
|
||||||
if globalIsEnvBrowser {
|
if globalIsEnvWORM {
|
||||||
return globalIsBrowserEnabled
|
return globalWORMEnabled
|
||||||
}
|
}
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return false
|
return false
|
||||||
|
@ -66,6 +66,9 @@ func TestServerConfigWithEnvs(t *testing.T) {
|
|||||||
os.Setenv("MINIO_BROWSER", "off")
|
os.Setenv("MINIO_BROWSER", "off")
|
||||||
defer os.Unsetenv("MINIO_BROWSER")
|
defer os.Unsetenv("MINIO_BROWSER")
|
||||||
|
|
||||||
|
os.Setenv("MINIO_WORM", "on")
|
||||||
|
defer os.Unsetenv("MINIO_WORM")
|
||||||
|
|
||||||
os.Setenv("MINIO_ACCESS_KEY", "minio")
|
os.Setenv("MINIO_ACCESS_KEY", "minio")
|
||||||
defer os.Unsetenv("MINIO_ACCESS_KEY")
|
defer os.Unsetenv("MINIO_ACCESS_KEY")
|
||||||
|
|
||||||
@ -99,29 +102,35 @@ func TestServerConfigWithEnvs(t *testing.T) {
|
|||||||
// Init config
|
// Init config
|
||||||
initConfig(objLayer)
|
initConfig(objLayer)
|
||||||
|
|
||||||
// Check if serverConfig has
|
// Check if serverConfig has browser disabled
|
||||||
if globalServerConfig.GetBrowser() {
|
if globalServerConfig.GetBrowser() {
|
||||||
t.Errorf("Expecting browser is set to false found %v", globalServerConfig.GetBrowser())
|
t.Error("Expected browser to be disabled but it is not")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if serverConfig has
|
// Check if serverConfig returns WORM config from the env
|
||||||
|
if !globalServerConfig.GetWorm() {
|
||||||
|
t.Error("Expected WORM to be enabled but it is not")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if serverConfig has region from the environment
|
||||||
if globalServerConfig.GetRegion() != "us-west-1" {
|
if globalServerConfig.GetRegion() != "us-west-1" {
|
||||||
t.Errorf("Expecting region to be \"us-west-1\" found %v", globalServerConfig.GetRegion())
|
t.Errorf("Expected region to be \"us-west-1\", found %v", globalServerConfig.GetRegion())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if serverConfig has
|
// Check if serverConfig has credentials from the environment
|
||||||
cred := globalServerConfig.GetCredential()
|
cred := globalServerConfig.GetCredential()
|
||||||
|
|
||||||
if cred.AccessKey != "minio" {
|
if cred.AccessKey != "minio" {
|
||||||
t.Errorf("Expecting access key to be `minio` found %s", cred.AccessKey)
|
t.Errorf("Expected access key to be `minio`, found %s", cred.AccessKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if cred.SecretKey != "minio123" {
|
if cred.SecretKey != "minio123" {
|
||||||
t.Errorf("Expecting access key to be `minio123` found %s", cred.SecretKey)
|
t.Errorf("Expected access key to be `minio123`, found %s", cred.SecretKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if serverConfig has the correct domain
|
||||||
if globalServerConfig.Domain != "domain.com" {
|
if globalServerConfig.Domain != "domain.com" {
|
||||||
t.Errorf("Expecting Domain to be `domain.com` found " + globalServerConfig.Domain)
|
t.Errorf("Expected Domain to be `domain.com`, found " + globalServerConfig.Domain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,6 +434,7 @@ func resetGlobalIsXL() {
|
|||||||
|
|
||||||
func resetGlobalIsEnvs() {
|
func resetGlobalIsEnvs() {
|
||||||
globalIsEnvCreds = false
|
globalIsEnvCreds = false
|
||||||
|
globalIsEnvWORM = false
|
||||||
globalIsEnvBrowser = false
|
globalIsEnvBrowser = false
|
||||||
globalIsEnvRegion = false
|
globalIsEnvRegion = false
|
||||||
globalIsStorageClass = false
|
globalIsStorageClass = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user