@@ -760,6 +760,93 @@ def test_sasl_names(self):
760
760
cmp_mech .shouldnt_be_none ()
761
761
cmp_mech .should_be (mech )
762
762
763
+ @ktu .gssapi_extension_test ('ggf' , 'Global Grid Forum' )
764
+ @ktu .gssapi_extension_test ('s4u' , 'S4U' )
765
+ @ktu .krb_minversion_test ('1.16' ,
766
+ 'querying impersonator name of krb5 GSS '
767
+ 'Credential using the '
768
+ 'GSS_KRB5_GET_CRED_IMPERSONATOR OID' )
769
+ def test_inquire_cred_by_oid_impersonator (self ):
770
+ svc_princ = SERVICE_PRINCIPAL .decode ("UTF-8" )
771
+ self .realm .kinit (svc_princ , flags = ['-k' , '-f' ])
772
+
773
+ target_name = gb .import_name (TARGET_SERVICE_NAME ,
774
+ gb .NameType .hostbased_service )
775
+
776
+ client_token = gb .init_sec_context (target_name ).token
777
+
778
+ # if our acceptor creds have a usage of both, we get
779
+ # s4u2proxy delegated credentials
780
+ server_creds = gb .acquire_cred (None , usage = 'both' ).creds
781
+ server_ctx_resp = gb .accept_sec_context (client_token ,
782
+ acceptor_creds = server_creds )
783
+
784
+ server_ctx_resp .shouldnt_be_none ()
785
+ server_ctx_resp .delegated_creds .shouldnt_be_none ()
786
+ server_ctx_resp .delegated_creds .should_be_a (gb .Creds )
787
+
788
+ # GSS_KRB5_GET_CRED_IMPERSONATOR
789
+ oid = gb .OID .from_int_seq ("1.2.840.113554.1.2.2.5.14" )
790
+ info = gb .inquire_cred_by_oid (server_ctx_resp .delegated_creds , oid )
791
+
792
+ info .should_be_a (list )
793
+ info .shouldnt_be_empty ()
794
+ info [0 ].should_be_a (bytes )
795
+ info [0 ].should_be (b"%s@%s" % (SERVICE_PRINCIPAL ,
796
+ self .realm .realm .encode ('utf-8' )))
797
+
798
+ @ktu .gssapi_extension_test ('ggf' , 'Global Grid Forum' )
799
+ def test_inquire_sec_context_by_oid (self ):
800
+ target_name = gb .import_name (TARGET_SERVICE_NAME ,
801
+ gb .NameType .hostbased_service )
802
+ ctx_resp1 = gb .init_sec_context (target_name )
803
+
804
+ server_name = gb .import_name (SERVICE_PRINCIPAL ,
805
+ gb .NameType .kerberos_principal )
806
+ server_creds = gb .acquire_cred (server_name )[0 ]
807
+ server_resp = gb .accept_sec_context (ctx_resp1 [3 ],
808
+ acceptor_creds = server_creds )
809
+ server_ctx = server_resp [0 ]
810
+ server_tok = server_resp [3 ]
811
+
812
+ client_resp2 = gb .init_sec_context (target_name ,
813
+ context = ctx_resp1 [0 ],
814
+ input_token = server_tok )
815
+ client_ctx = client_resp2 [0 ]
816
+
817
+ # GSS_C_INQ_SSPI_SESSION_KEY
818
+ session_key_oid = gb .OID .from_int_seq ("1.2.840.113554.1.2.2.5.5" )
819
+
820
+ client_key = gb .inquire_sec_context_by_oid (client_ctx , session_key_oid )
821
+ server_key = gb .inquire_sec_context_by_oid (server_ctx , session_key_oid )
822
+
823
+ client_key .should_be_a (list )
824
+ client_key .shouldnt_be_empty ()
825
+ server_key .should_be_a (list )
826
+ server_key .shouldnt_be_empty ()
827
+ client_key .should_have_same_items_as (server_key )
828
+
829
+ @ktu .gssapi_extension_test ('ggf' , 'Global Grid Forum' )
830
+ def test_inquire_sec_context_by_oid_should_raise_error (self ):
831
+ target_name = gb .import_name (TARGET_SERVICE_NAME ,
832
+ gb .NameType .hostbased_service )
833
+ ctx_resp1 = gb .init_sec_context (target_name )
834
+
835
+ server_name = gb .import_name (SERVICE_PRINCIPAL ,
836
+ gb .NameType .kerberos_principal )
837
+ server_creds = gb .acquire_cred (server_name )[0 ]
838
+ server_resp = gb .accept_sec_context (ctx_resp1 [3 ],
839
+ acceptor_creds = server_creds )
840
+
841
+ client_resp2 = gb .init_sec_context (target_name ,
842
+ context = ctx_resp1 [0 ],
843
+ input_token = server_resp [3 ])
844
+ client_ctx = client_resp2 [0 ]
845
+
846
+ invalid_oid = gb .OID .from_int_seq ("1.2.3.4.5.6.7.8.9" )
847
+ gb .inquire_sec_context_by_oid .should_raise (gb .GSSError , client_ctx ,
848
+ invalid_oid )
849
+
763
850
764
851
class TestIntEnumFlagSet (unittest .TestCase ):
765
852
def test_create_from_int (self ):
0 commit comments