Search in sources :

Example 61 with MethodNotAllowedException

use of com.google.gerrit.extensions.restapi.MethodNotAllowedException in project gerrit by GerritCodeReview.

the class DeleteBranchIT method cannotDeleteRefsMetaConfig.

@Test
public void cannotDeleteRefsMetaConfig() throws Exception {
    MethodNotAllowedException thrown = assertThrows(MethodNotAllowedException.class, () -> branch(BranchNameKey.create(allUsers, RefNames.REFS_CONFIG)).delete());
    assertThat(thrown).hasMessageThat().contains("not allowed to delete branch refs/meta/config");
}
Also used : MethodNotAllowedException(com.google.gerrit.extensions.restapi.MethodNotAllowedException) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 62 with MethodNotAllowedException

use of com.google.gerrit.extensions.restapi.MethodNotAllowedException in project gerrit by GerritCodeReview.

the class DeleteBranchIT method cannotDeleteHead.

@Test
public void cannotDeleteHead() throws Exception {
    MethodNotAllowedException thrown = assertThrows(MethodNotAllowedException.class, () -> branch(BranchNameKey.create(allUsers, RefNames.HEAD)).delete());
    assertThat(thrown).hasMessageThat().contains("not allowed to delete HEAD");
}
Also used : MethodNotAllowedException(com.google.gerrit.extensions.restapi.MethodNotAllowedException) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 63 with MethodNotAllowedException

use of com.google.gerrit.extensions.restapi.MethodNotAllowedException in project gerrit by GerritCodeReview.

the class DeleteBranchesIT method cannotDeleteRefsMetaConfig.

@Test
public void cannotDeleteRefsMetaConfig() throws Exception {
    DeleteBranchesInput input = new DeleteBranchesInput();
    input.branches = Lists.newArrayList();
    input.branches.add(RefNames.REFS_CONFIG);
    MethodNotAllowedException thrown = assertThrows(MethodNotAllowedException.class, () -> project().deleteBranches(input));
    assertThat(thrown).hasMessageThat().contains("not allowed to delete branch refs/meta/config");
}
Also used : MethodNotAllowedException(com.google.gerrit.extensions.restapi.MethodNotAllowedException) DeleteBranchesInput(com.google.gerrit.extensions.api.projects.DeleteBranchesInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 64 with MethodNotAllowedException

use of com.google.gerrit.extensions.restapi.MethodNotAllowedException in project gerrit by GerritCodeReview.

the class DeleteBranchesIT method cannotDeleteHead.

@Test
public void cannotDeleteHead() throws Exception {
    DeleteBranchesInput input = new DeleteBranchesInput();
    input.branches = Lists.newArrayList();
    input.branches.add(RefNames.HEAD);
    MethodNotAllowedException thrown = assertThrows(MethodNotAllowedException.class, () -> project().deleteBranches(input));
    assertThat(thrown).hasMessageThat().contains("not allowed to delete HEAD");
}
Also used : MethodNotAllowedException(com.google.gerrit.extensions.restapi.MethodNotAllowedException) DeleteBranchesInput(com.google.gerrit.extensions.api.projects.DeleteBranchesInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 65 with MethodNotAllowedException

use of com.google.gerrit.extensions.restapi.MethodNotAllowedException in project gerrit by GerritCodeReview.

the class PrivateByDefaultIT method createChangeWithPrivateByDefaultAndDisablePrivateChangesTrue.

@Test
@GerritConfig(name = "change.disablePrivateChanges", value = "true")
public void createChangeWithPrivateByDefaultAndDisablePrivateChangesTrue() throws Exception {
    setPrivateByDefault(project2, InheritableBoolean.TRUE);
    ChangeInput input = new ChangeInput(project2.get(), "master", "empty change");
    MethodNotAllowedException thrown = assertThrows(MethodNotAllowedException.class, () -> gApi.changes().create(input));
    assertThat(thrown).hasMessageThat().contains("private changes are disabled");
}
Also used : MethodNotAllowedException(com.google.gerrit.extensions.restapi.MethodNotAllowedException) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)66 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)27 AuthException (com.google.gerrit.extensions.restapi.AuthException)23 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)16 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)16 Test (org.junit.Test)16 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)15 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)11 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)10 Account (com.google.gerrit.reviewdb.client.Account)9 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)8 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)7 BatchUpdate (com.google.gerrit.server.update.BatchUpdate)7 Account (com.google.gerrit.entities.Account)6 GroupInfo (com.google.gerrit.extensions.common.GroupInfo)5 Response (com.google.gerrit.extensions.restapi.Response)5 Change (com.google.gerrit.reviewdb.client.Change)5 CurrentUser (com.google.gerrit.server.CurrentUser)5