2nd
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
const AccesRights = require('../accesRights')
|
||||
let accessRights = new AccesRights({
|
||||
"accessRights": [
|
||||
{
|
||||
"canDo": [
|
||||
"getUserStatus"
|
||||
],
|
||||
"canGet": [
|
||||
"[UID]:userPrefs",
|
||||
"chat:friends",
|
||||
"collaborative:chalkboardUsers"
|
||||
],
|
||||
"canPublish": [
|
||||
"chat:*_*",
|
||||
"collaborative:*",
|
||||
"peer2peer:*",
|
||||
"rendezVous:*"
|
||||
],
|
||||
"canSet": [
|
||||
"[UID]:userPrefs",
|
||||
"chat:friends",
|
||||
"collaborative:chalkboardUsers"
|
||||
],
|
||||
"canSubscribe": [
|
||||
"chat:*_*",
|
||||
"collaborative:*",
|
||||
"peer2peer:*"
|
||||
],
|
||||
"mustSubscribe": [
|
||||
"rendezVous:[UID]",
|
||||
"system:notifs",
|
||||
"system:notifs:[UID]"
|
||||
],
|
||||
"roles": "*"
|
||||
},
|
||||
{
|
||||
"canDo": [
|
||||
"getActiveUsers",
|
||||
"killSessions",
|
||||
"reloadAccessRights",
|
||||
"setPlatformState",
|
||||
"getPlatformState"
|
||||
],
|
||||
"canPublish": [
|
||||
"system:notifs",
|
||||
"system:notifs:*",
|
||||
"infraNotifs:httpGateway",
|
||||
"dataSync:testNike",
|
||||
"infraNotifs:midas",
|
||||
"services:*"
|
||||
],
|
||||
"canSubscribe": [
|
||||
"busconsole:redpill"
|
||||
],
|
||||
"mustSubscribe": [
|
||||
"system:adminNotifs",
|
||||
"system:notifs:[UID]"
|
||||
],
|
||||
"roles": [
|
||||
"EIC_Admin",
|
||||
"EIC_Dev"
|
||||
]
|
||||
},
|
||||
{
|
||||
"canPublish": [
|
||||
"system:notifs"
|
||||
],
|
||||
"canSubscribe": [
|
||||
],
|
||||
"mustSubscribe": [
|
||||
],
|
||||
"roles": [
|
||||
"BP_PO",
|
||||
"BP_SPOC_*",
|
||||
"BP_ADMIN"
|
||||
]
|
||||
},
|
||||
{
|
||||
"canPublish": [
|
||||
"collaborative:shortprop_*"
|
||||
],
|
||||
"canSubscribe": [
|
||||
"collaborative:shortprop_*"
|
||||
],
|
||||
"mustSubscribe": [
|
||||
],
|
||||
"roles": [
|
||||
"ORG_MEMBER"
|
||||
]
|
||||
},
|
||||
{
|
||||
"canDo": [
|
||||
"REDPILL",
|
||||
"BLUEPILL"
|
||||
],
|
||||
"canPublish": [
|
||||
],
|
||||
"canSubscribe": [
|
||||
],
|
||||
"mustSubscribe": [
|
||||
],
|
||||
"roles": [
|
||||
"EIC_Dev"
|
||||
],
|
||||
"uuids": [
|
||||
"steinic"
|
||||
]
|
||||
}
|
||||
],
|
||||
"historize":{
|
||||
"historizeChannels": [ "dataSync:organisationUpdates" ],
|
||||
"historizeMax": 1000,
|
||||
"historizePrefix": "histoChan:"
|
||||
},
|
||||
"actions":{
|
||||
"gatewayActionsChannel": "infraNotifs:httpGateway",
|
||||
"gatewayActionsReply": "system:notifs:[UID]"
|
||||
},
|
||||
"redis":{
|
||||
"basePrefix": "messageBus:",
|
||||
"authTokenPrefix": "authorizer:message_bus_user_"
|
||||
}
|
||||
}, false)
|
||||
|
||||
|
||||
|
||||
test('mustSubscribe', () => {
|
||||
expect(accessRights.mustSubscribe('anon1', ['ANON1'])).toEqual(["rendezVous:anon1", "system:notifs", "system:notifs:anon1"]);
|
||||
});
|
||||
|
||||
test('canSubscribe', () => {
|
||||
expect(accessRights.canSubscribe('anon1', ['ANON1'], 'toto')).toBe(false);
|
||||
expect(accessRights.canSubscribe('anon1', ['ANON1'], 'collaborative:642')).toBe(true);
|
||||
});
|
||||
|
||||
test('isMandatory', () => {
|
||||
expect(accessRights.isMandatory('anon1', ['ANON1'], 'toto')).toBe(false);
|
||||
expect(accessRights.isMandatory('anon1', ['ANON1'], 'system:notifs')).toBe(true);
|
||||
});
|
||||
|
||||
test('canPublish', () => {
|
||||
expect(accessRights.canPublish('anon1', ['ANON1'], 'toto')).toBe(false);
|
||||
expect(accessRights.canPublish('', ['ANON1'], 'collaborative:642')).toBe(true);
|
||||
expect(accessRights.canPublish('', ['ANON1'], 'collaborative:642')).toBe(true);
|
||||
expect(accessRights.canPublish('', ['ANON1'], 'collaborative:642')).toBe(true);
|
||||
});
|
||||
|
||||
test('canDo', () => {
|
||||
expect(accessRights.canDo(['TEST1', 'TEST2'], 'getActiveUsers')).toBe(false);
|
||||
expect(accessRights.canDo(['EIC_Dev', 'TEST2'], 'killSessions')).toBe(true);
|
||||
expect(accessRights.canDo(['EIC_Dev', 'TEST2'], 'crashplatform')).toBe(false);
|
||||
expect(accessRights.canDo(['EIC_Dev'], 'reloadAccessRights')).toBe(true);
|
||||
//expect(accessRights.canDo(['marklogic', 'smed'], 'TIME')).toBe(true);
|
||||
|
||||
expect(accessRights.canDo(['PROJECT_Hack'], 'REDPILL')).toBe(false);
|
||||
expect(accessRights.canDo(['PROJECT_Hack'], 'REDPILL', 'steinic')).toBe(false);
|
||||
expect(accessRights.canDo(['EIC_Dev'], 'REDPILL')).toBe(false);
|
||||
expect(accessRights.canDo(['EIC_Dev'], 'REDPILL', 'pirate')).toBe(false);
|
||||
expect(accessRights.canDo(['EIC_Dev'], 'REDPILL', 'steinic')).toBe(true);
|
||||
expect(accessRights.canDo(['EIC_Dev'], 'BLUEPILL', 'pirate')).toBe(false);
|
||||
expect(accessRights.canDo(['EIC_Dev'], 'BLUEPILL', 'steinic')).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user