mirror of
https://github.com/status-im/consul.git
synced 2025-01-23 03:59:18 +00:00
aaefe15613
* First pass for helper for bulk changes Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Convert ACLRead and ACLWrite to new form Signed-off-by: Mark Anderson <manderson@hashicorp.com> * AgentRead and AgentWRite Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Fix EventWrite Signed-off-by: Mark Anderson <manderson@hashicorp.com> * KeyRead, KeyWrite, KeyList Signed-off-by: Mark Anderson <manderson@hashicorp.com> * KeyRing Signed-off-by: Mark Anderson <manderson@hashicorp.com> * NodeRead NodeWrite Signed-off-by: Mark Anderson <manderson@hashicorp.com> * OperatorRead and OperatorWrite Signed-off-by: Mark Anderson <manderson@hashicorp.com> * PreparedQuery Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Intention partial Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Fix ServiceRead, Write ,etc Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Error check ServiceRead? Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Fix Sessionread/Write Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Fixup snapshot ACL Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Error fixups for txn Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Add changelog Signed-off-by: Mark Anderson <manderson@hashicorp.com> * Fixup review comments Signed-off-by: Mark Anderson <manderson@hashicorp.com>
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package acl
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPermissionDeniedError(t *testing.T) {
|
|
type testCase struct {
|
|
err PermissionDeniedError
|
|
expected string
|
|
}
|
|
|
|
testName := func(t testCase) string {
|
|
return t.expected
|
|
}
|
|
|
|
auth1 := mockAuthorizer{}
|
|
|
|
cases := []testCase{
|
|
{
|
|
err: PermissionDeniedError{},
|
|
expected: "Permission denied",
|
|
},
|
|
{
|
|
err: PermissionDeniedError{Cause: "simon says"},
|
|
expected: "Permission denied: simon says",
|
|
},
|
|
{
|
|
err: PermissionDeniedByACL(&auth1, nil, ResourceService, AccessRead, "foobar"),
|
|
expected: "Permission denied: provided accessor lacks permission 'service:read' on foobar",
|
|
},
|
|
{
|
|
err: PermissionDeniedByACLUnnamed(&auth1, nil, ResourceService, AccessRead),
|
|
expected: "Permission denied: provided accessor lacks permission 'service:read'",
|
|
},
|
|
}
|
|
|
|
for _, tcase := range cases {
|
|
t.Run(testName(tcase), func(t *testing.T) {
|
|
require.Error(t, tcase.err)
|
|
require.Equal(t, tcase.expected, tcase.err.Error())
|
|
})
|
|
}
|
|
}
|