Skip to content

Commit 56f06e6

Browse files
committed
getRole renamed to fetchRole, getProfile renamed to fetchProfile
1 parent 12cc678 commit 56f06e6

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

src/security/kuzzleSecurity.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ function Security(kuzzle) {
4747
* @param {object|responseCallback} [options] - Optional parameters
4848
* @param {responseCallback} [cb] - returns Kuzzle's response
4949
*/
50-
Security.prototype.getRole = function (id, options, cb) {
50+
Security.prototype.fetchRole = function (id, options, cb) {
5151
var
5252
data,
5353
self = this;
5454

5555
if (!id) {
56-
throw new Error('Id parameter is mandatory for getRole function');
56+
throw new Error('Id parameter is mandatory for fetchRole function');
5757
}
5858

5959
if (!cb && typeof options === 'function') {
@@ -63,9 +63,9 @@ Security.prototype.getRole = function (id, options, cb) {
6363

6464
data = {_id: id};
6565

66-
self.kuzzle.callbackRequired('Security.getRole', cb);
66+
self.kuzzle.callbackRequired('Security.fetchRole', cb);
6767

68-
self.kuzzle.query(this.buildQueryArgs('getRole'), data, options, function (err, response) {
68+
self.kuzzle.query(this.buildQueryArgs('fetchRole'), data, options, function (err, response) {
6969
cb(err, err ? undefined : new Role(self, response.result._id, response.result._source));
7070
});
7171
};
@@ -229,7 +229,7 @@ Security.prototype.role = function(id, content) {
229229
* @param {object|responseCallback} [options] - (optional) arguments
230230
* @param {responseCallback} cb - returns Kuzzle's response
231231
*/
232-
Security.prototype.getProfile = function (id, options, cb) {
232+
Security.prototype.fetchProfile = function (id, options, cb) {
233233
var
234234
data,
235235
self = this;
@@ -240,15 +240,15 @@ Security.prototype.getProfile = function (id, options, cb) {
240240
}
241241

242242
if (!id || typeof id !== 'string') {
243-
throw new Error('Id parameter is mandatory for getProfile function');
243+
throw new Error('Id parameter is mandatory for fetchProfile function');
244244
}
245245

246246

247247
data = {_id: id};
248248

249-
self.kuzzle.callbackRequired('Security.getProfile', cb);
249+
self.kuzzle.callbackRequired('Security.fetchProfile', cb);
250250

251-
self.kuzzle.query(this.buildQueryArgs('getProfile'), data, options, function (error, response) {
251+
self.kuzzle.query(this.buildQueryArgs('fetchProfile'), data, options, function (error, response) {
252252
cb(error, error ? undefined : new Profile(self, response.result._id, response.result._source));
253253
});
254254
};

test/security/kuzzleSecurity/constructor.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ describe('kuzzleSecurity constructor', function () {
2424
kuzzle = new Kuzzle('foo');
2525

2626
should.exist(kuzzle.security.createRolePromise);
27-
should.exist(kuzzle.security.getRolePromise);
27+
should.exist(kuzzle.security.fetchRolePromise);
2828
should.exist(kuzzle.security.searchRolesPromise);
2929
should.exist(kuzzle.security.deleteRolePromise);
3030
should.exist(kuzzle.security.createProfilePromise);
31-
should.exist(kuzzle.security.getProfilePromise);
31+
should.exist(kuzzle.security.fetchProfilePromise);
3232
should.exist(kuzzle.security.searchProfilesPromise);
3333
should.exist(kuzzle.security.deleteProfilePromise);
3434
should.exist(kuzzle.security.createUserPromise);

test/security/kuzzleSecurity/profilesMethods.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('Security profiles methods', function () {
4040
}
4141
};
4242

43-
describe('#getProfile', function () {
43+
describe('#fetchProfile', function () {
4444
beforeEach(function () {
4545
kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'});
4646
kuzzle.query = queryStub;
@@ -60,14 +60,14 @@ describe('Security profiles methods', function () {
6060
}
6161
};
6262
expectedQuery = {
63-
action: 'getProfile',
63+
action: 'fetchProfile',
6464
controller: 'security',
6565
_id: 'foobar'
6666
};
6767
});
6868

6969
it('should send the right query to Kuzzle', function (done) {
70-
should(kuzzle.security.getProfile(result.result._id, function (err, res) {
70+
should(kuzzle.security.fetchProfile(result.result._id, function (err, res) {
7171
should(err).be.null();
7272
should(res).be.instanceof(Profile);
7373

@@ -83,7 +83,7 @@ describe('Security profiles methods', function () {
8383
});
8484

8585
it('should send the right query to Kuzzle with id as roles when hydrate is false', function (done) {
86-
should(kuzzle.security.getProfile(result.result._id, function (err, res) {
86+
should(kuzzle.security.fetchProfile(result.result._id, function (err, res) {
8787
should(err).be.null();
8888
should(res).be.instanceof(Profile);
8989

@@ -103,18 +103,18 @@ describe('Security profiles methods', function () {
103103
});
104104

105105
it('should raise an error if no callback is provided', function () {
106-
should(function () { kuzzle.security.getProfile('test'); }).throw(Error);
106+
should(function () { kuzzle.security.fetchProfile('test'); }).throw(Error);
107107
});
108108

109109
it('should throw an error when no id is provided', function () {
110-
should(function () { kuzzle.security.getProfile(null, function () {}); }).throw(Error);
110+
should(function () { kuzzle.security.fetchProfile(null, function () {}); }).throw(Error);
111111
});
112112

113113
it('should call the callback with an error if one occurs', function (done) {
114114
error = 'error';
115115
this.timeout(50);
116116

117-
kuzzle.security.getProfile('foobar', function (err, res) {
117+
kuzzle.security.fetchProfile('foobar', function (err, res) {
118118
should(err).be.exactly('error');
119119
should(res).be.undefined();
120120
done();

test/security/kuzzleSecurity/rolesMethods.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,40 @@ describe('Security roles methods', function () {
4040
}
4141
};
4242

43-
describe('#getRole', function () {
43+
describe('#fetchRole', function () {
4444
beforeEach(function () {
4545
kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'});
4646
kuzzle.query = queryStub;
4747
error = null;
4848
result = { result: {_id: 'foobar', _source: {} }};
4949
expectedQuery = {
50-
action: 'getRole',
50+
action: 'fetchRole',
5151
controller: 'security',
5252
_id: 'foobar'
5353
};
5454
});
5555

5656
it('should send the right query to Kuzzle', function (done) {
57-
should(kuzzle.security.getRole(result.result._id, function (err, res) {
57+
should(kuzzle.security.fetchRole(result.result._id, function (err, res) {
5858
should(err).be.null();
5959
should(res).be.instanceof(Role);
6060
done();
6161
}));
6262
});
6363

6464
it('should raise an error if no callback is provided', function () {
65-
should(function () { kuzzle.security.getRole('test'); }).throw(Error);
65+
should(function () { kuzzle.security.fetchRole('test'); }).throw(Error);
6666
});
6767

6868
it('should throw an error when no id is provided', function () {
69-
should(function () { kuzzle.security.getRole(null, function () {}); }).throw(Error);
69+
should(function () { kuzzle.security.fetchRole(null, function () {}); }).throw(Error);
7070
});
7171

7272
it('should call the callback with an error if one occurs', function (done) {
7373
error = 'error';
7474
this.timeout(50);
7575

76-
kuzzle.security.getRole('foobar', function (err, res) {
76+
kuzzle.security.fetchRole('foobar', function (err, res) {
7777
should(err).be.exactly('error');
7878
should(res).be.undefined();
7979
done();

0 commit comments

Comments
 (0)