fix: openid config provider not initialized correctly (#14399)

Up until now `InitializeProvider` method of `Config` struct was
implemented on a value receiver which is why changes on `provider`
field where never reflected to method callers. In order to fix this
issue, the method was implemented on a pointer receiver.
This commit is contained in:
hellivan
2022-02-24 08:42:37 +01:00
committed by GitHub
parent 1bfbe354f5
commit 0913eb6655
2 changed files with 26 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ import (
"time"
jwtg "github.com/golang-jwt/jwt/v4"
"github.com/minio/minio/internal/config"
jwtm "github.com/minio/minio/internal/jwt"
xnet "github.com/minio/pkg/net"
)
@@ -230,3 +231,27 @@ func TestExpCorrect(t *testing.T) {
t.Error(err)
}
}
func TestKeycloakProviderInitialization(t *testing.T) {
testConfig := Config{
DiscoveryDoc: DiscoveryDoc{
TokenEndpoint: "http://keycloak.test/token/endpoint",
},
}
testKvs := config.KVS{}
testKvs.Set(Vendor, "keycloak")
testKvs.Set(KeyCloakRealm, "TestRealm")
testKvs.Set(KeyCloakAdminURL, "http://keycloak.test/auth/admin")
if testConfig.provider != nil {
t.Errorf("Empty config cannot have any provider!")
}
if err := testConfig.InitializeProvider(testKvs); err != nil {
t.Error(err)
}
if testConfig.provider == nil {
t.Errorf("keycloak provider must be initialized!")
}
}