Skip to content

Commit a7489c1

Browse files
committed
.
1 parent d4e4808 commit a7489c1

File tree

1 file changed

+32
-14
lines changed

1 file changed

+32
-14
lines changed

gssapi/tests/test_raw.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -846,35 +846,53 @@ def test_inquire_sec_context_by_oid_should_raise_error(self):
846846
@ktu.gssapi_extension_test('ggf', 'Global Grid Forum')
847847
@ktu.gssapi_extension_test('password', 'Add Credential with Password')
848848
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-
853849
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-
856850
username = gb.import_name(name=b"user",
857851
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+
858860
server = gb.import_name(name=b"server",
859861
name_type=gb.NameType.hostbased_service)
860-
cred = gb.acquire_cred_with_password(name=username,
861-
password=b"password",
862-
mechs=[ntlm_mech])
863862
orig_context = gb.init_sec_context(server, creds=cred.creds,
864863
mech=ntlm_mech)[0]
865864

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")
866867
out_context = gb.set_sec_context_option(reset_mech,
867868
context=orig_context,
868869
value=b"\x00" * 4)
869870
out_context.should_be_a(gb.SecurityContext)
870871

871872
@ktu.gssapi_extension_test('ggf', 'Global Grid Forum')
873+
@ktu.gssapi_extension_test('password', 'Add Credential with Password')
872874
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)
878896

879897
@ktu.gssapi_extension_test('set_cred_opt', 'Kitten Set Credential Option')
880898
@ktu.krb_minversion_test('1.14',

0 commit comments

Comments
 (0)