Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo, rename method #6

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Config[T any] map[string]map[string]T
// Get returns the config value for the given request.
func (c Config[T]) Get(path string) (v T, err error) {
if c == nil {
return v, fmt.Errorf("cofig is nil")
return v, fmt.Errorf("config is nil")
}

p := strings.Split(path, "/")
Expand All @@ -65,13 +65,13 @@ func (c Config[T]) Get(path string) (v T, err error) {
return v, nil
}

// VerifyACL checks that the given ACL config is valid for the given service.
// Verify checks that the given config is valid for the given service.
// It can be used in unit tests to ensure that all methods are covered.
func (acl Config[any]) VerifyACL(webrpcServices map[string][]string) error {
func (c Config[any]) Verify(webrpcServices map[string][]string) error {
var errList []error
for service, methods := range webrpcServices {
for _, method := range methods {
if _, ok := acl[service][method]; !ok {
if _, ok := c[service][method]; !ok {
errList = append(errList, fmt.Errorf("%s.%s not found", service, method))
}
}
Expand Down
8 changes: 4 additions & 4 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func executeRequest(t *testing.T, ctx context.Context, handler http.Handler, pat
return true, nil
}

func TestVerifyACL(t *testing.T) {
func TestVerify(t *testing.T) {
services := map[string][]string{
"Service1": {
"Method1",
Expand All @@ -71,7 +71,7 @@ func TestVerifyACL(t *testing.T) {
},
}

err := acl.VerifyACL(services)
err := acl.Verify(services)
assert.NoError(t, err)

// Wrong Service
Expand All @@ -86,7 +86,7 @@ func TestVerifyACL(t *testing.T) {
},
}

err = acl.VerifyACL(services)
err = acl.Verify(services)
require.Error(t, err)

expectedErrors := []error{
Expand All @@ -106,7 +106,7 @@ func TestVerifyACL(t *testing.T) {
},
}

err = acl.VerifyACL(services)
err = acl.Verify(services)
require.Error(t, err)

expectedErrors = []error{
Expand Down
Loading