convertObjects converts the codersdk types to rbac.Object. Unfortunately does not have type safety, and instead uses a t.Fatal to enforce types.
(t *testing.T, objs ...interface{})
| 111 | // convertObjects converts the codersdk types to rbac.Object. Unfortunately |
| 112 | // does not have type safety, and instead uses a t.Fatal to enforce types. |
| 113 | func (RBACAsserter) convertObjects(t *testing.T, objs ...interface{}) []rbac.Object { |
| 114 | converted := make([]rbac.Object, 0, len(objs)) |
| 115 | for _, obj := range objs { |
| 116 | var robj rbac.Object |
| 117 | switch obj := obj.(type) { |
| 118 | case rbac.Object: |
| 119 | robj = obj |
| 120 | case rbac.Objecter: |
| 121 | robj = obj.RBACObject() |
| 122 | case codersdk.TemplateVersion: |
| 123 | robj = rbac.ResourceTemplate.InOrg(obj.OrganizationID) |
| 124 | case codersdk.User: |
| 125 | robj = rbac.ResourceUserObject(obj.ID) |
| 126 | case codersdk.Workspace: |
| 127 | robj = rbac.ResourceWorkspace.WithID(obj.ID).InOrg(obj.OrganizationID).WithOwner(obj.OwnerID.String()) |
| 128 | default: |
| 129 | t.Fatalf("unsupported type %T to convert to rbac.Object, add the implementation", obj) |
| 130 | } |
| 131 | converted = append(converted, robj) |
| 132 | } |
| 133 | return converted |
| 134 | } |
| 135 | |
| 136 | // Reset will clear all previously recorded authz calls. |
| 137 | // This is helpful when wanting to ignore checks run in test setup. |
no test coverage detected