File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ Features
1111Bug Fixes
1212---------
1313* Unable to connect to a cloud cluster using Ubuntu 20.04 (PYTHON-1238)
14+ * PlainTextAuthProvider fails with unicode chars and Python3 (PYTHON-1241)
1415* [GRAPH] Can't write data in a Boolean field using the Fluent API (PYTHON-1239)
1516* [GRAPH] Fix elementMap() result deserialization (PYTHON-1233)
1617
Original file line number Diff line number Diff line change @@ -277,7 +277,8 @@ def get_initial_challenge(self):
277277
278278 def evaluate_challenge (self , challenge ):
279279 if challenge == six .b ('PLAIN-START' ):
280- return six .b ("\x00 %s\x00 %s" % (self .username , self .password ))
280+ data = "\x00 %s\x00 %s" % (self .username , self .password )
281+ return data if six .PY2 else data .encode ()
281282 raise Exception ('Did not receive a valid challenge response from server' )
282283
283284
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ # # Copyright DataStax, Inc.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+
16+ import six
17+ from cassandra .auth import PlainTextAuthenticator
18+
19+ try :
20+ import unittest2 as unittest
21+ except ImportError :
22+ import unittest # noqa
23+
24+
25+ class TestPlainTextAuthenticator (unittest .TestCase ):
26+
27+ def test_evaluate_challenge_with_unicode_data (self ):
28+ authenticator = PlainTextAuthenticator ("johnӁ" , "doeӁ" )
29+ self .assertEqual (
30+ authenticator .evaluate_challenge (six .ensure_binary ('PLAIN-START' )),
31+ six .ensure_binary ("\x00 johnӁ\x00 doeӁ" )
32+ )
You can’t perform that action at this time.
0 commit comments