-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send invites as owner if added via an admin api key
- Loading branch information
1 parent
66f16f8
commit f63963d
Showing
3 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,14 @@ var should = require('should'), | |
|
||
describe('Invites API', function () { | ||
before(testUtils.teardown); | ||
before(testUtils.setup('invites', 'settings', 'users:roles', 'perms:invite', 'perms:init')); | ||
before(testUtils.setup( | ||
'invites', | ||
'settings', | ||
'users:roles', | ||
'api_keys', | ||
'perms:invite', | ||
'perms:init' | ||
)); | ||
|
||
beforeEach(function () { | ||
sandbox.stub(mail, 'send').callsFake(function () { | ||
|
@@ -440,5 +447,65 @@ describe('Invites API', function () { | |
}).catch(done); | ||
}); | ||
}); | ||
|
||
describe('Admin API Key', function () { | ||
it('CANNOT invite an Owner', function (done) { | ||
InvitesAPI.add({ | ||
invites: [ | ||
{ | ||
email: '[email protected]', | ||
role_id: testUtils.roles.ids.owner | ||
} | ||
] | ||
}, testUtils.context.admin_api_key).then(function () { | ||
done(new Error('API Key should not be able to add an owner')); | ||
}).catch(checkForErrorType('NoPermissionError', done)); | ||
}); | ||
|
||
it('Can invite an Admin', function (done) { | ||
InvitesAPI.add({ | ||
invites: [ | ||
{ | ||
email: '[email protected]', | ||
role_id: testUtils.roles.ids.admin | ||
} | ||
] | ||
}, _.merge({}, {include: 'roles'}, testUtils.context.admin_api_key)).then(function (response) { | ||
checkAddResponse(response); | ||
response.invites[0].role_id.should.equal(testUtils.roles.ids.admin); | ||
done(); | ||
}).catch(done); | ||
}); | ||
|
||
it('Can invite an Editor', function (done) { | ||
InvitesAPI.add({ | ||
invites: [ | ||
{ | ||
email: '[email protected]', | ||
role_id: testUtils.roles.ids.editor | ||
} | ||
] | ||
}, testUtils.context.admin_api_key).then(function (response) { | ||
checkAddResponse(response); | ||
response.invites[0].role_id.should.equal(testUtils.roles.ids.editor); | ||
done(); | ||
}).catch(done); | ||
}); | ||
|
||
it('Can invite an Author', function (done) { | ||
InvitesAPI.add({ | ||
invites: [ | ||
{ | ||
email: '[email protected]', | ||
role_id: testUtils.roles.ids.author | ||
} | ||
] | ||
}, testUtils.context.admin_api_key).then(function (response) { | ||
checkAddResponse(response); | ||
response.invites[0].role_id.should.equal(testUtils.roles.ids.author); | ||
done(); | ||
}).catch(done); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters