Merge branch 'stable-3.2' into stable-3.3
* stable-3.2: Update git submodules Honor toogleWipState permission for %ready %wip push options Change-Id: I6c22b3e33b9249b816ad805c76890df8ba2430f2
This commit is contained in:
@@ -25,7 +25,7 @@ import static com.google.gerrit.git.ObjectIds.abbreviateName;
|
|||||||
import static com.google.gerrit.server.change.HashtagsUtil.cleanupHashtag;
|
import static com.google.gerrit.server.change.HashtagsUtil.cleanupHashtag;
|
||||||
import static com.google.gerrit.server.git.MultiProgressMonitor.UNKNOWN;
|
import static com.google.gerrit.server.git.MultiProgressMonitor.UNKNOWN;
|
||||||
import static com.google.gerrit.server.git.receive.ReceiveConstants.COMMAND_REJECTION_MESSAGE_FOOTER;
|
import static com.google.gerrit.server.git.receive.ReceiveConstants.COMMAND_REJECTION_MESSAGE_FOOTER;
|
||||||
import static com.google.gerrit.server.git.receive.ReceiveConstants.ONLY_CHANGE_OWNER_OR_PROJECT_OWNER_CAN_MODIFY_WIP;
|
import static com.google.gerrit.server.git.receive.ReceiveConstants.ONLY_USERS_WITH_TOGGLE_WIP_STATE_PERM_CAN_MODIFY_WIP;
|
||||||
import static com.google.gerrit.server.git.receive.ReceiveConstants.PUSH_OPTION_SKIP_VALIDATION;
|
import static com.google.gerrit.server.git.receive.ReceiveConstants.PUSH_OPTION_SKIP_VALIDATION;
|
||||||
import static com.google.gerrit.server.git.receive.ReceiveConstants.SAME_CHANGE_ID_IN_MULTIPLE_CHANGES;
|
import static com.google.gerrit.server.git.receive.ReceiveConstants.SAME_CHANGE_ID_IN_MULTIPLE_CHANGES;
|
||||||
import static com.google.gerrit.server.git.validators.CommitValidators.NEW_PATCHSET_PATTERN;
|
import static com.google.gerrit.server.git.validators.CommitValidators.NEW_PATCHSET_PATTERN;
|
||||||
@@ -2883,9 +2883,9 @@ class ReceiveCommits {
|
|||||||
|
|
||||||
if (!hasWriteConfigPermission) {
|
if (!hasWriteConfigPermission) {
|
||||||
try {
|
try {
|
||||||
permissionBackend.user(user).check(GlobalPermission.ADMINISTRATE_SERVER);
|
permissions.change(notes).check(ChangePermission.TOGGLE_WORK_IN_PROGRESS_STATE);
|
||||||
} catch (AuthException e1) {
|
} catch (AuthException e1) {
|
||||||
reject(inputCommand, ONLY_CHANGE_OWNER_OR_PROJECT_OWNER_CAN_MODIFY_WIP);
|
reject(inputCommand, ONLY_USERS_WITH_TOGGLE_WIP_STATE_PERM_CAN_MODIFY_WIP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ public final class ReceiveConstants {
|
|||||||
public static final String PUSH_OPTION_SKIP_VALIDATION = "skip-validation";
|
public static final String PUSH_OPTION_SKIP_VALIDATION = "skip-validation";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final String ONLY_CHANGE_OWNER_OR_PROJECT_OWNER_CAN_MODIFY_WIP =
|
public static final String ONLY_USERS_WITH_TOGGLE_WIP_STATE_PERM_CAN_MODIFY_WIP =
|
||||||
"only change owner or project owner can modify Work-in-Progress";
|
"only users with Toogle-Wip-State permission can modify Work-in-Progress";
|
||||||
|
|
||||||
static final String COMMAND_REJECTION_MESSAGE_FOOTER =
|
static final String COMMAND_REJECTION_MESSAGE_FOOTER =
|
||||||
"Contact an administrator to fix the permissions";
|
"Contact an administrator to fix the permissions";
|
||||||
|
|||||||
@@ -889,7 +889,19 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
|||||||
GitUtil.fetch(user2Repo, r.getPatchSet().refName() + ":ps");
|
GitUtil.fetch(user2Repo, r.getPatchSet().refName() + ":ps");
|
||||||
user2Repo.reset("ps");
|
user2Repo.reset("ps");
|
||||||
r = amendChange(r.getChangeId(), "refs/for/master%ready", user2, user2Repo);
|
r = amendChange(r.getChangeId(), "refs/for/master%ready", user2, user2Repo);
|
||||||
r.assertErrorStatus(ReceiveConstants.ONLY_CHANGE_OWNER_OR_PROJECT_OWNER_CAN_MODIFY_WIP);
|
r.assertErrorStatus(ReceiveConstants.ONLY_USERS_WITH_TOGGLE_WIP_STATE_PERM_CAN_MODIFY_WIP);
|
||||||
|
|
||||||
|
// Non owner, non admin and non project owner with toggleWipState should succeed.
|
||||||
|
projectOperations
|
||||||
|
.project(project)
|
||||||
|
.forUpdate()
|
||||||
|
.add(
|
||||||
|
allow(Permission.TOGGLE_WORK_IN_PROGRESS_STATE)
|
||||||
|
.ref(RefNames.REFS_HEADS + "*")
|
||||||
|
.group(REGISTERED_USERS))
|
||||||
|
.update();
|
||||||
|
r = amendChange(r.getChangeId(), "refs/for/master%ready", user2, user2Repo);
|
||||||
|
r.assertOkStatus();
|
||||||
|
|
||||||
// Project owner trying to move from WIP to ready should succeed.
|
// Project owner trying to move from WIP to ready should succeed.
|
||||||
projectOperations
|
projectOperations
|
||||||
|
|||||||
Submodule plugins/gitiles updated: 641476e153...b8ea789876
Reference in New Issue
Block a user