Reputation: 413
Are Rally permissions consistent or eventually consistent? because many workspace and project permission tests I wrote are failing. They were passing 2 months ago.
What i do is I create a workspace permission and then immediately after the response from the rally server I set a GET for that permission, but I get the old, stale data.
I note again: all my WSAPI permission tests were passing 2 months ago, and I did not change anything in my code, so I'm assuming something changed on the WSAPI end.
--
some extra info: i am using node-rally library and i wrote a thin wrapper library on top of that to edit permissions.
Also, this might be irrelevant, but I get these warnings when creating workspace permissions, which i dont understand why. I need to specify all 3 of these to create the workspace permission!
Warnings:
[ 'Ignored JSON element workspacepermission.Workspace during processing of this req... (length: 85)',
'Ignored JSON element workspacepermission.User during processing of this request.',
'Ignored JSON element workspacepermission.Role during processing of this request.'
],
EDIT: code I'm using
rallyUtil.getWorkspacePermission = function(personRef){
var deferred = Q.defer();
restApi.query({
type: 'workspacepermission',
limit: Infinity,
fetch: ['Workspace', 'User', 'Role', 'ObjectID', 'UserName', 'Name'],
query: queryUtils.where('User', '=', personRef),
scope: { workspace: workspaceRef }
}, function(error, result) {
if(error) deferred.reject(error);
else deferred.resolve(_.find(result.Results, function(wPermission){ return areSameRefs(wPermission.Workspace._ref, workspaceRef); }));
});
return deferred.promise;
};
rallyUtil.setWorkspacePermission = function(personRef, permission){
var deferred = Q.defer();
restApi.create({
type: 'workspacepermission',
limit: Infinity,
data: { Workspace: workspaceRef, User:personRef, Role:permission },
scope: { workspace: workspaceRef },
}, function(error, result) {
if(error) deferred.reject(error);
else deferred.resolve();
});
return deferred.promise;
};
rallyUtil.setWorkspaceAdmin = function(personRef){
return rallyUtil.setWorkspacePermission(personRef, 'Admin');
};
Upvotes: 0
Views: 118
Reputation: 8410
You can simplify your code a little bit by eliminating the duplicate promises. All of the restApi methods already return promises (implemented using Q) so your setWorkspacePermission can become this:
rallyUtil.setWorkspacePermission = function(personRef, permission){
return restApi.create({
type: 'workspacepermission',
data: { Workspace: workspaceRef, User:personRef, Role:permission },
scope: { workspace: workspaceRef }
});
};
That being said, I'm not sure what else might be going on. Does the create return successfully with a created record? Is it possible that the permission already exists and that's why it's ignoring the new one?
Upvotes: 1