mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-17 14:14:22 +01:00
59
test/acl.test.js
Normal file
59
test/acl.test.js
Normal file
@@ -0,0 +1,59 @@
|
||||
const test = require('brittle')
|
||||
const acl = require('../src/acl')
|
||||
|
||||
test('acl', async t => {
|
||||
const repoName = 'foo'
|
||||
|
||||
t.test('setACL', async t => {
|
||||
const aclObj = acl.setACL(repoName)
|
||||
t.is(aclObj.visibility, 'public')
|
||||
t.is(aclObj.protectedBranches.length, 1)
|
||||
t.is(aclObj.protectedBranches[0], 'master')
|
||||
t.is(Object.keys(aclObj.ACL).length, 0)
|
||||
})
|
||||
|
||||
test('getACL', async t => {
|
||||
const aclObj = acl.setACL(repoName)
|
||||
t.alike(acl.getACL(repoName), aclObj)
|
||||
})
|
||||
|
||||
test('makeRepoPublic', async t => {
|
||||
acl.makeRepoPublic(repoName)
|
||||
t.is(acl.getRepoVisibility(repoName), 'public')
|
||||
})
|
||||
|
||||
test('makeRepoPrivate', async t => {
|
||||
acl.makeRepoPrivate(repoName)
|
||||
t.is(acl.getRepoVisibility(repoName), 'private')
|
||||
})
|
||||
|
||||
test('grantAccessToUser', async t => {
|
||||
acl.grantAccessToUser(repoName, 'user1', 'admin')
|
||||
t.alike(acl.getUserRole(repoName, 'user1'), 'admin')
|
||||
})
|
||||
|
||||
test('addProtectedBranch', async t => {
|
||||
acl.addProtectedBranch(repoName, 'branch1')
|
||||
t.is(acl.getACL(repoName).protectedBranches.length, 2)
|
||||
})
|
||||
|
||||
test('removeProtectedBranch', async t => {
|
||||
acl.removeProtectedBranch(repoName, 'branch1')
|
||||
t.is(acl.getACL(repoName).protectedBranches.length, 1)
|
||||
})
|
||||
|
||||
test('getAdmins', async t => {
|
||||
acl.grantAccessToUser(repoName, 'user2', 'admin')
|
||||
t.alike(acl.getAdmins(repoName), ['user1', 'user2'])
|
||||
})
|
||||
|
||||
test('getContributors', async t => {
|
||||
acl.grantAccessToUser(repoName, 'user3', 'contributor')
|
||||
t.alike(acl.getContributors(repoName), ['user3', 'user1', 'user2'])
|
||||
})
|
||||
|
||||
test('getViewers', async t => {
|
||||
acl.grantAccessToUser(repoName, 'user4', 'viewer')
|
||||
t.alike(acl.getViewers(repoName), ['user4', 'user3', 'user1', 'user2'])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user