import org.sonar.db.property.PropertyQuery;
import org.sonar.server.ce.ws.ActivityAction;
import org.sonar.server.component.ComponentFinder;
+import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.ui.ViewProxy;
import org.sonar.server.ui.Views;
import org.sonar.server.user.UserSession;
try {
ComponentDto component = componentFinder.getByKey(session, componentKey);
- userSession.checkComponentUuidPermission(UserRole.USER, component.projectUuid());
+ if (!(userSession.hasComponentUuidPermission(UserRole.USER, component.projectUuid()) || userSession.hasComponentUuidPermission(UserRole.ADMIN, component.projectUuid()))) {
+ throw new ForbiddenException("Insufficient privileges");
+ }
Optional<SnapshotDto> analysis = dbClient.snapshotDao().selectLastAnalysisByRootComponentUuid(session, component.projectUuid());
wsTester.newGetRequest("api/navigation", "component").setParam("componentKey", "palap:src/main/xoo/Source.xoo").execute().assertJson(getClass(), "breadcrumbs.json");
}
+ @Test
+ public void work_with_only_system_admin() throws Exception {
+ ComponentDto project = ComponentTesting.newProjectDto("abcd")
+ .setKey("polop").setName("Polop").setLanguage("xoo");
+ dbClient.componentDao().insert(dbTester.getSession(), project);
+ dbClient.snapshotDao().insert(dbTester.getSession(), SnapshotTesting.newAnalysis(project));
+ dbTester.getSession().commit();
+
+ userSessionRule.setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
+
+ WsTester wsTester = newdWsTester(createViews());
+ wsTester.newGetRequest("api/navigation", "component").setParam("componentKey", "polop").execute();
+ }
+
private WsTester newdWsTester(View... views) {
return new WsTester(new NavigationWs(new ComponentNavigationAction(dbClient, new Views(userSessionRule, views), i18n, resourceTypes, userSessionRule,
new ComponentFinder(dbClient))));
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import $ from 'jquery';
-import { getJSON, post } from '../helpers/request.js';
+import { getJSON, post } from '../helpers/request';
export function getQueue (data) {
const url = window.baseUrl + '/api/ce/queue';
}
export function getTasksForComponent (componentId) {
- const url = window.baseUrl + '/api/ce/component';
+ const url = '/api/ce/component';
const data = { componentId };
- return new Promise(resolve => $.get(url, data).done(resolve));
+ return getJSON(url, data);
}
export function getTypes () {
def index
@project = Project.by_key(params[:id])
- access_denied unless is_admin?(@project)
+ access_denied unless is_admin? || is_admin?(@project)
end
end