Test that the RenameEmail REST endpoint requires authentication
This slightly increases the test coverage from 98.4% to 100%.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Id501305a04c6003506f714412f4188bd369c588a
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/RenameEmailIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/RenameEmailIT.java
index 74e0d52..40d87a6 100644
--- a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/RenameEmailIT.java
+++ b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/RenameEmailIT.java
@@ -143,6 +143,15 @@
}
@Test
+ public void requiresAuthenticatedUser() throws Exception {
+ requestScopeOperations.setApiUserAnonymous();
+ AuthException authException =
+ assertThrows(
+ AuthException.class, () -> renameEmail(project, "master", new RenameEmailInput()));
+ assertThat(authException).hasMessageThat().contains("Authentication required");
+ }
+
+ @Test
public void renameEmailRequiresDirectPushPermissionsForNonProjectOwner() throws Exception {
String secondaryEmail = "user-foo@example.com";
accountOperations.account(user.id()).forUpdate().addSecondaryEmail(secondaryEmail).update();