@@ -91,7 +91,8 @@ func TestUpdateOmAuthentication_NoAuthenticationEnabled(t *testing.T) {
9191
9292 kubeClient , omConnectionFactory := mock .NewDefaultFakeClient (rs )
9393 r := newReplicaSetReconciler (ctx , kubeClient , nil , "" , "" , false , false , omConnectionFactory .GetConnectionFunc )
94- r .updateOmAuthentication (ctx , conn , processNames , rs , "" , "" , "" , false , zap .S ())
94+ agentCertSecretSelector := rs .GetSecurity ().AgentClientCertificateSecretName (rs .Name )
95+ r .updateOmAuthentication (ctx , conn , processNames , rs , agentCertSecretSelector , "" , "" , false , zap .S ())
9596
9697 ac , _ := conn .ReadAutomationConfig ()
9798
@@ -112,7 +113,8 @@ func TestUpdateOmAuthentication_EnableX509_TlsNotEnabled(t *testing.T) {
112113
113114 kubeClient , omConnectionFactory := mock .NewDefaultFakeClient (rs )
114115 r := newReplicaSetReconciler (ctx , kubeClient , nil , "" , "" , false , false , omConnectionFactory .GetConnectionFunc )
115- status , isMultiStageReconciliation := r .updateOmAuthentication (ctx , conn , []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , "" , "" , "" , false , zap .S ())
116+ agentCertSecretSelector := rs .GetSecurity ().AgentClientCertificateSecretName (rs .Name )
117+ status , isMultiStageReconciliation := r .updateOmAuthentication (ctx , conn , []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , agentCertSecretSelector , "" , "" , false , zap .S ())
116118
117119 assert .True (t , status .IsOK (), "configuring both options at once should not result in a failed status" )
118120 assert .True (t , isMultiStageReconciliation , "configuring both tls and x509 at once should result in a multi stage reconciliation" )
@@ -124,7 +126,8 @@ func TestUpdateOmAuthentication_EnableX509_WithTlsAlreadyEnabled(t *testing.T) {
124126 omConnectionFactory := om .NewCachedOMConnectionFactoryWithInitializedConnection (om .NewMockedOmConnection (deployment .CreateFromReplicaSet ("fake-mongoDBImage" , false , rs )))
125127 kubeClient := mock .NewDefaultFakeClientWithOMConnectionFactory (omConnectionFactory , rs )
126128 r := newReplicaSetReconciler (ctx , kubeClient , nil , "" , "" , false , false , omConnectionFactory .GetConnectionFunc )
127- status , isMultiStageReconciliation := r .updateOmAuthentication (ctx , omConnectionFactory .GetConnection (), []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , "" , "" , "" , false , zap .S ())
129+ agentCertSecretSelector := rs .GetSecurity ().AgentClientCertificateSecretName (rs .Name )
130+ status , isMultiStageReconciliation := r .updateOmAuthentication (ctx , omConnectionFactory .GetConnection (), []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , agentCertSecretSelector , "" , "" , false , zap .S ())
128131
129132 assert .True (t , status .IsOK (), "configuring x509 when tls has already been enabled should not result in a failed status" )
130133 assert .False (t , isMultiStageReconciliation , "if tls is already enabled, we should be able to configure x509 is a single reconciliation" )
@@ -140,7 +143,8 @@ func TestUpdateOmAuthentication_AuthenticationIsNotConfigured_IfAuthIsNotSet(t *
140143 kubeClient := mock .NewDefaultFakeClientWithOMConnectionFactory (omConnectionFactory , rs )
141144 r := newReplicaSetReconciler (ctx , kubeClient , nil , "" , "" , false , false , omConnectionFactory .GetConnectionFunc )
142145
143- status , _ := r .updateOmAuthentication (ctx , omConnectionFactory .GetConnection (), []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , "" , "" , "" , false , zap .S ())
146+ agentCertSecretSelector := rs .GetSecurity ().AgentClientCertificateSecretName (rs .Name )
147+ status , _ := r .updateOmAuthentication (ctx , omConnectionFactory .GetConnection (), []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , agentCertSecretSelector , "" , "" , false , zap .S ())
144148 assert .True (t , status .IsOK (), "no authentication should have been configured" )
145149
146150 ac , _ := omConnectionFactory .GetConnection ().ReadAutomationConfig ()
@@ -211,7 +215,8 @@ func TestUpdateOmAuthentication_EnableX509_FromEmptyDeployment(t *testing.T) {
211215 r := newReplicaSetReconciler (ctx , kubeClient , nil , "" , "" , false , false , omConnectionFactory .GetConnectionFunc )
212216 createAgentCSRs (t , ctx , 1 , r .client , certsv1 .CertificateApproved )
213217
214- status , isMultiStageReconciliation := r .updateOmAuthentication (ctx , omConnectionFactory .GetConnection (), []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , "" , "" , "" , false , zap .S ())
218+ agentCertSecretSelector := rs .GetSecurity ().AgentClientCertificateSecretName (rs .Name )
219+ status , isMultiStageReconciliation := r .updateOmAuthentication (ctx , omConnectionFactory .GetConnection (), []string {"my-rs-0" , "my-rs-1" , "my-rs-2" }, rs , agentCertSecretSelector , "" , "" , false , zap .S ())
215220 assert .True (t , status .IsOK (), "configuring x509 and tls when there are no processes should not result in a failed status" )
216221 assert .False (t , isMultiStageReconciliation , "if we are enabling tls and x509 at once, this should be done in a single reconciliation" )
217222}
0 commit comments