MCPcopy Index your code
hub / github.com/coder/coder / convertObjects

Method convertObjects

coderd/coderdtest/authorize.go:113–134  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

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.
113func (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.

Callers 2

AssertCheckedMethod · 0.95
AssertInOrderMethod · 0.95

Calls 7

ResourceUserObjectFunction · 0.92
InOrgMethod · 0.80
WithOwnerMethod · 0.80
RBACObjectMethod · 0.65
WithIDMethod · 0.45
StringMethod · 0.45
FatalfMethod · 0.45

Tested by

no test coverage detected