Skip to content

Commit c7d80a4

Browse files
committed
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 c7d80a4

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-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

+17
Original file line numberDiff line numberDiff line change
@@ -1353,3 +1353,20 @@ 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+
a = krb5 == krb5_other
1363+
a.should_be(True)
1364+
1365+
a = krb5 == spnego
1366+
a.should_be(False)
1367+
1368+
a = krb5 != krb5_other
1369+
a.should_be(False)
1370+
1371+
a = krb5 != spnego
1372+
a.should_be(True)

0 commit comments

Comments
 (0)