1package ldap 2 3import ( 4 "reflect" 5 "testing" 6) 7 8// TestNewEntry tests that repeated calls to NewEntry return the same value with the same input 9func TestNewEntry(t *testing.T) { 10 dn := "testDN" 11 attributes := map[string][]string{ 12 "alpha": {"value"}, 13 "beta": {"value"}, 14 "gamma": {"value"}, 15 "delta": {"value"}, 16 "epsilon": {"value"}, 17 } 18 executedEntry := NewEntry(dn, attributes) 19 20 iteration := 0 21 for { 22 if iteration == 100 { 23 break 24 } 25 testEntry := NewEntry(dn, attributes) 26 if !reflect.DeepEqual(executedEntry, testEntry) { 27 t.Fatalf("subsequent calls to NewEntry did not yield the same result:\n\texpected:\n\t%v\n\tgot:\n\t%v\n", executedEntry, testEntry) 28 } 29 iteration = iteration + 1 30 } 31} 32 33func TestGetAttributeValue(t *testing.T) { 34 dn := "testDN" 35 attributes := map[string][]string{ 36 "Alpha": {"value"}, 37 "bEta": {"value"}, 38 "gaMma": {"value"}, 39 "delTa": {"value"}, 40 "epsiLon": {"value"}, 41 } 42 entry := NewEntry(dn, attributes) 43 if entry.GetAttributeValue("Alpha") != "value" { 44 t.Errorf("failed to get attribute in original case") 45 } 46 47 if entry.GetEqualFoldAttributeValue("alpha") != "value" { 48 t.Errorf("failed to get attribute in changed case") 49 } 50} 51