@@ -91,7 +91,8 @@ func TestUpdateOmAuthentication_NoAuthenticationEnabled(t *testing.T) {
91
91
92
92
kubeClient , omConnectionFactory := mock .NewDefaultFakeClient (rs )
93
93
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 ())
95
96
96
97
ac , _ := conn .ReadAutomationConfig ()
97
98
@@ -112,7 +113,8 @@ func TestUpdateOmAuthentication_EnableX509_TlsNotEnabled(t *testing.T) {
112
113
113
114
kubeClient , omConnectionFactory := mock .NewDefaultFakeClient (rs )
114
115
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 ())
116
118
117
119
assert .True (t , status .IsOK (), "configuring both options at once should not result in a failed status" )
118
120
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) {
124
126
omConnectionFactory := om .NewCachedOMConnectionFactoryWithInitializedConnection (om .NewMockedOmConnection (deployment .CreateFromReplicaSet ("fake-mongoDBImage" , false , rs )))
125
127
kubeClient := mock .NewDefaultFakeClientWithOMConnectionFactory (omConnectionFactory , rs )
126
128
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 ())
128
131
129
132
assert .True (t , status .IsOK (), "configuring x509 when tls has already been enabled should not result in a failed status" )
130
133
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 *
140
143
kubeClient := mock .NewDefaultFakeClientWithOMConnectionFactory (omConnectionFactory , rs )
141
144
r := newReplicaSetReconciler (ctx , kubeClient , nil , "" , "" , false , false , omConnectionFactory .GetConnectionFunc )
142
145
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 ())
144
148
assert .True (t , status .IsOK (), "no authentication should have been configured" )
145
149
146
150
ac , _ := omConnectionFactory .GetConnection ().ReadAutomationConfig ()
@@ -211,7 +215,8 @@ func TestUpdateOmAuthentication_EnableX509_FromEmptyDeployment(t *testing.T) {
211
215
r := newReplicaSetReconciler (ctx , kubeClient , nil , "" , "" , false , false , omConnectionFactory .GetConnectionFunc )
212
216
createAgentCSRs (t , ctx , 1 , r .client , certsv1 .CertificateApproved )
213
217
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 ())
215
220
assert .True (t , status .IsOK (), "configuring x509 and tls when there are no processes should not result in a failed status" )
216
221
assert .False (t , isMultiStageReconciliation , "if we are enabling tls and x509 at once, this should be done in a single reconciliation" )
217
222
}
0 commit comments