Add real subject ACL support and tests.

This commit is contained in:
Ian Gulliver
2014-05-19 20:52:57 +03:00
parent c361d41fcf
commit f27fc7977b
4 changed files with 220 additions and 33 deletions

View File

@@ -374,6 +374,83 @@ asyncTest('Reconnect channel', function() {
});
});
asyncTest('subscribe ACL', function() {
expect(2);
var subject = randstring();
logout(function() {
var tempCallbacks = {
'onLogout': function() {
var tempProfile = tempCosmo.profile();
tempCosmo.shutdown();
var callbacks = {
'onLogout': function() {
cosmo.subscribe({
'name': subject,
'readable_only_by': cosmo.profile(),
}).then(function() {
ok(true, 'correct ACL succeeds');
cosmo.subscribe({
'name': subject,
'readable_only_by': tempProfile,
}).then(null, function() {
ok(true, 'bad ACL fails');
cosmo.shutdown();
start();
});
});
},
};
var cosmo = new Cosmopolite(callbacks, null, randstring());
},
};
var tempCosmo = new Cosmopolite(tempCallbacks, null, randstring());
});
});
asyncTest('sendMessage ACL', function() {
expect(2);
var subject = randstring();
var message = randstring();
logout(function() {
var tempCallbacks = {
'onLogout': function() {
var tempProfile = tempCosmo.profile();
tempCosmo.shutdown();
var callbacks = {
'onLogout': function() {
cosmo.sendMessage({
'name': subject,
'writable_only_by': cosmo.profile(),
}, message).then(function() {
ok(true, 'correct ACL succeeds');
cosmo.sendMessage({
'name': subject,
'writable_only_by': tempProfile,
}, message).then(null, function() {
ok(true, 'bad ACL fails');
cosmo.shutdown();
start();
});
});
},
};
var cosmo = new Cosmopolite(callbacks, null, randstring());
},
};
var tempCosmo = new Cosmopolite(tempCallbacks, null, randstring());
});
});
module('dev_appserver only');