diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-02 12:32:27 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-02 12:32:27 -0600 |
| commit | a577c62277e3d651b66fd68dbe800bf3ab5c4921 (patch) | |
| tree | 7ae4e79fc84c539c12fb0313d0d3cc929b2e12ae /app/server_test.go | |
| parent | c2b8edab01b23fde6cc196a3349ad6aa19a93299 (diff) | |
| parent | 0b610d061e45811130d8cf3919037fdc9513e340 (diff) | |
Merge branch 'rs' into 'main'
Re-write the authorization daemon in rust
See merge request gitlab-org/software-supply-chain-security/authorization/authzd!1
Diffstat (limited to 'app/server_test.go')
| -rw-r--r-- | app/server_test.go | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/app/server_test.go b/app/server_test.go deleted file mode 100644 index ff34487a..00000000 --- a/app/server_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package app - -import ( - "context" - "net" - "testing" - - auth "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/test/bufconn" -) - -type HTTPRequest = auth.AttributeContext_HttpRequest - -func TestServer(t *testing.T) { - socket := bufconn.Listen(1024 * 1024) - srv := NewServer(t.Context()) - - defer srv.GracefulStop() - go func() { - require.NoError(t, srv.Serve(socket)) - }() - - connection, err := grpc.DialContext( - t.Context(), - "bufnet", - grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) { - return socket.Dial() - }), - grpc.WithTransportCredentials(insecure.NewCredentials()), - ) - require.NoError(t, err) - defer connection.Close() - - client := auth.NewAuthorizationClient(connection) - - t.Run("CheckRequest", func(t *testing.T) { - tt := []struct { - http *HTTPRequest - status codes.Code - }{ - {status: codes.OK, http: &HTTPRequest{Method: "GET", Path: "/"}}, - } - - for _, example := range tt { - t.Run(example.http.Path, func(t *testing.T) { - response, err := client.Check(t.Context(), &auth.CheckRequest{ - Attributes: &auth.AttributeContext{ - Request: &auth.AttributeContext_Request{ - Http: example.http, - }, - }, - }) - require.NoError(t, err) - assert.Equal(t, int32(example.status), response.Status.Code) - }) - } - }) -} |
