From bc32062d519cc01f93e4fa27a295e88902f6c2f5 Mon Sep 17 00:00:00 2001 From: Alexander Scheel Date: Tue, 25 Jul 2017 13:29:01 -0400 Subject: [PATCH] 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 --- gssapi/raw/oids.pyx | 2 +- gssapi/tests/test_raw.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gssapi/raw/oids.pyx b/gssapi/raw/oids.pyx index d40157c0..a5340609 100644 --- a/gssapi/raw/oids.pyx +++ b/gssapi/raw/oids.pyx @@ -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) diff --git a/gssapi/tests/test_raw.py b/gssapi/tests/test_raw.py index fbe54f1c..d2b307f1 100644 --- a/gssapi/tests/test_raw.py +++ b/gssapi/tests/test_raw.py @@ -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)