Skip to content

Commit

Permalink
Fix typo, rename method (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
klaidliadon authored Oct 24, 2024
1 parent 97f2559 commit 733cff5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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

0 comments on commit 733cff5

Please sign in to comment.