import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.groups.Tuple.tuple;
-import static org.sonar.api.web.UserRole.ADMIN;
import static org.sonar.api.web.UserRole.USER;
import static org.sonar.test.JsonAssert.assertJson;
@Test
public void get_github_project_binding() {
- userSession.logIn(user).addProjectPermission(ADMIN, project);
+ userSession.logIn(user).addProjectPermission(USER, project);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
ProjectAlmSettingDto githubProjectAlmSetting = db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project);
@Test
public void get_azure_project_binding() {
- userSession.logIn(user).addProjectPermission(ADMIN, project);
+ userSession.logIn(user).addProjectPermission(USER, project);
AlmSettingDto almSetting = db.almSettings().insertAzureAlmSetting();
ProjectAlmSettingDto projectAlmSettingDto = db.almSettings().insertAzureMonoRepoProjectAlmSetting(almSetting, project);
public void get_gitlab_project_binding() {
UserDto user = db.users().insertUser();
ProjectDto project = db.components().insertPrivateProjectDto();
- userSession.logIn(user).addProjectPermission(ADMIN, project);
+ userSession.logIn(user).addProjectPermission(USER, project);
AlmSettingDto almSetting = db.almSettings().insertGitlabAlmSetting();
db.almSettings().insertGitlabProjectAlmSetting(almSetting, project);
@Test
public void get_bitbucket_project_binding() {
- userSession.logIn(user).addProjectPermission(ADMIN, project);
+ userSession.logIn(user).addProjectPermission(USER, project);
AlmSettingDto almSetting = db.almSettings().insertBitbucketAlmSetting();
ProjectAlmSettingDto projectAlmSettingDto = db.almSettings().insertBitbucketProjectAlmSetting(almSetting, project);
@Test
public void fail_when_project_does_not_exist() {
- userSession.logIn(user).addProjectPermission(ADMIN, project);
+ userSession.logIn(user).addProjectPermission(USER, project);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project);
}
@Test
- public void fail_when_missing_administer_permission_on_project() {
- userSession.logIn(user).addProjectPermission(USER, project);
+ public void fail_when_missing_browse_permission_on_project() {
+ userSession.logIn(user);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting();
db.almSettings().insertGitHubProjectAlmSetting(githubAlmSetting, project);
@Test
public void json_example() {
- userSession.logIn(user).addProjectPermission(ADMIN, project);
+ userSession.logIn(user).addProjectPermission(USER, project);
AlmSettingDto githubAlmSetting = db.almSettings().insertGitHubAlmSetting(
almSettingDto -> almSettingDto
.setKey("GitHub Server - Dev Team")
import static java.lang.String.format;
import static java.util.Optional.ofNullable;
-import static org.sonar.api.web.UserRole.ADMIN;
+import static org.sonar.api.web.UserRole.USER;
import static org.sonar.server.almsettings.ws.AlmSettingsSupport.toAlmWs;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
public void define(WebService.NewController context) {
WebService.NewAction action = context.createAction("get_binding")
.setDescription("Get DevOps Platform binding of a given project.<br/>" +
- "Requires the 'Administer' permission on the project")
+ "Requires the 'Browse' permission on the project")
.setSince("8.1")
.setResponseExample(getClass().getResource("example-get_binding.json"))
.setChangelog(
new Change("8.6", "Azure binding now contains the project and repository names"),
- new Change("8.7", "Azure binding now contains a monorepo flag for monorepo feature in Enterprise Edition and above"))
+ new Change("8.7", "Azure binding now contains a monorepo flag for monorepo feature in Enterprise Edition and above"),
+ new Change("10.1", "Permission needed changed from 'Administer' to 'Browse'"))
.setHandler(this);
action
String projectKey = request.mandatoryParam(PARAM_PROJECT);
try (DbSession dbSession = dbClient.openSession(false)) {
ProjectDto project = componentFinder.getProjectByKey(dbSession, projectKey);
- userSession.checkProjectPermission(ADMIN, project);
+ userSession.checkProjectPermission(USER, project);
ProjectAlmSettingDto projectAlmSetting = dbClient.projectAlmSettingDao().selectByProject(dbSession, project)
.orElseThrow(() -> new NotFoundException(format("Project '%s' is not bound to any DevOps Platform", project.getKey())));
AlmSettingDto almSetting = dbClient.almSettingDao().selectByUuid(dbSession, projectAlmSetting.getAlmSettingUuid())