@@ -846,35 +846,53 @@ def test_inquire_sec_context_by_oid_should_raise_error(self):
846
846
@ktu .gssapi_extension_test ('ggf' , 'Global Grid Forum' )
847
847
@ktu .gssapi_extension_test ('password' , 'Add Credential with Password' )
848
848
def test_set_sec_context_option (self ):
849
- if not os .path .exists ('/etc/gss/mech.d/ntlmssp.conf' ):
850
- self .skipTest ('You do not have the GSSAPI gss-ntlmssp mech '
851
- 'installed' )
852
-
853
849
ntlm_mech = gb .OID .from_int_seq ("1.3.6.1.4.1.311.2.2.10" )
854
- reset_mech = gb .OID .from_int_seq ("1.3.6.1.4.1.7165.655.1.3" )
855
-
856
850
username = gb .import_name (name = b"user" ,
857
851
name_type = gb .NameType .user )
852
+ try :
853
+ cred = gb .acquire_cred_with_password (name = username ,
854
+ password = b"password" ,
855
+ mechs = [ntlm_mech ])
856
+ except gb .GSSError :
857
+ self .skipTest ('You do not have the GSSAPI gss-ntlmssp mech '
858
+ 'installed' )
859
+
858
860
server = gb .import_name (name = b"server" ,
859
861
name_type = gb .NameType .hostbased_service )
860
- cred = gb .acquire_cred_with_password (name = username ,
861
- password = b"password" ,
862
- mechs = [ntlm_mech ])
863
862
orig_context = gb .init_sec_context (server , creds = cred .creds ,
864
863
mech = ntlm_mech )[0 ]
865
864
865
+ # GSS_NTLMSSP_RESET_CRYPTO_OID_STRING
866
+ reset_mech = gb .OID .from_int_seq ("1.3.6.1.4.1.7165.655.1.3" )
866
867
out_context = gb .set_sec_context_option (reset_mech ,
867
868
context = orig_context ,
868
869
value = b"\x00 " * 4 )
869
870
out_context .should_be_a (gb .SecurityContext )
870
871
871
872
@ktu .gssapi_extension_test ('ggf' , 'Global Grid Forum' )
873
+ @ktu .gssapi_extension_test ('password' , 'Add Credential with Password' )
872
874
def test_set_sec_context_option_fail (self ):
873
- # because MIT krb5 doesn't implement any OID's for
874
- # gss_set_sec_context_option, we just need to query any OID and it will
875
- # raise an exception
876
- gb .set_sec_context_option .should_raise (gb .GSSError ,
877
- gb .OID .from_int_seq ("1.2.3.4" ))
875
+ ntlm_mech = gb .OID .from_int_seq ("1.3.6.1.4.1.311.2.2.10" )
876
+ username = gb .import_name (name = b"user" ,
877
+ name_type = gb .NameType .user )
878
+ try :
879
+ cred = gb .acquire_cred_with_password (name = username ,
880
+ password = b"password" ,
881
+ mechs = [ntlm_mech ])
882
+ except gb .GSSError :
883
+ self .skipTest ('You do not have the GSSAPI gss-ntlmssp mech '
884
+ 'installed' )
885
+
886
+ server = gb .import_name (name = b"server" ,
887
+ name_type = gb .NameType .hostbased_service )
888
+ orig_context = gb .init_sec_context (server , creds = cred .creds ,
889
+ mech = ntlm_mech )[0 ]
890
+
891
+ # GSS_NTLMSSP_RESET_CRYPTO_OID_STRING
892
+ reset_mech = gb .OID .from_int_seq ("1.3.6.1.4.1.7165.655.1.3" )
893
+
894
+ # will raise a GSSError if no data was passed in
895
+ gb .set_sec_context_option .should_raise (gb .GSSError , reset_mech )
878
896
879
897
@ktu .gssapi_extension_test ('set_cred_opt' , 'Kitten Set Credential Option' )
880
898
@ktu .krb_minversion_test ('1.14' ,
0 commit comments