mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: Add initial AuthzQuerier implementation (#5919)
feat: Add initial AuthzQuerier implementation - Adds package database/dbauthz that adds a database.Store implementation where each method goes through AuthZ checks - Implements all database.Store methods on AuthzQuerier - Updates and fixes unit tests where required - Updates coderd initialization to use AuthzQuerier if codersdk.ExperimentAuthzQuerier is enabled
This commit is contained in:
32
coderd/rbac/error_test.go
Normal file
32
coderd/rbac/error_test.go
Normal file
@ -0,0 +1,32 @@
|
||||
package rbac_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/coder/coder/coderd/rbac"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
func TestIsUnauthorizedError(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("NotWrapped", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
errFunc := func() error {
|
||||
return rbac.UnauthorizedError{}
|
||||
}
|
||||
|
||||
err := errFunc()
|
||||
require.True(t, rbac.IsUnauthorizedError(err))
|
||||
})
|
||||
|
||||
t.Run("Wrapped", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
errFunc := func() error {
|
||||
return xerrors.Errorf("test error: %w", rbac.UnauthorizedError{})
|
||||
}
|
||||
err := errFunc()
|
||||
require.True(t, rbac.IsUnauthorizedError(err))
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user