mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
8dc4d76890
<!-- If you have used AI to produce some or all of this PR, please ensure you have read our [AI Contribution guidelines](https://coder.com/docs/about/contributing/AI_CONTRIBUTING) before submitting. --> relates to GRU-18 Adds basic implementation for Workspace Agent Connection Watch and tests. Missing are handling of logs.
32 lines
775 B
Go
32 lines
775 B
Go
package coderdtest
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/coder/coder/v2/coderd/rbac"
|
|
"github.com/coder/coder/v2/coderd/rbac/rolestore"
|
|
)
|
|
|
|
func MemberSubject(userID, orgID uuid.UUID) rbac.Subject {
|
|
memberRole, err := rbac.RoleByName(rbac.RoleMember())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
orgMember, err := rolestore.TestingGetSystemRole(
|
|
rbac.RoleOrgMember(),
|
|
orgID,
|
|
rbac.OrgSettings{ShareableWorkspaceOwners: rbac.ShareableWorkspaceOwnersNone},
|
|
)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return rbac.Subject{
|
|
FriendlyName: "coderdtest-member",
|
|
Email: "member@coderd.test",
|
|
Type: rbac.SubjectTypeUser,
|
|
ID: userID.String(),
|
|
Roles: rbac.Roles{memberRole, orgMember},
|
|
Scope: rbac.ScopeAll,
|
|
}.WithCachedASTValue()
|
|
}
|