Skip to content

Test management page needs to be developed #54

Description

@hsluoyz

Currently, we have visualized model, adapter, enforcer pages. We also need to add a test page to hold all test cases for an enforcer: https://github.com/casbin/casbin/blob/master/model_test.go

So the enforcer can tested for its correctness at any time. As an example:

A test is: (id, name, created_time, test_cases)
A test_case is: (id=TestBasicModel, test_assertions)
A test_assertion is: (request, true/false)
A request is: (sub="alice", obj="data1", act="read")

func TestBasicModel(t *testing.T) {
	e, _ := NewEnforcer("examples/basic_model.conf", "examples/basic_policy.csv")

	testEnforce(t, e, "alice", "data1", "read", true)
	testEnforce(t, e, "alice", "data1", "write", false)
	testEnforce(t, e, "alice", "data2", "read", false)
	testEnforce(t, e, "alice", "data2", "write", false)
	testEnforce(t, e, "bob", "data1", "read", false)
	testEnforce(t, e, "bob", "data1", "write", false)
	testEnforce(t, e, "bob", "data2", "read", false)
	testEnforce(t, e, "bob", "data2", "write", true)
}
  • A test can be bound to one enforcer or multiple enforcers.
  • An enforcer can bound to 0, 1 or multiple tests.

A user can click a button to test an enforcer against its bound tests.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions