Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/org/labkey/snd/security/SNDSecurityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.labkey.api.security.SecurityPolicy;
import org.labkey.api.security.SecurityPolicyManager;
import org.labkey.api.security.User;
import org.labkey.api.security.impersonation.ImpersonationContext;
import org.labkey.api.security.impersonation.RoleImpersonationContextFactory;
import org.labkey.api.security.permissions.Permission;
import org.labkey.api.security.roles.Role;
import org.labkey.api.snd.Category;
Expand Down Expand Up @@ -206,7 +208,24 @@ public Map<String, Role> getAllSecurityRoles()
private boolean hasPermission(User u, Category category, QCStateActionEnum action, QCStateEnum qcState)
{
Permission perm = action.getPermission(qcState);
return perm != null && category.hasPermission(u, perm.getClass());
if (perm == null)
{
return false;
}

Set<Role> roles = Set.of();

// SND has permissions bound to SND categories which can be assigned to packages (domains). Impersonating roles is used
// in automated and manual testing to verify this behavior. The behavior of role impersonation was changed in core
// labkey to only check for roles related to containers. This is a workaround to go back to checking all roles.
ImpersonationContext impersonationContext = u.getImpersonationContext();
if (impersonationContext instanceof RoleImpersonationContextFactory.RoleImpersonationContext context)
{
roles = context.getRoles().getRoles();
}

return SecurityManager.hasAllPermissions(this.getClass().getName() + ":" + category.getResourceName(),
category, u, Set.of(perm.getClass()), roles);

}

Expand Down
3 changes: 3 additions & 0 deletions webapp/snd/test/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@
else if (LABKEY.Utils.isObject(result)) {
finish(undefined, result);
}
else if (json?.event?.exception?.message) {
finish('Test "' + test.name + '" failed. ' + json.event.exception.message);
}
else {
finish('Test "' + test.name + '" failed. Test should specify a reason for failure or return true.');
}
Expand Down
14 changes: 7 additions & 7 deletions webapp/snd/test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
return true;
}

LABKEY.handleFailure(response, name + " - Stack Trace");
LABKEY.handleSndFailure(response, name + " - Stack Trace");
return false;
}
}
Expand Down Expand Up @@ -563,7 +563,7 @@
return true;
}

LABKEY.handleFailure(response, name + " - Stack Trace");
LABKEY.handleSndFailure(response, name + " - Stack Trace");
return false;
}
}
Expand All @@ -586,7 +586,7 @@
return true;
}

LABKEY.handleFailure(response, name + " - Stack Trace");
LABKEY.handleSndFailure(response, name + " - Stack Trace");
return false;
}
}
Expand Down Expand Up @@ -630,7 +630,7 @@
return true;
}

LABKEY.handleFailure(response, name + " - Stack Trace");
LABKEY.handleSndFailure(response, name + " - Stack Trace");
return false;
}
}
Expand All @@ -655,7 +655,7 @@
return true;
}

LABKEY.handleFailure(response, name + " - Stack Trace");
LABKEY.handleSndFailure(response, name + " - Stack Trace");
return false;
}
}
Expand Down Expand Up @@ -713,7 +713,7 @@
return true;
}

LABKEY.handleFailure(response, name + " - Stack Trace");
LABKEY.handleSndFailure(response, name + " - Stack Trace");
return false;
}
}
Expand Down Expand Up @@ -782,7 +782,7 @@
return true;
}

LABKEY.handleFailure(response, test + " - Stack Trace");
LABKEY.handleSndFailure(response, test + " - Stack Trace");
return false;
}
};
Expand Down