From 8181f855766819447f410df8aa23ce98080be235 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 11 May 2018 11:47:28 +0900 Subject: [PATCH 1/2] AgreementsIT: Test that signing agreement as other user fails Change-Id: Ib5629a0a901dea78f1299a5664e2e7285acaf7a9 --- .../gerrit/acceptance/api/accounts/AgreementsIT.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java index 0e9d2ab6bf..60696b0ed3 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java @@ -128,6 +128,15 @@ public class AgreementsIT extends AbstractDaemonTest { assertThat(result).hasSize(1); } + @Test + public void signAgreementAsOtherUser() throws Exception { + assume().that(isContributorAgreementsEnabled()).isTrue(); + assertThat(gApi.accounts().self().get().name).isNotEqualTo("admin"); + exception.expect(AuthException.class); + exception.expectMessage("not allowed to enter contributor agreement"); + gApi.accounts().id("admin").signAgreement(caAutoVerify.getName()); + } + @Test public void agreementsDisabledSign() throws Exception { assume().that(isContributorAgreementsEnabled()).isFalse(); From edb94ecab54f49a8d8a314cccb78ded605cbc824 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 11 May 2018 12:57:06 +0900 Subject: [PATCH 2/2] AgreementsIT: Test that anonymous user cannot sign agreement Change-Id: I1ab0c91183a934b139c96011ffdfa02bebdafb25 --- .../gerrit/acceptance/api/accounts/AgreementsIT.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java index 60696b0ed3..10acae442b 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AgreementsIT.java @@ -137,6 +137,14 @@ public class AgreementsIT extends AbstractDaemonTest { gApi.accounts().id("admin").signAgreement(caAutoVerify.getName()); } + @Test + public void signAgreementAnonymous() throws Exception { + setApiUserAnonymous(); + exception.expect(AuthException.class); + exception.expectMessage("Authentication required"); + gApi.accounts().self().signAgreement(caAutoVerify.getName()); + } + @Test public void agreementsDisabledSign() throws Exception { assume().that(isContributorAgreementsEnabled()).isFalse();