From d3026f9b3e574db015e63819fd0f72c8bf4b528c Mon Sep 17 00:00:00 2001 From: icepie Date: Thu, 12 Oct 2023 13:37:49 +0800 Subject: [PATCH] test: add TestRequestDigestAuthWithBody --- request_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/request_test.go b/request_test.go index fd1222c5..7312128f 100644 --- a/request_test.go +++ b/request_test.go @@ -722,6 +722,25 @@ func TestRequestDigestAuthFail(t *testing.T) { logResponse(t, resp) } +func TestRequestDigestAuthWithBody(t *testing.T) { + conf := defaultDigestServerConf() + ts := createDigestServer(t, nil) + defer ts.Close() + + resp, err := dclr(). + SetDigestAuth(conf.username, conf.password). + SetResult(&AuthSuccess{}). + SetHeader(hdrContentTypeKey, "application/json"). + SetBody(map[string]interface{}{"zip_code": "00000", "city": "Los Angeles"}). + Post(ts.URL + conf.uri) + + assertError(t, err) + assertEqual(t, http.StatusOK, resp.StatusCode()) + + t.Logf("Result Success: %q", resp.Result().(*AuthSuccess)) + logResponse(t, resp) +} + func TestFormData(t *testing.T) { ts := createFormPostServer(t) defer ts.Close()