diff --git a/dovecot/dict_test.go b/dovecot/dict_test.go index 8f03d12007ebb15c0fc2745e8470a0e4715d1fd8..61446476a9f19ada7813e0f580347ebd819d6912 100644 --- a/dovecot/dict_test.go +++ b/dovecot/dict_test.go @@ -2,6 +2,7 @@ package dovecot import ( "context" + "io/ioutil" "log" "net/textproto" "os" @@ -53,7 +54,7 @@ func newTestDictDatabase() *testDictDatabase { func newTestSocketServer(t *testing.T) (string, func()) { t.Helper() - dir, err := os.MkdirTemp("", "") + dir, err := ioutil.TempDir("", "") if err != nil { t.Fatal(err) } @@ -81,7 +82,7 @@ func newTestSocketServer(t *testing.T) (string, func()) { } } -func makeTestRequest(t *testing.T, socketPath string, version int, lookupKey string, expectedStatus byte) { +func makeTestRequest(t *testing.T, socketPath string, version int, lookupKey, expected string) { conn, err := textproto.Dial("unix", socketPath) if err != nil { t.Fatalf("dialing socket: %v", err) @@ -109,8 +110,8 @@ func makeTestRequest(t *testing.T, socketPath string, version int, lookupKey str if err != nil { t.Fatalf("error reading HELLO response: %v", err) } - if resp[0] != expectedStatus { - t.Fatalf("request returned unexpected status: %s, expected %c", resp, expectedStatus) + if resp != expected { + t.Fatalf("unexpected response: got '%s', expected '%s'", resp, expected) } } @@ -118,7 +119,8 @@ func TestLookup(t *testing.T) { socketPath, cleanup := newTestSocketServer(t) defer cleanup() - makeTestRequest(t, socketPath, 2, "pass/foo", 'O') - makeTestRequest(t, socketPath, 3, "pass/foo", 'O') - makeTestRequest(t, socketPath, 3, "unknown", 'N') + makeTestRequest(t, socketPath, 2, "pass/foo", "O{\"password\":\"bar\"}") + makeTestRequest(t, socketPath, 3, "pass/foo", "O{\"password\":\"bar\"}") + makeTestRequest(t, socketPath, 2, "unknown", "N") + makeTestRequest(t, socketPath, 3, "unknown", "N") }