def test_egee_site_unique_id(self): for entry in self.entries: if 'GlueSite' not in entry.objectClass: continue if ('SiteName' not in entry.glue) or ('SiteUniqueID' not in entry.glue): if 'SiteName' not in entry.glue: self.expectEquals(0, 1, msg="No SiteName for %s" % prettyDN(entry.dn)) if 'SiteUniqueID' not in entry.glue: self.expectEquals(0, 1, msg="No SiteUniqueID for %s" % prettyDN(entry.dn)) continue self.expectEquals(entry.glue['SiteName'], entry.glue['SiteUniqueID'], \ msg="For EGEE compat., must have GlueSiteName == GlueSiteUniqueID")
def test_dn(self): for entry in self.entries: dn = list(entry.dn) fulldn = prettyDN(entry.dn) self.expectEquals(dn.pop(), "o=grid", msg="DN %s does not end with o=grid" % fulldn) self.expectEquals( dn.pop().lower(), "mds-vo-name=local", msg="DN %s does not end with mds-vo-name=local,o=grid" % fulldn) if (self.type.lower() == "url" ): # the gip_info does not have the mds-vo-name=site self.expectEquals( dn.pop().lower(), ("mds-vo-name=%s" % self.site).lower(), msg= "DN %s does not end with mds-vo-name=%s,mds-vo-name=local,o=grid" % (fulldn, self.site)) for d in dn: self.expectTrue(d.find("o=grid") < 0, msg="There is an extra o=grid entry in DN %s" % fulldn) self.expectTrue( d.startswith("mds-vo-name") == False, "There is an extra mds-vo-name entry in DN %s" % fulldn)
def test_missing_values(self): for entry in self.entries: for key, val in entry.glue.items(): self.expectNotEquals(val, "", msg="No value for entry %s, key %s." % (prettyDN(entry.dn), key))
def test_foreign_keys(self): for entry in self.entries: if 'ForeignKey' not in entry.glue: continue self.test_existence(entry.glue['ForeignKey'], full=True, key_check="ForeignKey", orig_dn=prettyDN(entry.dn))
def test_value_not_equal(self, objClass, attribute, value): for entry in self.entries: if objClass not in entry.objectClass: continue self.expectNotEquals( entry.glue[attribute], value, msg="GLUE attribute %s for entity %s in\n %s \n is equal to %s" % (attribute, objClass, prettyDN(entry.dn), value))
def test_url(self): for entry in self.entries: if 'GlueSite' not in entry.objectClass: continue if 'SiteWeb' not in entry.glue: parts = '' self.assertNotEquals(parts, '', msg="No SiteWeb for: %s" % prettyDN(entry.dn)) continue parts = urlparse.urlparse(entry.glue['SiteWeb']) self.expectNotEquals(parts, '', msg="Invalid website: %s" % entry.glue['SiteWeb'])
def run_compareDN(self, string1, string2, should_match=False): orig_entries = [] fp = cStringIO.StringIO(string1) orig_entries += read_ldap(fp, multi=True) other_entries = [] fp = cStringIO.StringIO(string2) other_entries += read_ldap(fp, multi=True) result = compareDN(orig_entries[0], other_entries[0]) if should_match: self.failIf(not result, msg="compareDN returned False when it should have "\ "returned True.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) else: self.failIf(result, msg="compareDN returned True when it should have "\ "returned False.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) return result
def run_compareDN(self, string1, string2, should_match = False): orig_entries = [] fp = cStringIO.StringIO(string1) orig_entries += read_ldap(fp, multi=True) other_entries = [] fp = cStringIO.StringIO(string2) other_entries += read_ldap(fp, multi=True) result = compareDN(orig_entries[0], other_entries[0]) if should_match: self.failIf(not result, msg="compareDN returned False when it should have "\ "returned True.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) else: self.failIf(result, msg="compareDN returned True when it should have "\ "returned False.\n\nDN1: %s \nDN2: %s" % \ (prettyDN(orig_entries[0].dn),prettyDN(other_entries[0].dn))) return result
def test_dn(self): for entry in self.entries: dn = list(entry.dn) fulldn = prettyDN(entry.dn) self.expectEquals(dn.pop(), "o=grid", msg="DN %s does not end with o=grid" % fulldn) self.expectEquals(dn.pop().lower(), "mds-vo-name=local", msg="DN %s does not end with mds-vo-name=local,o=grid" % fulldn) if (self.type.lower() == "url"): # the gip_info does not have the mds-vo-name=site self.expectEquals(dn.pop().lower(), ("mds-vo-name=%s" % self.site).lower(), msg="DN %s does not end with mds-vo-name=%s,mds-vo-name=local,o=grid" % (fulldn, self.site)) for d in dn: self.expectTrue(d.find("o=grid") < 0, msg="There is an extra o=grid entry in DN %s" % fulldn) self.expectTrue(d.startswith("mds-vo-name") == False, "There is an extra mds-vo-name entry in DN %s" % fulldn)
def test_missing_newlines(self): r = re.compile("Glue\w*:\s") for entry in self.entries: for key, val in entry.glue.items(): if not isinstance(val, types.StringType): continue m = r.search(val) self.expectEquals( m, None, msg="Entry %s, key %s is missing the newline character." % (prettyDN(entry.dn), key))
def test_missing_newlines(self): r = re.compile("Glue\w*:\s") for entry in self.entries: for key, val in entry.glue.items(): if not isinstance(val, types.StringType): continue m = r.search(val) self.expectEquals(m, None, msg="Entry %s, key %s is missing the newline character." % (prettyDN(entry.dn), key))
def test_value_not_equal(self, objClass, attribute, value): for entry in self.entries: if objClass not in entry.objectClass: continue self.expectNotEquals(entry.glue[attribute], value, msg="GLUE attribute %s for entity %s in\n %s \n is equal to %s" % (attribute, objClass, prettyDN(entry.dn), value))