Skip to content

Commit

Permalink
test the operator list is up to date when a new operator is added
Browse files Browse the repository at this point in the history
  • Loading branch information
kerphi committed Jan 13, 2013
1 parent 41cf616 commit 4f3aff2
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions server/tests/channels-op.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,25 @@ vows.describe('Channel operator rights tests').addBatch({
jar: j1,
}, callback);
},
// [11] u2 get the operator list
function USER2OPLIST3(callback) {
request({
method: 'GET',
url: baseurl + '/server/channels/' + cid1 + '/op/',
jar: j2,
}, callback);
},

// `server/channels/:cid/op/:uid` - DELETE - removes operator rights to :uid on :cid channel (try to)
// [11] u1 try to remove op rights to u2
// [12] u1 try to remove op rights to u2
function USER1REMOVEOP(callback) {
request({
method: 'DELETE',
url: baseurl + '/server/channels/' + cid1 + '/op/' + userdata2.id,
jar: j1,
}, callback);
},
// [12] u2 try to remove op rights to u1
// [13] u2 try to remove op rights to u1
function USER2REMOVEOP(callback) {
request({
method: 'DELETE',
Expand Down Expand Up @@ -253,6 +261,23 @@ vows.describe('Channel operator rights tests').addBatch({
assert.equal(result.statusCode, 200, 'should returns 200 (user1 IS an operator so he can give op rights to other users)');
},

'once user1 gave op rights to user2, the operator list should contain user1 and user2': function (error, results, requests, steps) {
var result = results[steps.USER2OPLIST3][0];
assert.equal(result.statusCode, 200);

var response = {};
try {
response = JSON.parse(result.body);
} catch (err) {
assert.isNull(err, 'response body should be JSON formated');
}

assert.isArray(response);
assert.lengthOf(response, 2);
assert.include(response, userdata1.id);
assert.include(response, userdata2.id);
},

'user1 should be able to remove op rights to user2': function (error, results, requests, steps) {
var result = results[steps.USER1REMOVEOP][0];
assert.equal(result.statusCode, 200, 'should returns 200 (user1 IS an operator so he can remove op rights to other users)');
Expand Down

0 comments on commit 4f3aff2

Please sign in to comment.