Skip to content

Commit b7f39f4

Browse files
author
Devendra
committed
adding wildcard grant test
1 parent 8b03310 commit b7f39f4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

node.js/tests/test.js

+43
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,49 @@ describe('Pubnub', function () {
952952
}, 5000);
953953
});
954954

955+
it('should be able to grant read write access for wildcard channel', function (done) {
956+
var auth_key = "abcd";
957+
var grant_channel_local = grant_channel + "-" + Date.now() + ".";
958+
setTimeout(function () {
959+
pubnub.grant({
960+
channel: grant_channel_local + "*",
961+
'auth_key': auth_key,
962+
read: true,
963+
write: true,
964+
callback: function () {
965+
pubnub.audit({
966+
channel: grant_channel_local + "*",
967+
'auth_key': auth_key,
968+
callback: function (response) {
969+
assert.deepEqual(response.auths[auth_key].r, 1);
970+
assert.deepEqual(response.auths[auth_key].w, 1);
971+
pubnub.history({
972+
'channel': grant_channel_local + "a",
973+
'auth_key': auth_key,
974+
'callback': function () {
975+
pubnub.publish({
976+
'channel': grant_channel_local + "a",
977+
'auth_key': auth_key,
978+
'message': 'Test',
979+
'callback': function () {
980+
done();
981+
},
982+
'error': function () {
983+
done(new Error("Unable to publish to granted channel"));
984+
}
985+
})
986+
},
987+
'error': function () {
988+
done(new Error("Unable to get history of granted channel"));
989+
}
990+
});
991+
}
992+
});
993+
}
994+
})
995+
}, 5000);
996+
});
997+
955998
it('should be able to grant read write access without auth key', function (done) {
956999
var grant_channel_local = grant_channel + Date.now();
9571000
setTimeout(function () {

0 commit comments

Comments
 (0)