def testGetNameFromGroupUIDNone(self): groupuid = '0000-000' self.mox.StubOutWithMock(ds, 'DSGetRecordNameFromUUID') ds.DSGetRecordNameFromUUID('group', groupuid).AndReturn(None) self.mox.ReplayAll() self.assertEqual(ds._GetNameFromGroupUID(groupuid), None) self.mox.VerifyAll()
def testGetGroupMembership(self): groupname = 'somegroup' members = [u'asdf', u'asdfaaa'] guids = [u'000-111-aaa', u'121123-aaaa'] ldap = 'ldap.corp' self.mox.StubOutWithMock(ds, '_GetNameFromGroupUID') self.mox.StubOutWithMock(ds, 'DSQuery') ds.DSQuery('group', groupname, attribute='GroupMembership').AndReturn(members) ds.DSQuery('group', groupname, attribute='NestedGroups').AndReturn(guids) ds._GetNameFromGroupUID(guids[0], ldap_server=ldap).AndReturn(None) ds._GetNameFromGroupUID(guids[1], ldap_server=ldap).AndReturn('humanreadable') self.mox.ReplayAll() result = ds.GetGroupMembership(groupname, ldap_server=ldap) self.assertEqual(result, (members, [guids[0], 'humanreadable'])) self.mox.VerifyAll()
def testGetNameFromGroupUIDError(self): groupuid = '0000-000' self.mox.StubOutWithMock(ds, 'DSGetRecordNameFromUUID') ds.DSGetRecordNameFromUUID('group', groupuid).AndReturn(None) ds.DSGetRecordNameFromUUID('group', groupuid, node='/LDAPv3/blah').AndRaise( ds.DSException('something')) self.mox.ReplayAll() self.assertEqual(ds._GetNameFromGroupUID(groupuid, ldap_server='blah'), None) self.mox.VerifyAll()