From 44fb4dfbe5d3ccbe2b548dddba4d9bab84919066 Mon Sep 17 00:00:00 2001 From: Ashutosh Narkar Date: Fri, 26 May 2023 10:07:17 -0700 Subject: [PATCH] internal: Update test that exercises ND cache functionality to use local server Signed-off-by: Ashutosh Narkar --- internal/internal_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/internal_test.go b/internal/internal_test.go index 36afb1a7d..6f2edaa58 100644 --- a/internal/internal_test.go +++ b/internal/internal_test.go @@ -423,6 +423,13 @@ func TestCheckDenyWithLogger(t *testing.T) { func TestCheckAllowWithLoggerNDBCache(t *testing.T) { + // test server + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + })) + + defer ts.Close() + exampleRequest := `{ "attributes": { "request": { @@ -441,16 +448,17 @@ func TestCheckAllowWithLoggerNDBCache(t *testing.T) { // create custom logger customLogger := &testPlugin{} - module := ` + module := fmt.Sprintf(` package envoy.authz default allow = false allow { - res := http.send({"url": "http://httpbin.org", "method": "GET"}) + res := http.send({"url": "%s", "method": "GET"}) res.status_code == 200 } -` +`, ts.URL) + server := testAuthzServerWithModule(module, "envoy/authz/allow", customLogger, false, false) ctx := context.Background() output, err := server.Check(ctx, &req)