Skip to content

Commit

Permalink
internal: Update test that exercises ND cache functionality to use lo…
Browse files Browse the repository at this point in the history
…cal server

Signed-off-by: Ashutosh Narkar <[email protected]>
  • Loading branch information
ashutosh-narkar committed May 26, 2023
1 parent 20e46f6 commit 44fb4df
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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)
Expand Down

0 comments on commit 44fb4df

Please sign in to comment.