parent
0adba76a42
commit
471e2e5d5c
|
|
@ -1148,7 +1148,7 @@ func (r *ReconcileChe) autoEnableOAuth(deployContext *deploy.DeployContext, requ
|
|||
if len(openshitOAuth.Spec.IdentityProviders) > 0 {
|
||||
oauth = true
|
||||
} else if util.IsInitialOpenShiftOAuthUserEnabled(cr) {
|
||||
provisioned, err := r.userHandler.SyncOAuthInitialUser(openshitOAuth, deployContext);
|
||||
provisioned, err := r.userHandler.SyncOAuthInitialUser(openshitOAuth, deployContext)
|
||||
if err != nil {
|
||||
message = warningNoIdentityProvidersMessage + " Operator tried to create initial OpenShift OAuth user for HTPasswd identity provider, but failed. Cause: " + err.Error()
|
||||
logrus.Error(message)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
password = util.GeneratePasswd(6)
|
||||
password = util.GeneratePasswd(6)
|
||||
htpasswdFileContent string
|
||||
)
|
||||
|
||||
|
|
@ -84,7 +84,6 @@ func (iuh *OpenShiftOAuthUserOperatorHandler) SyncOAuthInitialUser(openshiftOAut
|
|||
return false, err
|
||||
}
|
||||
|
||||
|
||||
storedPassword := string(credentionalSecret.Data["password"])
|
||||
if password != storedPassword {
|
||||
password = storedPassword
|
||||
|
|
@ -92,8 +91,8 @@ func (iuh *OpenShiftOAuthUserOperatorHandler) SyncOAuthInitialUser(openshiftOAut
|
|||
|
||||
htpasswdFileSecretData := map[string][]byte{"htpasswd": []byte(htpasswdFileContent)}
|
||||
secret, err := deploy.SyncSecret(deployContext, htpasswdSecretName, ocConfigNamespace, htpasswdFileSecretData)
|
||||
if sercet == nil {
|
||||
return false, err
|
||||
if secret == nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if err := appendIdentityProvider(openshiftOAuth, iuh.runtimeClient); err != nil {
|
||||
|
|
@ -110,27 +109,27 @@ func (iuh *OpenShiftOAuthUserOperatorHandler) DeleteOAuthInitialUser(deployConte
|
|||
return err
|
||||
}
|
||||
|
||||
cr := deployContext.CheCluster
|
||||
userName := deploy.DefaultCheFlavor(cr)
|
||||
if err := deleteUser(iuh.runtimeClient, userName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deleteUserIdentity(iuh.runtimeClient, userName); err != nil {
|
||||
return err
|
||||
}
|
||||
cr := deployContext.CheCluster
|
||||
userName := deploy.DefaultCheFlavor(cr)
|
||||
if err := deleteUser(iuh.runtimeClient, userName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deleteIdentityProvider(oAuth, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deploy.DeleteSecret(htpasswdSecretName, ocConfigNamespace, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := deleteUserIdentity(iuh.runtimeClient, userName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deploy.DeleteSecret(openShiftOAuthUserCredentialsSecret, cr.Namespace, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := deleteIdentityProvider(oAuth, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deploy.DeleteSecret(htpasswdSecretName, ocConfigNamespace, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := deploy.DeleteSecret(openShiftOAuthUserCredentialsSecret, cr.Namespace, iuh.runtimeClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -178,7 +177,7 @@ func appendIdentityProvider(oAuth *oauthv1.OAuth, runtimeClient client.Client) e
|
|||
oauthPatch := client.MergeFrom(oAuth.DeepCopy())
|
||||
|
||||
oAuth.Spec.IdentityProviders = append(oAuth.Spec.IdentityProviders, *htpasswdProvider)
|
||||
|
||||
|
||||
if err := runtimeClient.Patch(context.TODO(), oAuth, oauthPatch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ func TestCreateInitialUser(t *testing.T) {
|
|||
}
|
||||
dc := &deploy.DeployContext{
|
||||
CheCluster: testCR,
|
||||
ClusterAPI: deploy.ClusterAPI{Client: runtimeClient, NonCachedClient: runtimeClient, DiscoveryClient: nil, Scheme: scheme},
|
||||
ClusterAPI: deploy.ClusterAPI{Client: runtimeClient, NonCachedClient: runtimeClient, DiscoveryClient: nil, Scheme: scheme},
|
||||
}
|
||||
provisined, err := initialUserHandler.SyncOAuthInitialUser(oAuth, dc)
|
||||
if err != nil {
|
||||
|
|
@ -176,8 +176,8 @@ func TestDeleteInitialUser(t *testing.T) {
|
|||
}
|
||||
|
||||
dc := &deploy.DeployContext{
|
||||
CheCluster: testCR,
|
||||
ClusterAPI: deploy.ClusterAPI{Client: runtimeClient, NonCachedClient: runtimeClient, DiscoveryClient: nil, Scheme: scheme},
|
||||
CheCluster: testCR,
|
||||
ClusterAPI: deploy.ClusterAPI{Client: runtimeClient, NonCachedClient: runtimeClient, DiscoveryClient: nil, Scheme: scheme},
|
||||
}
|
||||
if err := initialUserHandler.DeleteOAuthInitialUser(dc); err != nil {
|
||||
t.Errorf("Unable to delete initial user: %s", err.Error())
|
||||
|
|
|
|||
|
|
@ -282,9 +282,9 @@ func TestMountSecret(t *testing.T) {
|
|||
},
|
||||
},
|
||||
ClusterAPI: ClusterAPI{
|
||||
Client: cli,
|
||||
Client: cli,
|
||||
NonCachedClient: cli,
|
||||
Scheme: scheme.Scheme,
|
||||
Scheme: scheme.Scheme,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -391,9 +391,9 @@ func CompareBoolPointers(a *bool, b *bool) bool {
|
|||
return true
|
||||
}
|
||||
if a == nil && b != nil {
|
||||
return false
|
||||
return false
|
||||
}
|
||||
if b == nil && a != nil{
|
||||
if b == nil && a != nil {
|
||||
return false
|
||||
}
|
||||
return *a == *b
|
||||
|
|
|
|||
Loading…
Reference in New Issue