Skip to content

Commit

Permalink
Fix OID inequality comparison
Browse files Browse the repository at this point in the history
Due to an extraneous 'or' branch, OID inequality
comparison would return the results of an equality
comparison.

Signed-off-by: Alexander Scheel <ascheel@redhat.com>
  • Loading branch information
cipherboy committed Jul 25, 2017
1 parent ae99d0c commit bc32062
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gssapi/raw/oids.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ cdef class OID:
return hash(self.__bytes__())

def __richcmp__(OID self, OID other, op):
if op == 2 or op == 3: # ==
if op == 2: # ==
return c_compare_oids(&self.raw_oid, &other.raw_oid)
elif op == 3: # !=
return not c_compare_oids(&self.raw_oid, &other.raw_oid)
Expand Down
10 changes: 10 additions & 0 deletions gssapi/tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,3 +1353,13 @@ def test_encode_from_int_seq(self):
int_seq = oid['string'].split('.')
o = gb.OID.from_int_seq(int_seq)
o.__bytes__().should_be(oid['bytes'])

def test_comparisons(self):
krb5 = gb.OID.from_int_seq(TEST_OIDS['KRB5']['string'])
krb5_other = gb.OID.from_int_seq(TEST_OIDS['KRB5']['string'])
spnego = gb.OID.from_int_seq(TEST_OIDS['SPNEGO']['string'])

(krb5 == krb5_other).should_be(True)
(krb5 == spnego).should_be(False)
(krb5 != krb5_other).should_be(False)
(krb5 != spnego).should_be(True)

0 comments on commit bc32062

Please sign in to comment.