Skip to content

Commit 28b7337

Browse files
committed
Merge branch 'r1.0.1'
2 parents c51ea3c + 1e0ae35 commit 28b7337

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## 1.0.1 (2014-08-11)
4+
5+
[CHANGED] Incorrect arguments to `authenticate` will raise an error
6+
7+
## 1.0.0 (2014-07-14)
8+
9+
First stable release.

lib/pusher.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ Pusher.forCluster = function(cluster, options) {
7979
* @returns {String} authentication signature
8080
*/
8181
Pusher.prototype.authenticate = function(socketId, channel, data) {
82+
if (typeof socketId !== "string" || socketId === "") {
83+
throw new Error("Invalid socket id: '" + socketId + "'");
84+
}
85+
if (typeof channel !== "string" || channel === "") {
86+
throw new Error("Invalid channel name: '" + channel + "'");
87+
}
8288
return auth.getSocketSignature(this.config.token, channel, socketId, data);
8389
};
8490

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "pusher",
33
"description": "Node.js client to interact with the Pusher REST API",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"author": "Pusher <[email protected]>",
66
"contributors": [
77
{

tests/integration/pusher/authenticate.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,41 @@ describe("Pusher", function() {
6666
channel_data: "{\"foo\":\"bar\"}"
6767
});
6868
});
69+
70+
it("should raise an exception if socket id is not a string", function() {
71+
expect(function() {
72+
pusher.authenticate(undefined, "test")
73+
}).to.throwException(/^Invalid socket id: 'undefined'$/);
74+
expect(function() {
75+
pusher.authenticate(null, "test")
76+
}).to.throwException(/^Invalid socket id: 'null'$/);
77+
expect(function() {
78+
pusher.authenticate(111, "test")
79+
}).to.throwException(/^Invalid socket id: '111'$/);
80+
});
81+
82+
it("should raise an exception if socket id is an empty string", function() {
83+
expect(function() {
84+
pusher.authenticate("", "test")
85+
}).to.throwException(/^Invalid socket id: ''$/);
86+
});
87+
88+
it("should raise an exception if channel name is not a string", function() {
89+
expect(function() {
90+
pusher.authenticate("111.222", undefined)
91+
}).to.throwException(/^Invalid channel name: 'undefined'$/);
92+
expect(function() {
93+
pusher.authenticate("111.222", null)
94+
}).to.throwException(/^Invalid channel name: 'null'$/);
95+
expect(function() {
96+
pusher.authenticate("111.222", 111)
97+
}).to.throwException(/^Invalid channel name: '111'$/);
98+
});
99+
100+
it("should raise an exception if channel name is an empty string", function() {
101+
expect(function() {
102+
pusher.authenticate("111.222", "")
103+
}).to.throwException(/^Invalid channel name: ''$/);
104+
});
69105
});
70106
});

0 commit comments

Comments
 (0)