@@ -119,7 +119,7 @@ func TestIntegration_Postgres(t *testing.T) {
119119 }
120120
121121 // Associate permissions with roles
122- editorRole := gate .Role ("editor" )
122+ editorRole := gate .Role ("editor" , "web" )
123123 err = editorRole .GivePermissionTo (ctx , "publish:articles" )
124124 if err != nil {
125125 t .Fatalf ("failed to assign publish:articles to editor: %v" , err )
@@ -129,29 +129,29 @@ func TestIntegration_Postgres(t *testing.T) {
129129 t .Fatalf ("failed to assign read:articles to editor: %v" , err )
130130 }
131131
132- viewerRole := gate .Role ("viewer" )
132+ viewerRole := gate .Role ("viewer" , "web" )
133133 err = viewerRole .GivePermissionTo (ctx , "read:articles" )
134134 if err != nil {
135135 t .Fatalf ("failed to assign read:articles to viewer: %v" , err )
136136 }
137137
138- writerRole := gate .Role ("writer" )
138+ writerRole := gate .Role ("writer" , "web" )
139139 err = writerRole .GivePermissionTo (ctx , "create:articles" )
140140 if err != nil {
141141 t .Fatalf ("failed to assign create:articles to writer: %v" , err )
142142 }
143143
144144 // Verify local cache updates
145- if ! gate .HasRolePermission ("editor" , "publish:articles" ) {
145+ if ! gate .HasRolePermission ("web" , " editor" , "publish:articles" ) {
146146 t .Error ("expected editor to have publish:articles in cache" )
147147 }
148- if ! gate .HasRolePermission ("editor" , "read:articles" ) {
148+ if ! gate .HasRolePermission ("web" , " editor" , "read:articles" ) {
149149 t .Error ("expected editor to have read:articles in cache" )
150150 }
151- if ! gate .HasRolePermission ("writer" , "create:articles" ) {
151+ if ! gate .HasRolePermission ("web" , " writer" , "create:articles" ) {
152152 t .Error ("expected writer to have create:articles in cache" )
153153 }
154- if gate .HasRolePermission ("viewer" , "publish:articles" ) {
154+ if gate .HasRolePermission ("web" , " viewer" , "publish:articles" ) {
155155 t .Error ("viewer should not have publish:articles in cache" )
156156 }
157157
@@ -163,7 +163,7 @@ func TestIntegration_Postgres(t *testing.T) {
163163 userInTeam := gate .Model ("users" , userID , teamID )
164164
165165 // Check initially has no access
166- ok , err := userInTeam .Can (ctx , "read:articles" )
166+ ok , err := userInTeam .Can (ctx , "read:articles" , "web" )
167167 if err != nil {
168168 t .Fatalf ("Can failed: %v" , err )
169169 }
@@ -172,13 +172,13 @@ func TestIntegration_Postgres(t *testing.T) {
172172 }
173173
174174 // Assign viewer role in teamID
175- err = userInTeam .AssignRole (ctx , "viewer" )
175+ err = userInTeam .AssignRole (ctx , "viewer" , "web" )
176176 if err != nil {
177177 t .Fatalf ("failed to assign viewer role: %v" , err )
178178 }
179179
180180 // Verify access allowed
181- ok , err = userInTeam .Can (ctx , "read:articles" )
181+ ok , err = userInTeam .Can (ctx , "read:articles" , "web" )
182182 if err != nil {
183183 t .Fatalf ("Can failed: %v" , err )
184184 }
@@ -188,7 +188,7 @@ func TestIntegration_Postgres(t *testing.T) {
188188
189189 // Verify check is scoped to teamID (checking otherTeamID should return false)
190190 userInOtherTeam := gate .Model ("users" , userID , otherTeamID )
191- ok , err = userInOtherTeam .Can (ctx , "read:articles" )
191+ ok , err = userInOtherTeam .Can (ctx , "read:articles" , "web" )
192192 if err != nil {
193193 t .Fatalf ("Can failed: %v" , err )
194194 }
@@ -198,18 +198,18 @@ func TestIntegration_Postgres(t *testing.T) {
198198
199199 // Test case: Fully isolated multi-workspace roles (writer in Team A, viewer in Team B)
200200 userTeamA := gate .Model ("users" , userID , teamID )
201- err = userTeamA .AssignRole (ctx , "writer" )
201+ err = userTeamA .AssignRole (ctx , "writer" , "web" )
202202 if err != nil {
203203 t .Fatalf ("failed to assign writer role in Team A: %v" , err )
204204 }
205205 userTeamB := gate .Model ("users" , userID , otherTeamID )
206- err = userTeamB .AssignRole (ctx , "viewer" )
206+ err = userTeamB .AssignRole (ctx , "viewer" , "web" )
207207 if err != nil {
208208 t .Fatalf ("failed to assign viewer role in Team B: %v" , err )
209209 }
210210
211211 // In Team A (writer role assigned), user has create:articles
212- ok , err = userTeamA .Can (ctx , "create:articles" )
212+ ok , err = userTeamA .Can (ctx , "create:articles" , "web" )
213213 if err != nil {
214214 t .Fatalf ("Can failed: %v" , err )
215215 }
@@ -218,14 +218,14 @@ func TestIntegration_Postgres(t *testing.T) {
218218 }
219219
220220 // In Team B (viewer role assigned), user has read:articles but NOT create:articles
221- ok , err = userTeamB .Can (ctx , "read:articles" )
221+ ok , err = userTeamB .Can (ctx , "read:articles" , "web" )
222222 if err != nil {
223223 t .Fatalf ("Can failed: %v" , err )
224224 }
225225 if ! ok {
226226 t .Error ("expected user to have read:articles access in Team B (viewer)" )
227227 }
228- ok , err = userTeamB .Can (ctx , "create:articles" )
228+ ok , err = userTeamB .Can (ctx , "create:articles" , "web" )
229229 if err != nil {
230230 t .Fatalf ("Can failed: %v" , err )
231231 }
@@ -234,23 +234,23 @@ func TestIntegration_Postgres(t *testing.T) {
234234 }
235235
236236 // Clean up Team A's writer role and Team B's viewer role
237- err = userTeamA .RemoveRole (ctx , "writer" )
237+ err = userTeamA .RemoveRole (ctx , "writer" , "web" )
238238 if err != nil {
239239 t .Fatalf ("failed to remove writer role from Team A: %v" , err )
240240 }
241- err = userTeamB .RemoveRole (ctx , "viewer" )
241+ err = userTeamB .RemoveRole (ctx , "viewer" , "web" )
242242 if err != nil {
243243 t .Fatalf ("failed to remove viewer role from Team B: %v" , err )
244244 }
245245
246246 // Give direct permission override in teamID
247- err = userInTeam .GivePermissionTo (ctx , "admin:settings" )
247+ err = userInTeam .GivePermissionTo (ctx , "admin:settings" , "web" )
248248 if err != nil {
249249 t .Fatalf ("failed to give direct permission: %v" , err )
250250 }
251251
252252 // Verify direct permission works
253- ok , err = userInTeam .Can (ctx , "admin:settings" )
253+ ok , err = userInTeam .Can (ctx , "admin:settings" , "web" )
254254 if err != nil {
255255 t .Fatalf ("Can failed: %v" , err )
256256 }
@@ -259,7 +259,7 @@ func TestIntegration_Postgres(t *testing.T) {
259259 }
260260
261261 // Verify other team has no direct permission
262- ok , err = userInOtherTeam .Can (ctx , "admin:settings" )
262+ ok , err = userInOtherTeam .Can (ctx , "admin:settings" , "web" )
263263 if err != nil {
264264 t .Fatalf ("Can failed: %v" , err )
265265 }
@@ -268,13 +268,13 @@ func TestIntegration_Postgres(t *testing.T) {
268268 }
269269
270270 // Revoke direct permission
271- err = userInTeam .RevokePermissionTo (ctx , "admin:settings" )
271+ err = userInTeam .RevokePermissionTo (ctx , "admin:settings" , "web" )
272272 if err != nil {
273273 t .Fatalf ("failed to revoke direct permission: %v" , err )
274274 }
275275
276276 // Verify direct permission revoked
277- ok , err = userInTeam .Can (ctx , "admin:settings" )
277+ ok , err = userInTeam .Can (ctx , "admin:settings" , "web" )
278278 if err != nil {
279279 t .Fatalf ("Can failed: %v" , err )
280280 }
@@ -283,13 +283,13 @@ func TestIntegration_Postgres(t *testing.T) {
283283 }
284284
285285 // Revoke role viewer
286- err = userInTeam .RemoveRole (ctx , "viewer" )
286+ err = userInTeam .RemoveRole (ctx , "viewer" , "web" )
287287 if err != nil {
288288 t .Fatalf ("failed to remove role: %v" , err )
289289 }
290290
291291 // Verify role revoked
292- ok , err = userInTeam .Can (ctx , "read:articles" )
292+ ok , err = userInTeam .Can (ctx , "read:articles" , "web" )
293293 if err != nil {
294294 t .Fatalf ("Can failed: %v" , err )
295295 }
0 commit comments