Merge pull request #19301 from overleaf/jdt-collaborator-ai-usage
Prevent AI usage on projects where collaborators have a blocking policy GitOrigin-RevId: 93bdd9c5accff51a14f0585249e13ed7f1fa4e53
This commit is contained in:
committed by
Copybot
parent
22c4caa02d
commit
918c3e7e33
@@ -30,6 +30,38 @@ describe('PermissionsManager', function () {
|
||||
this.PermissionsManager.registerCapability('capability4', {
|
||||
default: false,
|
||||
})
|
||||
this.PermissionsManager.registerPolicy('openPolicy', {
|
||||
capability1: true,
|
||||
capability2: true,
|
||||
})
|
||||
this.PermissionsManager.registerPolicy('restrictivePolicy', {
|
||||
capability1: true,
|
||||
capability2: false,
|
||||
})
|
||||
this.openPolicyResponseSet = [
|
||||
[
|
||||
{
|
||||
managedUsersEnabled: true,
|
||||
groupPolicy: { openPolicy: true },
|
||||
},
|
||||
{
|
||||
managedUsersEnabled: true,
|
||||
groupPolicy: { openPolicy: true },
|
||||
},
|
||||
],
|
||||
]
|
||||
this.restrictivePolicyResponseSet = [
|
||||
[
|
||||
{
|
||||
managedUsersEnabled: true,
|
||||
groupPolicy: { openPolicy: true },
|
||||
},
|
||||
{
|
||||
managedUsersEnabled: true,
|
||||
groupPolicy: { restrictivePolicy: true },
|
||||
},
|
||||
],
|
||||
]
|
||||
})
|
||||
|
||||
describe('hasPermission', function () {
|
||||
@@ -717,4 +749,36 @@ describe('PermissionsManager', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('checkUserListPermissions', function () {
|
||||
it('should return true when all users have permissions required', async function () {
|
||||
const userList = ['user1', 'user2', 'user3']
|
||||
const capabilities = ['capability1', 'capability2']
|
||||
this.hooksFire.onCall(0).resolves(this.openPolicyResponseSet)
|
||||
this.hooksFire.onCall(1).resolves(this.openPolicyResponseSet)
|
||||
this.hooksFire.onCall(2).resolves(this.openPolicyResponseSet)
|
||||
|
||||
const usersHavePermission =
|
||||
await this.PermissionsManager.promises.checkUserListPermissions(
|
||||
userList,
|
||||
capabilities
|
||||
)
|
||||
expect(usersHavePermission).to.equal(true)
|
||||
})
|
||||
|
||||
it('should return false if any user does not have permission', async function () {
|
||||
const userList = ['user1', 'user2', 'user3']
|
||||
const capabilities = ['capability1', 'capability2']
|
||||
this.hooksFire.onCall(0).resolves(this.openPolicyResponseSet)
|
||||
this.hooksFire.onCall(1).resolves(this.restrictivePolicyResponseSet)
|
||||
this.hooksFire.onCall(2).resolves(this.openPolicyResponseSet)
|
||||
|
||||
const usersHavePermission =
|
||||
await this.PermissionsManager.promises.checkUserListPermissions(
|
||||
userList,
|
||||
capabilities
|
||||
)
|
||||
expect(usersHavePermission).to.equal(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user