|
1 | | -package rbac |
| 1 | +package authz |
2 | 2 |
|
3 | 3 | import ( |
4 | 4 | "testing" |
5 | 5 |
|
6 | 6 | "github.com/hatchet-dev/hatchet/api/v1/server/oas/gen" |
| 7 | + "github.com/hatchet-dev/hatchet/pkg/auth/rbac" |
7 | 8 | "github.com/hatchet-dev/hatchet/pkg/repository/sqlcv1" |
8 | 9 |
|
9 | 10 | "github.com/stretchr/testify/assert" |
@@ -34,21 +35,21 @@ func operationIdsFromSpec() []string { |
34 | 35 | } |
35 | 36 |
|
36 | 37 | func TestAuthorizeTenantOperations(t *testing.T) { |
37 | | - r, err := NewAuthorizer() |
| 38 | + r, err := newHatchetAuthorizer() |
38 | 39 | assert.Nil(t, err) |
39 | 40 | allOperations := operationIdsFromSpec() |
40 | 41 | for _, operationId := range allOperations { |
41 | | - assert.Equal(t, r.IsAuthorized(sqlcv1.TenantMemberRoleADMIN, operationId), true) |
42 | | - assert.Equal(t, r.IsAuthorized(sqlcv1.TenantMemberRoleOWNER, operationId), true) |
43 | | - if OperationIn(operationId, adminAndOwnerOnly) { |
44 | | - assert.Equal(t, r.IsAuthorized(sqlcv1.TenantMemberRoleMEMBER, operationId), false) |
| 42 | + assert.Equal(t, r.IsAuthorized(string(sqlcv1.TenantMemberRoleADMIN), operationId), true) |
| 43 | + assert.Equal(t, r.IsAuthorized(string(sqlcv1.TenantMemberRoleOWNER), operationId), true) |
| 44 | + if rbac.OperationIn(operationId, adminAndOwnerOnly) { |
| 45 | + assert.Equal(t, r.IsAuthorized(string(sqlcv1.TenantMemberRoleMEMBER), operationId), false) |
45 | 46 | } else { |
46 | | - assert.Equal(t, r.IsAuthorized(sqlcv1.TenantMemberRoleMEMBER, operationId), true) |
| 47 | + assert.Equal(t, r.IsAuthorized(string(sqlcv1.TenantMemberRoleMEMBER), operationId), true) |
47 | 48 | } |
48 | 49 | } |
49 | 50 | } |
50 | 51 |
|
51 | 52 | func TestValidateSpec(t *testing.T) { |
52 | | - _, err := NewAuthorizer() |
| 53 | + _, err := newHatchetAuthorizer() |
53 | 54 | assert.Nil(t, err) |
54 | 55 | } |
0 commit comments