MCPcopy Create free account
hub / github.com/apache/casbin-server / testHasRole

Function testHasRole

server/rbac_api_test.go:61–71  ·  view source on GitHub ↗
(t *testing.T, e *testEngine, name string, role string, res bool)

Source from the content-addressed store, hash-verified

59}
60
61func testHasRole(t *testing.T, e *testEngine, name string, role string, res bool) {
62 t.Helper()
63 reply, err := e.s.HasRoleForUser(e.ctx, &pb.UserRoleRequest{EnforcerHandler: e.h, User: name, Role: role})
64 assert.NoError(t, err)
65
66 t.Log(name, " has role ", role, ": ", reply.Res)
67
68 if res != reply.Res {
69 t.Error(name, " has role ", role, ": ", reply.Res, ", supposed to be ", res)
70 }
71}
72
73func TestRoleAPI(t *testing.T) {
74 e := newTestEngine(t, "file", "../examples/rbac_policy.csv", "../examples/rbac_model.conf")

Callers 1

TestRoleAPIFunction · 0.85

Calls 1

HasRoleForUserMethod · 0.65

Tested by

no test coverage detected