File tree 2 files changed +19
-3
lines changed
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def __str__(self):
112
112
113
113
def __unicode__ (self ):
114
114
# Python 2 -- someone asked for unicode
115
- return self .__bytes__ ().encode (_utils ._get_encoding ())
115
+ return self .__bytes__ ().decode (_utils ._get_encoding ())
116
116
117
117
def __bytes__ (self ):
118
118
# Python 3 -- someone asked for bytes
@@ -142,8 +142,8 @@ def display_as(self, name_type):
142
142
raise NotImplementedError ("Your GSSAPI implementation does not "
143
143
"support RFC 6680 (the GSSAPI naming "
144
144
"extensions)" )
145
- return rname_rfc6680 .display_name_ext (self , name_type ).encode (
146
- _utils .get_encoding ())
145
+ return rname_rfc6680 .display_name_ext (self , name_type ).decode (
146
+ _utils ._get_encoding ())
147
147
148
148
@property
149
149
def name_type (self ):
Original file line number Diff line number Diff line change @@ -396,6 +396,22 @@ def test_create_from_token(self):
396
396
name2 .shouldnt_be_none ()
397
397
name2 .name_type .should_be (gb .NameType .kerberos_principal )
398
398
399
+ @_extension_test ('rfc6680' , 'RFC 6680' )
400
+ def test_display_as (self ):
401
+ name = gssnames .Name (TARGET_SERVICE_NAME ,
402
+ gb .NameType .hostbased_service )
403
+ canonical_name = name .canonicalize (gb .MechType .kerberos )
404
+
405
+ # NB(directxman12): krb5 doesn't implement display_name_ext, so just
406
+ # check to make sure we return the right types and a reasonable value
407
+ krb_name = canonical_name .display_as (
408
+ gb .NameType .hostbased_service )
409
+
410
+ princ_str = SERVICE_PRINCIPAL .decode ('utf-8' ) + '@'
411
+ six .text_type (canonical_name ).should_be (princ_str )
412
+ krb_name .should_be_a (six .text_type )
413
+ krb_name .should_be (princ_str )
414
+
399
415
@_extension_test ('rfc6680' , 'RFC 6680' )
400
416
def test_create_from_composite_token_no_attrs (self ):
401
417
name1 = gssnames .Name (TARGET_SERVICE_NAME ,
You can’t perform that action at this time.
0 commit comments