From 86ad4fe8bf4bfde9bbe31a63431a508f81032527 Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 23 May 2025 15:41:13 -0600 Subject: test: extract alias for HTTP Request --- pkg/authz/server_test.go | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'pkg') diff --git a/pkg/authz/server_test.go b/pkg/authz/server_test.go index 6740eda..c612146 100644 --- a/pkg/authz/server_test.go +++ b/pkg/authz/server_test.go @@ -18,6 +18,8 @@ import ( "google.golang.org/grpc/test/bufconn" ) +type HTTPRequest = auth.AttributeContext_HttpRequest + func TestServer(t *testing.T) { idp := web.NewOIDCServer(t) defer idp.Close() @@ -55,25 +57,25 @@ func TestServer(t *testing.T) { t.Run("CheckRequest", func(t *testing.T) { tt := []struct { - http *auth.AttributeContext_HttpRequest + http *HTTPRequest status codes.Code }{ - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/application.js"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/callback"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/dashboard", Headers: loggedInHeaders}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/dashboard/nav"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/favicon.ico"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/favicon.png"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/health"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/index.html"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/logo.png"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/signout"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/sparkles"}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "POST", Path: "/sparkles", Headers: loggedInHeaders}}, - {status: codes.OK, http: &auth.AttributeContext_HttpRequest{Method: "POST", Path: "/sparkles/restore"}}, - {status: codes.PermissionDenied, http: &auth.AttributeContext_HttpRequest{Method: "GET", Path: "/dashboard"}}, - {status: codes.PermissionDenied, http: &auth.AttributeContext_HttpRequest{Method: "POST", Path: "/sparkles"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/application.js"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/callback"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/dashboard", Headers: loggedInHeaders}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/dashboard/nav"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/favicon.ico"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/favicon.png"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/health"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/index.html"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/logo.png"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/signout"}}, + {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/sparkles"}}, + {status: codes.OK, http: &HTTPRequest{Method: "POST", Path: "/sparkles", Headers: loggedInHeaders}}, + {status: codes.OK, http: &HTTPRequest{Method: "POST", Path: "/sparkles/restore"}}, + {status: codes.PermissionDenied, http: &HTTPRequest{Method: "GET", Path: "/dashboard"}}, + {status: codes.PermissionDenied, http: &HTTPRequest{Method: "POST", Path: "/sparkles"}}, } for _, example := range tt { -- cgit v1.2.3