@@ -41,7 +41,8 @@ public class ScramSha1SaslAuthenticatorTest {
41
41
public void before () {
42
42
this .connection = new TestInternalConnection (new ServerId (new ClusterId (), new ServerAddress ("localhost" , 27017 )));
43
43
connectionDescription = new ConnectionDescription (new ServerId (new ClusterId (), new ServerAddress ()));
44
- this .credential = MongoCredential .createScramSha1Credential ("user" , "database" , "pencil" .toCharArray ());
44
+ // User name contains ",' and '=" to test user name prepping required by the RFC
45
+ this .credential = MongoCredential .createScramSha1Credential ("u,ser=" , "database" , "pencil" .toCharArray ());
45
46
ScramSha1Authenticator .RandomStringGenerator randomStringGenerator = new ScramSha1Authenticator .RandomStringGenerator () {
46
47
@ Override
47
48
public String generate (final int length ) {
@@ -159,19 +160,20 @@ private void validateMessages() {
159
160
String firstCommand = MessageHelper .decodeCommandAsJson (sent .get (0 ));
160
161
String expectedFirstCommand = "{ \" saslStart\" : 1, "
161
162
+ "\" mechanism\" : \" SCRAM-SHA-1\" , "
162
- + "\" payload\" : { \" $binary\" : \" biwsbj11c2VyLHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdM \" , "
163
+ + "\" payload\" : { \" $binary\" : \" biwsbj11PTJDc2VyPTNELHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdM \" , "
163
164
+ "\" $type\" : \" 00\" } }" ;
164
165
165
166
String secondCommand = MessageHelper .decodeCommandAsJson (sent .get (1 ));
166
167
String expectedSecondCommand = "{ \" saslContinue\" : 1, "
167
168
+ "\" conversationId\" : 1, "
168
- + "\" payload\" : { \" $binary\" : \" Yz1iaXdzLHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdMSG8rVmdrN3F2VU9LVXd"
169
- + "1V0xJV2c0bC85U3JhR01IRUUscD1NQzJUOEJ2Ym1XUmNrRHc4b1dsNUlWZ2h3Q1k9\" , \" $type\" : \" 00\" } }" ;
169
+ + "\" payload\" : { \" $binary\" : \" Yz1iaXdzLHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdMSG8rVmdrN3F2VU9LVXd1V0xJV2c0bC85U3JhR01IRUU"
170
+ + "scD04Z2RlTXVJL1dXbXVaOWFpQ0FOYk5wYTdrN009\" "
171
+ + ", \" $type\" : \" 00\" } }" ;
170
172
171
173
String thirdCommand = MessageHelper .decodeCommandAsJson (sent .get (2 ));
172
174
String expectedThirdCommand = "{ \" saslContinue\" : 1, "
173
175
+ "\" conversationId\" : 1, "
174
- + "\" payload\" : { \" $binary\" : \" dj1VTVdlSTI1SkQxeU5ZWlJNcFo0Vkh2aFo5ZTA9 \" , \" $type\" : \" 00\" } }" ;
176
+ + "\" payload\" : { \" $binary\" : \" dj1ZaVNJZWJNNHJ4MG5kTEdqS1JZY1ZqMnBZTEE9 \" , \" $type\" : \" 00\" } }" ;
175
177
176
178
assertEquals (expectedFirstCommand , firstCommand );
177
179
assertEquals (expectedSecondCommand , secondCommand );
@@ -188,7 +190,7 @@ private void enqueueSuccessfulReplies() {
188
190
+ "ok: 1}" );
189
191
ResponseBuffers secondReply =
190
192
buildSuccessfulReply ("{conversationId: 1, "
191
- + "payload: BinData(0,dj1VTVdlSTI1SkQxeU5ZWlJNcFo0Vkh2aFo5ZTA9 ), "
193
+ + "payload: BinData(0,dj1ZaVNJZWJNNHJ4MG5kTEdqS1JZY1ZqMnBZTEE9 ), "
192
194
+ "done: false, "
193
195
+ "ok: 1}" );
194
196
ResponseBuffers thirdReply =
0 commit comments