@@ -15,41 +15,15 @@ func init() {
15
15
zap .ReplaceGlobals (logger )
16
16
}
17
17
18
- func TestConfigureScramSha1FallbackToCr (t * testing.T ) {
19
- dep := om .NewDeployment ()
20
- conn := om .NewMockedOmConnection (dep )
21
-
22
- opts := Options {
23
- MinimumMajorVersion : 3 ,
24
- AuthoritativeSet : true ,
25
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
26
- Mechanisms : []string {"SCRAM" },
27
- AgentMechanism : "SCRAM" ,
28
- }
29
-
30
- if err := Configure (conn , opts , false , zap .S ()); err != nil {
31
- t .Fatal (err )
32
- }
33
-
34
- ac , err := conn .ReadAutomationConfig ()
35
- if err != nil {
36
- t .Fatal (err )
37
- }
38
-
39
- assertAuthenticationEnabled (t , ac .Auth )
40
- assertAuthenticationMechanism (t , ac .Auth , "MONGODB-CR" )
41
- }
42
-
43
18
func TestConfigureScramSha256 (t * testing.T ) {
44
19
dep := om .NewDeployment ()
45
20
conn := om .NewMockedOmConnection (dep )
46
21
47
22
opts := Options {
48
- MinimumMajorVersion : 4 ,
49
- AuthoritativeSet : true ,
50
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
51
- Mechanisms : []string {"SCRAM" },
52
- AgentMechanism : "SCRAM" ,
23
+ AuthoritativeSet : true ,
24
+ ProcessNames : []string {"process-1" , "process-2" , "process-3" },
25
+ Mechanisms : []string {"SCRAM" },
26
+ AgentMechanism : "SCRAM" ,
53
27
}
54
28
55
29
if err := Configure (conn , opts , false , zap .S ()); err != nil {
@@ -70,12 +44,11 @@ func TestConfigureX509(t *testing.T) {
70
44
conn := om .NewMockedOmConnection (dep )
71
45
72
46
opts := Options {
73
- MinimumMajorVersion : 4 ,
74
- AuthoritativeSet : true ,
75
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
76
- Mechanisms : []string {"X509" },
77
- AgentMechanism : "X509" ,
78
- ClientCertificates : util .RequireClientCertificates ,
47
+ AuthoritativeSet : true ,
48
+ ProcessNames : []string {"process-1" , "process-2" , "process-3" },
49
+ Mechanisms : []string {"X509" },
50
+ AgentMechanism : "X509" ,
51
+ ClientCertificates : util .RequireClientCertificates ,
79
52
UserOptions : UserOptions {
80
53
AutomationSubject : validSubject ("automation" ),
81
54
},
@@ -99,11 +72,10 @@ func TestConfigureScramSha1(t *testing.T) {
99
72
conn := om .NewMockedOmConnection (dep )
100
73
101
74
opts := Options {
102
- MinimumMajorVersion : 4 ,
103
- AuthoritativeSet : true ,
104
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
105
- Mechanisms : []string {"SCRAM-SHA-1" },
106
- AgentMechanism : "SCRAM-SHA-1" ,
75
+ AuthoritativeSet : true ,
76
+ ProcessNames : []string {"process-1" , "process-2" , "process-3" },
77
+ Mechanisms : []string {"SCRAM-SHA-1" },
78
+ AgentMechanism : "SCRAM-SHA-1" ,
107
79
}
108
80
109
81
if err := Configure (conn , opts , false , zap .S ()); err != nil {
@@ -122,11 +94,10 @@ func TestConfigureMultipleAuthenticationMechanisms(t *testing.T) {
122
94
conn := om .NewMockedOmConnection (dep )
123
95
124
96
opts := Options {
125
- MinimumMajorVersion : 4 ,
126
- AuthoritativeSet : true ,
127
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
128
- Mechanisms : []string {"X509" , "SCRAM" },
129
- AgentMechanism : "SCRAM" ,
97
+ AuthoritativeSet : true ,
98
+ ProcessNames : []string {"process-1" , "process-2" , "process-3" },
99
+ Mechanisms : []string {"X509" , "SCRAM" },
100
+ AgentMechanism : "SCRAM" ,
130
101
UserOptions : UserOptions {
131
102
AutomationSubject : validSubject ("automation" ),
132
103
},
@@ -151,90 +122,6 @@ func TestConfigureMultipleAuthenticationMechanisms(t *testing.T) {
151
122
assert .Contains (t , ac .Auth .DeploymentAuthMechanisms , "MONGODB-X509" )
152
123
}
153
124
154
- func TestScramSha1MongoDBUpgrade (t * testing.T ) {
155
- dep := om .NewDeployment ()
156
- conn := om .NewMockedOmConnection (dep )
157
-
158
- opts := Options {
159
- MinimumMajorVersion : 3 ,
160
- AuthoritativeSet : true ,
161
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
162
- Mechanisms : []string {"SCRAM" },
163
- AgentMechanism : "SCRAM" ,
164
- }
165
-
166
- if err := Configure (conn , opts , false , zap .S ()); err != nil {
167
- t .Fatal (err )
168
- }
169
-
170
- ac , err := conn .ReadAutomationConfig ()
171
- if err != nil {
172
- t .Fatal (err )
173
- }
174
-
175
- assertAuthenticationEnabled (t , ac .Auth )
176
- assertAuthenticationMechanism (t , ac .Auth , "MONGODB-CR" )
177
-
178
- opts = Options {
179
- MinimumMajorVersion : 4 ,
180
- AuthoritativeSet : true ,
181
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
182
- Mechanisms : []string {"SCRAM" },
183
- AgentMechanism : "SCRAM" ,
184
- }
185
-
186
- if err := Configure (conn , opts , false , zap .S ()); err != nil {
187
- t .Fatal (err )
188
- }
189
-
190
- ac , err = conn .ReadAutomationConfig ()
191
- if err != nil {
192
- t .Fatal (err )
193
- }
194
-
195
- assertAuthenticationEnabled (t , ac .Auth )
196
- assertAuthenticationMechanism (t , ac .Auth , "MONGODB-CR" )
197
- }
198
-
199
- func TestConfigureAndDisable (t * testing.T ) {
200
- dep := om .NewDeployment ()
201
- conn := om .NewMockedOmConnection (dep )
202
-
203
- opts := Options {
204
- MinimumMajorVersion : 3 ,
205
- AuthoritativeSet : true ,
206
- ProcessNames : []string {"process-1" , "process-2" , "process-3" },
207
- Mechanisms : []string {"SCRAM" },
208
- AgentMechanism : "SCRAM" ,
209
- UserOptions : UserOptions {
210
- AutomationSubject : validSubject ("automation" ),
211
- },
212
- }
213
-
214
- if err := Configure (conn , opts , false , zap .S ()); err != nil {
215
- t .Fatal (err )
216
- }
217
-
218
- ac , err := conn .ReadAutomationConfig ()
219
- if err != nil {
220
- t .Fatal (err )
221
- }
222
-
223
- assertAuthenticationEnabled (t , ac .Auth )
224
- assertAuthenticationMechanism (t , ac .Auth , "MONGODB-CR" )
225
-
226
- if err := Disable (conn , opts , true , zap .S ()); err != nil {
227
- t .Fatal (err )
228
- }
229
-
230
- ac , err = conn .ReadAutomationConfig ()
231
- if err != nil {
232
- t .Fatal (err )
233
- }
234
-
235
- assertAuthenticationDisabled (t , ac .Auth )
236
- }
237
-
238
125
func TestDisableAuthentication (t * testing.T ) {
239
126
dep := om .NewDeployment ()
240
127
conn := om .NewMockedOmConnection (dep )
@@ -261,17 +148,12 @@ func TestGetCorrectAuthMechanismFromVersion(t *testing.T) {
261
148
conn := om .NewMockedOmConnection (om .NewDeployment ())
262
149
ac , _ := conn .ReadAutomationConfig ()
263
150
264
- mechanismNames := getMechanismNames (ac , 3 , []string {"X509" })
151
+ mechanismNames := getMechanismNames (ac , []string {"X509" })
265
152
266
153
assert .Len (t , mechanismNames , 1 )
267
154
assert .Contains (t , mechanismNames , MechanismName ("MONGODB-X509" ))
268
155
269
- mechanismNames = getMechanismNames (ac , 3 , []string {"SCRAM" , "X509" })
270
-
271
- assert .Contains (t , mechanismNames , MechanismName ("MONGODB-CR" ))
272
- assert .Contains (t , mechanismNames , MechanismName ("MONGODB-X509" ))
273
-
274
- mechanismNames = getMechanismNames (ac , 4 , []string {"SCRAM" , "X509" })
156
+ mechanismNames = getMechanismNames (ac , []string {"SCRAM" , "X509" })
275
157
276
158
assert .Contains (t , mechanismNames , MechanismName ("SCRAM-SHA-256" ))
277
159
assert .Contains (t , mechanismNames , MechanismName ("MONGODB-X509" ))
@@ -280,7 +162,7 @@ func TestGetCorrectAuthMechanismFromVersion(t *testing.T) {
280
162
ac .Auth .AutoAuthMechanism = "MONGODB-CR"
281
163
ac .Auth .Enable ()
282
164
283
- mechanismNames = getMechanismNames (ac , 4 , []string {"SCRAM" , "X509" })
165
+ mechanismNames = getMechanismNames (ac , []string {"SCRAM" , "X509" })
284
166
285
167
assert .Contains (t , mechanismNames , MechanismName ("MONGODB-CR" ))
286
168
assert .Contains (t , mechanismNames , MechanismName ("MONGODB-X509" ))
0 commit comments