@@ -41,7 +41,8 @@ public class ScramSha1SaslAuthenticatorTest {
4141 public void before () {
4242 this .connection = new TestInternalConnection (new ServerId (new ClusterId (), new ServerAddress ("localhost" , 27017 )));
4343 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 ());
4546 ScramSha1Authenticator .RandomStringGenerator randomStringGenerator = new ScramSha1Authenticator .RandomStringGenerator () {
4647 @ Override
4748 public String generate (final int length ) {
@@ -159,19 +160,20 @@ private void validateMessages() {
159160 String firstCommand = MessageHelper .decodeCommandAsJson (sent .get (0 ));
160161 String expectedFirstCommand = "{ \" saslStart\" : 1, "
161162 + "\" mechanism\" : \" SCRAM-SHA-1\" , "
162- + "\" payload\" : { \" $binary\" : \" biwsbj11c2VyLHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdM \" , "
163+ + "\" payload\" : { \" $binary\" : \" biwsbj11PTJDc2VyPTNELHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdM \" , "
163164 + "\" $type\" : \" 00\" } }" ;
164165
165166 String secondCommand = MessageHelper .decodeCommandAsJson (sent .get (1 ));
166167 String expectedSecondCommand = "{ \" saslContinue\" : 1, "
167168 + "\" conversationId\" : 1, "
168- + "\" payload\" : { \" $binary\" : \" Yz1iaXdzLHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdMSG8rVmdrN3F2VU9LVXd"
169- + "1V0xJV2c0bC85U3JhR01IRUUscD1NQzJUOEJ2Ym1XUmNrRHc4b1dsNUlWZ2h3Q1k9\" , \" $type\" : \" 00\" } }" ;
169+ + "\" payload\" : { \" $binary\" : \" Yz1iaXdzLHI9ZnlrbytkMmxiYkZnT05Sdjlxa3hkYXdMSG8rVmdrN3F2VU9LVXd1V0xJV2c0bC85U3JhR01IRUU"
170+ + "scD04Z2RlTXVJL1dXbXVaOWFpQ0FOYk5wYTdrN009\" "
171+ + ", \" $type\" : \" 00\" } }" ;
170172
171173 String thirdCommand = MessageHelper .decodeCommandAsJson (sent .get (2 ));
172174 String expectedThirdCommand = "{ \" saslContinue\" : 1, "
173175 + "\" conversationId\" : 1, "
174- + "\" payload\" : { \" $binary\" : \" dj1VTVdlSTI1SkQxeU5ZWlJNcFo0Vkh2aFo5ZTA9 \" , \" $type\" : \" 00\" } }" ;
176+ + "\" payload\" : { \" $binary\" : \" dj1ZaVNJZWJNNHJ4MG5kTEdqS1JZY1ZqMnBZTEE9 \" , \" $type\" : \" 00\" } }" ;
175177
176178 assertEquals (expectedFirstCommand , firstCommand );
177179 assertEquals (expectedSecondCommand , secondCommand );
@@ -188,7 +190,7 @@ private void enqueueSuccessfulReplies() {
188190 + "ok: 1}" );
189191 ResponseBuffers secondReply =
190192 buildSuccessfulReply ("{conversationId: 1, "
191- + "payload: BinData(0,dj1VTVdlSTI1SkQxeU5ZWlJNcFo0Vkh2aFo5ZTA9 ), "
193+ + "payload: BinData(0,dj1ZaVNJZWJNNHJ4MG5kTEdqS1JZY1ZqMnBZTEE9 ), "
192194 + "done: false, "
193195 + "ok: 1}" );
194196 ResponseBuffers thirdReply =
0 commit comments