usergrid
Advanced tools
Comparing version 0.10.6 to 0.10.7
##Change log | ||
###0.10.7 | ||
- Fixed issue where token was appeneded even when no token was present | ||
- Updated tests | ||
###0.10.5 | ||
@@ -4,0 +10,0 @@ |
@@ -99,3 +99,3 @@ /* | ||
qs['client_secret'] = this.clientSecret; | ||
} else if (this.authType === AUTH_APP_USER) { | ||
} else if (this.authType === AUTH_APP_USER && self.getToken()) { | ||
qs['access_token'] = self.getToken(); | ||
@@ -926,6 +926,12 @@ } | ||
var entityData = this.get(); | ||
var password = this.get('password'); | ||
var oldpassword = this.get('oldpassword'); | ||
var newpassword = this.get('newpassword'); | ||
//remove system specific properties | ||
for (var item in entityData) { | ||
if (item === 'metadata' || item === 'created' || item === 'modified' || | ||
item === 'type' || item === 'activated' || item ==='uuid') { continue; } | ||
item === 'oldpassword' || item === 'newpassword' || //old and new pw not added to data | ||
item === 'type' || item === 'activated' || item === 'uuid') { | ||
continue; | ||
} | ||
data[item] = entityData[item]; | ||
@@ -940,2 +946,6 @@ } | ||
this._client.request(options, function (err, retdata) { | ||
//clear out pw info if present | ||
self.set('password', null); | ||
self.set('oldpassword', null); | ||
self.set('newpassword', null); | ||
if (err && self._client.logging) { | ||
@@ -960,3 +970,3 @@ console.log('could not save entity'); | ||
//if this is a user, update the password if it has been specified; | ||
var needPasswordChange = ((self.get('type') === 'user' || self.get('type') === 'users') && entityData.oldpassword && entityData.newpassword); | ||
var needPasswordChange = ((self.get('type') === 'user' || self.get('type') === 'users') && oldpassword && newpassword); | ||
if (needPasswordChange) { | ||
@@ -966,4 +976,4 @@ //Note: we have a ticket in to change PUT calls to /users to accept the password change | ||
var pwdata = {}; | ||
pwdata.oldpassword = entityData.oldpassword; | ||
pwdata.newpassword = entityData.newpassword; | ||
pwdata.oldpassword = oldpassword; | ||
pwdata.newpassword = newpassword; | ||
var options = { | ||
@@ -1004,39 +1014,23 @@ method:'PUT', | ||
//Check for an entity type, then if a uuid is available, use that, otherwise, use the name | ||
//Check for an entity type, then if a uuid is available, use that, otherwise, use the name | ||
try { | ||
if (type === undefined) { | ||
var error = 'cannot fetch entity, no entity type specified'; | ||
if (self._client.logging) { | ||
console.log(error); | ||
} | ||
return callback(true, error, self) | ||
}else if (this.get('uuid')) { | ||
throw 'cannot fetch entity, no entity type specified' | ||
} else if (this.get('uuid')) { | ||
type += '/' + this.get('uuid'); | ||
} else { | ||
if (type === 'users') { | ||
if (this.get('username')) { | ||
type += '/' + this.get('username'); | ||
} else { | ||
if (typeof(callback) === 'function') { | ||
var error = 'no_name_specified'; | ||
if (self._client.logging) { | ||
console.log(error); | ||
} | ||
return callback(true, {error:error}, self) | ||
} | ||
} | ||
} else { | ||
if (this.get('name')) { | ||
type += '/' + encodeURIComponent(this.get('name')); | ||
} else { | ||
if (typeof(callback) === 'function') { | ||
var error = 'no_name_specified'; | ||
if (self._client.logging) { | ||
console.log(error); | ||
} | ||
return callback(true, {error:error}, self) | ||
} | ||
} | ||
} | ||
} else if (type === 'users' && this.get('username')) { | ||
type += '/' + this.get('username'); | ||
} else if (this.get('name')) { | ||
type += '/' + encodeURIComponent(this.get('name')); | ||
} else if (typeof(callback) === 'function') { | ||
throw 'no_name_specified'; | ||
} | ||
} catch (e) { | ||
if (self._client.logging) { | ||
console.log(e); | ||
} | ||
return callback(true, { | ||
error: e | ||
}, self); | ||
} | ||
var options = { | ||
@@ -1043,0 +1037,0 @@ method:'GET', |
{ | ||
"name": "usergrid", | ||
"version": "0.10.6", | ||
"version": "0.10.7", | ||
"description": "A Node.js module for making API calls to App Services (Usergrid) from within Node.js", | ||
@@ -5,0 +5,0 @@ "main": "./lib/usergrid.js", |
##Version | ||
Current Version: **0.10.5** | ||
Current Version: **0.10.7** | ||
@@ -5,0 +5,0 @@ See change log: |
175
test.js
@@ -20,2 +20,7 @@ /** | ||
var logNotice = true; | ||
var _unique = new Date().getTime(); | ||
var _username = 'marty'+_unique; | ||
var _email = 'marty'+_unique+'@timetravel.com'; | ||
var _password = 'password2'; | ||
var _newpassword = 'password3'; | ||
@@ -36,3 +41,3 @@ var client = new usergrid.client({ | ||
appName:'sandbox', | ||
//logging: true, //optional - turn on logging, off by default | ||
logging: true, //optional - turn on logging, off by default | ||
buildCurl: true //optional - turn on curl commands, off by default | ||
@@ -43,2 +48,3 @@ }); | ||
//call the runner function to start the process | ||
client.logout(); | ||
runner(0); | ||
@@ -131,15 +137,15 @@ | ||
case 21: | ||
notice('-----running step '+step+': refresh the user from the database'); | ||
notice('-----running step '+step+': log user in'); | ||
loginUser(step, arg); | ||
break; | ||
case 22: | ||
notice('-----running step '+step+': refresh the user from the database'); | ||
notice('-----running step '+step+': change users password'); | ||
changeUsersPassword(step, arg); | ||
break; | ||
case 23: | ||
notice('-----running step '+step+': refresh the user from the database'); | ||
notice('-----running step '+step+': log user out'); | ||
logoutUser(step, arg); | ||
break; | ||
case 24: | ||
notice('-----running step '+step+': refresh the user from the database'); | ||
notice('-----running step '+step+': relogin user'); | ||
reloginUser(step, arg); | ||
@@ -175,2 +181,14 @@ break; | ||
break; | ||
case 32: | ||
notice('-----running step '+step+': try to create new entity with no name'); | ||
createNewEntityNoName(step, arg); | ||
break; | ||
case 33: | ||
notice('-----running step '+step+': clean up users'); | ||
cleanUpUsers(step, arg); | ||
break; | ||
case 34: | ||
notice('-----running step '+step+': clean up dogs'); | ||
cleanUpDogs(step, arg); | ||
break; | ||
default: | ||
@@ -288,3 +306,3 @@ notice('-----test complete!-----'); | ||
type:'dogs', | ||
name:'Dino' | ||
name:'Ralph'+_unique | ||
} | ||
@@ -375,3 +393,3 @@ | ||
type:'dogs', | ||
name:'dog'+i, | ||
name:'dog'+_unique+i, | ||
index:i | ||
@@ -543,6 +561,8 @@ } | ||
function prepareDatabaseForNewUser(step) { | ||
var options = { | ||
method:'DELETE', | ||
endpoint:'users/marty' | ||
endpoint:'users/', | ||
qs:{ql:"select * where username ='marty*'"} | ||
}; | ||
@@ -562,22 +582,13 @@ client.request(options, function (err, data) { | ||
function createUser(step) { | ||
//type is 'users', set additional paramaters as needed | ||
var options = { | ||
type:'users', | ||
username:'marty', | ||
password:'mysecurepassword', | ||
name:'Marty McFly', | ||
city:'Hill Valley' | ||
} | ||
client.createEntity(options, function (err, marty) { | ||
if (err){ | ||
error('user not created'); | ||
runner(step, marty); | ||
} else { | ||
success('user created'); | ||
runner(step, marty); | ||
client.signup(_username, _password, _email, 'Marty McFly', | ||
function (err, marty) { | ||
if (err){ | ||
error('user not created'); | ||
runner(step, marty); | ||
} else { | ||
success('user created'); | ||
runner(step, marty); | ||
} | ||
} | ||
}); | ||
); | ||
} | ||
@@ -605,3 +616,3 @@ | ||
type:'users', | ||
username:'marty' | ||
username:_username | ||
} | ||
@@ -615,3 +626,3 @@ client.getEntity(options, function(err, existingUser){ | ||
var username = existingUser.get('username'); | ||
if (username === 'marty'){ | ||
if (username === _username){ | ||
success('got existing user username'); | ||
@@ -642,4 +653,4 @@ } else { | ||
function loginUser(step, marty) { | ||
username = 'marty'; | ||
password = 'mysecurepassword'; | ||
username = _username; | ||
password = _password; | ||
client.login(username, password, | ||
@@ -691,4 +702,4 @@ function (err) { | ||
marty.set('oldpassword', 'mysecurepassword'); | ||
marty.set('newpassword', 'mynewsecurepassword'); | ||
marty.set('oldpassword', _password); | ||
marty.set('newpassword', _newpassword); | ||
marty.save(function(err){ | ||
@@ -722,4 +733,4 @@ if (err){ | ||
username = 'marty'; | ||
password = 'mynewsecurepassword'; | ||
username = _username | ||
password = _newpassword; | ||
client.login(username, password, | ||
@@ -910,1 +921,95 @@ function (err) { | ||
} | ||
function createNewEntityNoName(step, marty) { | ||
var options = { | ||
type:"something", | ||
othervalue:"something else" | ||
} | ||
client.createEntity(options, function (err, entity) { | ||
if (err) { | ||
error('Create new entity with no name failed'); | ||
} else { | ||
success('Create new entity with no name succeeded'); | ||
entity.destroy(); | ||
runner(step); | ||
} | ||
}); | ||
} | ||
function cleanUpUsers(step){ | ||
var options = { | ||
type:'users', | ||
qs:{limit:50} //limit statement set to 50 | ||
} | ||
client.createCollection(options, function (err, users) { | ||
if (err) { | ||
error('could not get all users'); | ||
} else { | ||
success('got users'); | ||
//do doggy cleanup | ||
while(users.hasNextEntity()) { | ||
//get a reference to the dog | ||
var user = users.getNextEntity(); | ||
var username = user.get('name'); | ||
notice('removing dog ' + username + ' from database'); | ||
user.destroy(function(err, data) { | ||
if (err) { | ||
error('user not removed'); | ||
} else { | ||
success('user removed'); | ||
} | ||
}); | ||
} | ||
runner(step); | ||
} | ||
}); | ||
} | ||
function cleanUpDogs(step){ | ||
var options = { | ||
type:'dogs', | ||
qs:{limit:50} //limit statement set to 50 | ||
} | ||
client.createCollection(options, function (err, dogs) { | ||
if (err) { | ||
error('could not get all dogs'); | ||
} else { | ||
success('got at most 50 dogs'); | ||
//we got 50 dogs, now display the Entities: | ||
while(dogs.hasNextEntity()) { | ||
//get a reference to the dog | ||
var dog = dogs.getNextEntity(); | ||
var name = dog.get('name'); | ||
notice('dog is called ' + name); | ||
} | ||
dogs.resetEntityPointer(); | ||
//do doggy cleanup | ||
while(dogs.hasNextEntity()) { | ||
//get a reference to the dog | ||
var dog = dogs.getNextEntity(); | ||
var dogname = dog.get('name'); | ||
notice('removing dog ' + dogname + ' from database'); | ||
dog.destroy(function(err, data) { | ||
if (err) { | ||
error('dog not removed'); | ||
} else { | ||
success('dog removed'); | ||
} | ||
}); | ||
} | ||
//no need to wait around for dogs to be removed, so go on to next test | ||
runner(step); | ||
} | ||
}); | ||
} |
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
149430
21
3282
0
2