Skip to content

Commit 04f347d

Browse files
cipherboyDirectXMan12
authored andcommitted
Fix OID inequality comparison
Due to an extraneous 'or' branch, OID inequality comparison would return the results of an equality comparison. Signed-off-by: Alexander Scheel <[email protected]>
1 parent ae99d0c commit 04f347d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

gssapi/raw/oids.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ cdef class OID:
155155
return hash(self.__bytes__())
156156

157157
def __richcmp__(OID self, OID other, op):
158-
if op == 2 or op == 3: # ==
158+
if op == 2: # ==
159159
return c_compare_oids(&self.raw_oid, &other.raw_oid)
160160
elif op == 3: # !=
161161
return not c_compare_oids(&self.raw_oid, &other.raw_oid)

gssapi/tests/test_raw.py

+10
Original file line numberDiff line numberDiff line change
@@ -1353,3 +1353,13 @@ def test_encode_from_int_seq(self):
13531353
int_seq = oid['string'].split('.')
13541354
o = gb.OID.from_int_seq(int_seq)
13551355
o.__bytes__().should_be(oid['bytes'])
1356+
1357+
def test_comparisons(self):
1358+
krb5 = gb.OID.from_int_seq(TEST_OIDS['KRB5']['string'])
1359+
krb5_other = gb.OID.from_int_seq(TEST_OIDS['KRB5']['string'])
1360+
spnego = gb.OID.from_int_seq(TEST_OIDS['SPNEGO']['string'])
1361+
1362+
(krb5 == krb5_other).should_be(True)
1363+
(krb5 == spnego).should_be(False)
1364+
(krb5 != krb5_other).should_be(False)
1365+
(krb5 != spnego).should_be(True)

0 commit comments

Comments
 (0)