Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Oğuzhan Durgun <oguzhandurgun95@gmail.com>
  • Loading branch information
oguzhand95 committed May 15, 2023
1 parent b304641 commit 2e9b1a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/client_test.go
Expand Up @@ -79,7 +79,7 @@ func TestClient(t *testing.T) {
c, err := client.New(port.addr, tc.opts...)
require.NoError(t, err)

t.Run(port.name, client.TestGRPCClient(c.With(client.AuxDataJWT(jwt, ""))))
t.Run(port.name, client.TestGRPCClient(c))
}
})

Expand Down
10 changes: 9 additions & 1 deletion client/tests.go
Expand Up @@ -35,7 +35,10 @@ func TestGRPCClient(c Client) func(*testing.T) {
//nolint:thelper
return func(t *testing.T) {
token := GenerateToken(t, time.Now().Add(5*time.Minute)) //nolint:gomnd
c := c.With(AuxDataJWT(token, ""))
c := c.With(
AuxDataJWT(token, ""),
IncludeMeta(true),
)
t.Run("CheckResourceSet", func(t *testing.T) {
ctx, cancelFunc := context.WithTimeout(context.Background(), timeout)
defer cancelFunc()
Expand Down Expand Up @@ -65,6 +68,7 @@ func TestGRPCClient(c Client) func(*testing.T) {
require.True(t, have.IsAllowed("XX125", "view:public"))
require.False(t, have.IsAllowed("XX125", "approve"))
require.True(t, have.IsAllowed("XX125", "defer"))
require.NotNil(t, have.Meta, "no metadata found")
})

t.Run("CheckResourceBatch", func(t *testing.T) {
Expand Down Expand Up @@ -184,6 +188,8 @@ func TestGRPCClient(c Client) func(*testing.T) {

have, err := c.CheckResources(ctx, principal, resources)
check(t, have, err)

require.NotNil(t, have.Results[0].Meta, "no metadata found in the result")
})

t.Run("WithPrincipal", func(t *testing.T) {
Expand All @@ -192,6 +198,8 @@ func TestGRPCClient(c Client) func(*testing.T) {

have, err := c.WithPrincipal(principal).CheckResources(ctx, resources)
check(t, have, err)

require.NotNil(t, have.Results[0].Meta, "no metadata found in the result")
})
})

Expand Down

0 comments on commit 2e9b1a4

Please sign in to comment.