Remove unnecessary "throws" declarations

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201058582
This commit is contained in:
mcilwain 2018-06-18 14:25:42 -07:00 committed by Ben McIlwain
parent a7256f5edd
commit 5d80f124ca
377 changed files with 2297 additions and 2373 deletions

View file

@ -56,7 +56,7 @@ public class ConsoleUiActionTest {
private final User user = new User("marla.singer@example.com", "gmail.com", "12345");
@Before
public void setUp() throws Exception {
public void setUp() {
action.enabled = true;
action.logoFilename = "logo.png";
action.productName = "Nomulus";
@ -77,39 +77,39 @@ public class ConsoleUiActionTest {
}
@Test
public void testWebPage_disallowsIframe() throws Exception {
public void testWebPage_disallowsIframe() {
action.run();
assertThat(response.getHeaders()).containsEntry("X-Frame-Options", "SAMEORIGIN");
}
@Test
public void testWebPage_setsHtmlUtf8ContentType() throws Exception {
public void testWebPage_setsHtmlUtf8ContentType() {
action.run();
assertThat(response.getContentType()).isEqualTo(MediaType.HTML_UTF_8);
}
@Test
public void testWebPage_containsUserNickname() throws Exception {
public void testWebPage_containsUserNickname() {
action.run();
assertThat(response.getPayload()).contains("marla.singer");
}
@Test
public void testUserHasAccessAsTheRegistrar_showsRegistrarConsole() throws Exception {
public void testUserHasAccessAsTheRegistrar_showsRegistrarConsole() {
action.run();
assertThat(response.getPayload()).contains("Registrar Console");
assertThat(response.getPayload()).contains("reg-content-and-footer");
}
@Test
public void testConsoleDisabled_showsDisabledPage() throws Exception {
public void testConsoleDisabled_showsDisabledPage() {
action.enabled = false;
action.run();
assertThat(response.getPayload()).contains("<h1>Console is disabled</h1>");
}
@Test
public void testUserDoesntHaveAccessToAnyRegistrar_showsWhoAreYouPage() throws Exception {
public void testUserDoesntHaveAccessToAnyRegistrar_showsWhoAreYouPage() {
when(sessionUtils.checkRegistrarConsoleLogin(
any(HttpServletRequest.class), any(UserAuthInfo.class)))
.thenReturn(false);
@ -118,7 +118,7 @@ public class ConsoleUiActionTest {
}
@Test
public void testNoUser_redirect() throws Exception {
public void testNoUser_redirect() {
when(request.getRequestURI()).thenReturn("/test");
action.authResult = AuthResult.NOT_AUTHENTICATED;
action.run();
@ -127,7 +127,7 @@ public class ConsoleUiActionTest {
}
@Test
public void testNoUserInformationAtAll_redirectToRoot() throws Exception {
public void testNoUserInformationAtAll_redirectToRoot() {
when(request.getRequestURI()).thenThrow(new IllegalArgumentException());
action.authResult = AuthResult.NOT_AUTHENTICATED;
action.run();

View file

@ -42,7 +42,7 @@ import org.junit.runners.JUnit4;
public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
@Test
public void testPost_readContacts_success() throws Exception {
public void testPost_readContacts_success() {
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of(
"op", "read",
"args", ImmutableMap.of()));
@ -53,7 +53,7 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_loadSaveRegistrar_success() throws Exception {
public void testPost_loadSaveRegistrar_success() {
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of(
"op", "update",
"args", loadRegistrar(CLIENT_ID).toJsonMap()));
@ -61,7 +61,7 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_updateContacts_success() throws Exception {
public void testPost_updateContacts_success() {
// Remove all the contacts but the first by updating with list of
// just it.
Map<String, /* @Nullable */ Object> adminContact1 = new HashMap<>();
@ -89,7 +89,7 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_updateContacts_requiredTypes_error() throws Exception {
public void testPost_updateContacts_requiredTypes_error() {
Map<String, Object> reqJson = loadRegistrar(CLIENT_ID).toJsonMap();
reqJson.put("contacts",
ImmutableList.of(AppEngineRule.makeRegistrarContact2()
@ -105,7 +105,7 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_updateContacts_requireTechPhone_error() throws Exception {
public void testPost_updateContacts_requireTechPhone_error() {
// First make the contact a tech contact as well.
Registrar registrar = loadRegistrar(CLIENT_ID);
RegistrarContact rc = AppEngineRule.makeRegistrarContact2()
@ -130,7 +130,7 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_updateContacts_cannotRemoveWhoisAbuseContact_error() throws Exception {
public void testPost_updateContacts_cannotRemoveWhoisAbuseContact_error() {
// First make the contact's info visible in whois as abuse contact info.
Registrar registrar = loadRegistrar(CLIENT_ID);
RegistrarContact rc =
@ -156,8 +156,7 @@ public class ContactSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_updateContacts_whoisAbuseContactMustHavePhoneNumber_error()
throws Exception {
public void testPost_updateContacts_whoisAbuseContactMustHavePhoneNumber_error() {
// First make the contact's info visible in whois as abuse contact info.
Registrar registrar = loadRegistrar(CLIENT_ID);
RegistrarContact rc =

View file

@ -70,7 +70,7 @@ public class RegistrarPaymentActionTest {
private final RegistrarPaymentAction paymentAction = new RegistrarPaymentAction();
@Before
public void before() throws Exception {
public void before() {
paymentAction.sessionUtils = sessionUtils;
paymentAction.authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false));
paymentAction.accountIds =
@ -144,7 +144,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testAmountNotPresent_returnsErrorOnAmountField() throws Exception {
public void testAmountNotPresent_returnsErrorOnAmountField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -158,7 +158,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testAmountNotNumber_returnsErrorOnAmountField() throws Exception {
public void testAmountNotNumber_returnsErrorOnAmountField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -173,7 +173,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testNegativeAmount_returnsErrorOnAmountField() throws Exception {
public void testNegativeAmount_returnsErrorOnAmountField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -188,7 +188,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testZeroAmount_returnsErrorOnAmountField() throws Exception {
public void testZeroAmount_returnsErrorOnAmountField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -203,7 +203,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testAmountHasMorePrecisionThanUsdCurrencyAllows_returnsError() throws Exception {
public void testAmountHasMorePrecisionThanUsdCurrencyAllows_returnsError() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -218,7 +218,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testAmountHasMorePrecisionThanJpyCurrencyAllows_returnsError() throws Exception {
public void testAmountHasMorePrecisionThanJpyCurrencyAllows_returnsError() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -233,7 +233,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testCurrencyValidButNotSupported_returnsErrorOnCurrencyField() throws Exception {
public void testCurrencyValidButNotSupported_returnsErrorOnCurrencyField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -248,7 +248,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testCurrencyBogus_returnsErrorOnCurrencyField() throws Exception {
public void testCurrencyBogus_returnsErrorOnCurrencyField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -263,7 +263,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testCurrencyCodeNotAssigned_returnsErrorOnCurrencyField() throws Exception {
public void testCurrencyCodeNotAssigned_returnsErrorOnCurrencyField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -278,7 +278,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testCurrencyMissing_returnsErrorOnCurrencyField() throws Exception {
public void testCurrencyMissing_returnsErrorOnCurrencyField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -292,7 +292,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testPaymentMethodMissing_returnsErrorOnPaymentMethodField() throws Exception {
public void testPaymentMethodMissing_returnsErrorOnPaymentMethodField() {
assertThat(
paymentAction.handleJsonRequest(
ImmutableMap.of(
@ -306,7 +306,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testProcessorDeclined_returnsErrorResponse() throws Exception {
public void testProcessorDeclined_returnsErrorResponse() {
when(result.isSuccess()).thenReturn(false);
when(result.getTransaction()).thenReturn(transaction);
when(transaction.getStatus()).thenReturn(Transaction.Status.PROCESSOR_DECLINED);
@ -325,7 +325,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testGatewayRejectedDueToCvv_returnsErrorResponse() throws Exception {
public void testGatewayRejectedDueToCvv_returnsErrorResponse() {
when(result.isSuccess()).thenReturn(false);
when(result.getTransaction()).thenReturn(transaction);
when(transaction.getStatus()).thenReturn(Transaction.Status.GATEWAY_REJECTED);
@ -343,7 +343,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testGatewayRejectedDueToAddress_returnsErrorResponse() throws Exception {
public void testGatewayRejectedDueToAddress_returnsErrorResponse() {
when(result.isSuccess()).thenReturn(false);
when(result.getTransaction()).thenReturn(transaction);
when(transaction.getStatus()).thenReturn(Transaction.Status.GATEWAY_REJECTED);
@ -361,7 +361,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testSettlementDeclined_returnsErrorResponse() throws Exception {
public void testSettlementDeclined_returnsErrorResponse() {
when(result.isSuccess()).thenReturn(false);
when(result.getTransaction()).thenReturn(transaction);
when(transaction.getStatus()).thenReturn(Transaction.Status.SETTLEMENT_DECLINED);
@ -380,7 +380,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testHasTransactionObjectWithWeirdStatus_returnsErrorResponse() throws Exception {
public void testHasTransactionObjectWithWeirdStatus_returnsErrorResponse() {
when(result.isSuccess()).thenReturn(false);
when(result.getTransaction()).thenReturn(transaction);
when(transaction.getStatus()).thenReturn(Transaction.Status.UNRECOGNIZED);
@ -400,7 +400,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testFailedWithWeirdStatusButNoHelpfulText_usesWeirdStatusAsMsg() throws Exception {
public void testFailedWithWeirdStatusButNoHelpfulText_usesWeirdStatusAsMsg() {
when(result.isSuccess()).thenReturn(false);
when(result.getTransaction()).thenReturn(transaction);
when(transaction.getStatus()).thenReturn(Transaction.Status.FAILED);
@ -417,7 +417,7 @@ public class RegistrarPaymentActionTest {
}
@Test
public void testRemoteValidationError_showsErrorOnlyOnFirstFormField() throws Exception {
public void testRemoteValidationError_showsErrorOnlyOnFirstFormField() {
when(result.isSuccess()).thenReturn(false);
when(result.getErrors()).thenReturn(validationErrors);
when(validationErrors.getAllDeepValidationErrors())

View file

@ -57,7 +57,7 @@ public class RegistrarPaymentSetupActionTest {
private final RegistrarPaymentSetupAction action = new RegistrarPaymentSetupAction();
@Before
public void before() throws Exception {
public void before() {
action.sessionUtils = sessionUtils;
action.authResult = AuthResult.create(AuthLevel.USER, UserAuthInfo.create(user, false));
action.braintreeGateway = braintreeGateway;
@ -74,7 +74,7 @@ public class RegistrarPaymentSetupActionTest {
}
@Test
public void testTokenGeneration() throws Exception {
public void testTokenGeneration() {
action.brainframe = "/doodle";
action.accountIds =
ImmutableMap.of(
@ -95,7 +95,7 @@ public class RegistrarPaymentSetupActionTest {
}
@Test
public void testNonEmptyRequestObject_returnsError() throws Exception {
public void testNonEmptyRequestObject_returnsError() {
assertThat(action.handleJsonRequest(ImmutableMap.of("oh", "no")))
.containsExactly(
"status", "ERROR",
@ -104,7 +104,7 @@ public class RegistrarPaymentSetupActionTest {
}
@Test
public void testNotOnCreditCardBillingTerms_showsErrorPage() throws Exception {
public void testNotOnCreditCardBillingTerms_showsErrorPage() {
Registrar registrar = persistResource(
loadRegistrar("TheRegistrar")
.asBuilder()

View file

@ -94,7 +94,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
* This is the default read test for the registrar settings actions.
*/
@Test
public void testRead_authorized_returnsRegistrarJson() throws Exception {
public void testRead_authorized_returnsRegistrarJson() {
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of());
assertThat(response).containsExactly(
"status", "SUCCESS",
@ -129,7 +129,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_emptyJsonObject_emailFieldNotRequiredWhenEmpty() throws Exception {
public void testUpdate_emptyJsonObject_emailFieldNotRequiredWhenEmpty() {
persistResource(loadRegistrar(CLIENT_ID).asBuilder().setEmailAddress(null).build());
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of(
@ -204,33 +204,33 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_premiumPriceAck() throws Exception {
public void testUpdate_premiumPriceAck() {
doTestUpdate(
Registrar::getPremiumPriceAckRequired, true, Registrar.Builder::setPremiumPriceAckRequired);
}
@Test
public void testUpdate_whoisServer() throws Exception {
public void testUpdate_whoisServer() {
doTestUpdate(Registrar::getWhoisServer, "new-whois.example", Registrar.Builder::setWhoisServer);
}
@Test
public void testUpdate_phoneNumber() throws Exception {
public void testUpdate_phoneNumber() {
doTestUpdate(Registrar::getPhoneNumber, "+1.2345678900", Registrar.Builder::setPhoneNumber);
}
@Test
public void testUpdate_faxNumber() throws Exception {
public void testUpdate_faxNumber() {
doTestUpdate(Registrar::getFaxNumber, "+1.2345678900", Registrar.Builder::setFaxNumber);
}
@Test
public void testUpdate_url() throws Exception {
public void testUpdate_url() {
doTestUpdate(Registrar::getUrl, "new-url.example", Registrar.Builder::setUrl);
}
@Test
public void testUpdate_ipAddressWhitelist() throws Exception {
public void testUpdate_ipAddressWhitelist() {
doTestUpdate(
Registrar::getIpAddressWhitelist,
ImmutableList.of(CidrAddressBlock.create("1.1.1.0/24")),
@ -238,7 +238,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_clientCertificate() throws Exception {
public void testUpdate_clientCertificate() {
doTestUpdate(
Registrar::getClientCertificate,
CertificateSamples.SAMPLE_CERT,
@ -246,7 +246,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_failoverClientCertificate() throws Exception {
public void testUpdate_failoverClientCertificate() {
doTestUpdate(
Registrar::getFailoverClientCertificate,
CertificateSamples.SAMPLE_CERT,
@ -254,7 +254,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_localizedAddress_city() throws Exception {
public void testUpdate_localizedAddress_city() {
doTestUpdate(
Registrar::getLocalizedAddress,
loadRegistrar(CLIENT_ID).getLocalizedAddress().asBuilder().setCity("newCity").build(),
@ -262,7 +262,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_localizedAddress_countryCode() throws Exception {
public void testUpdate_localizedAddress_countryCode() {
doTestUpdate(
Registrar::getLocalizedAddress,
loadRegistrar(CLIENT_ID).getLocalizedAddress().asBuilder().setCountryCode("GB").build(),
@ -270,7 +270,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_localizedAddress_state() throws Exception {
public void testUpdate_localizedAddress_state() {
doTestUpdate(
Registrar::getLocalizedAddress,
loadRegistrar(CLIENT_ID).getLocalizedAddress().asBuilder().setState("NJ").build(),
@ -278,7 +278,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_localizedAddress_street() throws Exception {
public void testUpdate_localizedAddress_street() {
doTestUpdate(
Registrar::getLocalizedAddress,
loadRegistrar(CLIENT_ID)
@ -290,7 +290,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
}
@Test
public void testUpdate_localizedAddress_zip() throws Exception {
public void testUpdate_localizedAddress_zip() {
doTestUpdate(
Registrar::getLocalizedAddress,
loadRegistrar(CLIENT_ID).getLocalizedAddress().asBuilder().setZip("new zip").build(),

View file

@ -43,7 +43,7 @@ import org.junit.runners.JUnit4;
public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
@Test
public void testPost_updateCert_success() throws Exception {
public void testPost_updateCert_success() {
Registrar modified =
loadRegistrar(CLIENT_ID)
.asBuilder()
@ -64,7 +64,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_updateCert_failure() throws Exception {
public void testPost_updateCert_failure() {
Map<String, Object> reqJson = loadRegistrar(CLIENT_ID).toJsonMap();
reqJson.put("clientCertificate", "BLAH");
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of(
@ -75,7 +75,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testChangeCertificates() throws Exception {
public void testChangeCertificates() {
Map<String, Object> jsonMap = loadRegistrar(CLIENT_ID).toJsonMap();
jsonMap.put("clientCertificate", SAMPLE_CERT);
jsonMap.put("failoverClientCertificate", null);
@ -90,7 +90,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testChangeFailoverCertificate() throws Exception {
public void testChangeFailoverCertificate() {
Map<String, Object> jsonMap = loadRegistrar(CLIENT_ID).toJsonMap();
jsonMap.put("failoverClientCertificate", SAMPLE_CERT2);
Map<String, Object> response = action.handleJsonRequest(ImmutableMap.of(
@ -102,7 +102,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testEmptyOrNullCertificate_doesNotClearOutCurrentOne() throws Exception {
public void testEmptyOrNullCertificate_doesNotClearOutCurrentOne() {
Registrar initialRegistrar =
persistResource(
loadRegistrar(CLIENT_ID)
@ -126,7 +126,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testToJsonMap_containsCertificate() throws Exception {
public void testToJsonMap_containsCertificate() {
Map<String, Object> jsonMap =
loadRegistrar(CLIENT_ID)
.asBuilder()
@ -138,7 +138,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testToJsonMap_containsFailoverCertificate() throws Exception {
public void testToJsonMap_containsFailoverCertificate() {
Map<String, Object> jsonMap =
loadRegistrar(CLIENT_ID)
.asBuilder()

View file

@ -53,7 +53,7 @@ public class SendEmailUtilsTest {
private SendEmailUtils sendEmailUtils;
@Before
public void init() throws Exception {
public void init() {
inject.setStaticField(SendEmailUtils.class, "emailService", emailService);
message = new MimeMessage(Session.getDefaultInstance(new Properties(), null));
when(emailService.createMessage()).thenReturn(message);

View file

@ -77,7 +77,7 @@ public class SessionUtilsTest {
}
@Before
public void before() throws Exception {
public void before() {
LoggerConfig.getConfig(SessionUtils.class).addHandler(testLogHandler);
sessionUtils = new SessionUtils();
sessionUtils.registryAdminClientId = ADMIN_CLIENT_ID;
@ -86,14 +86,13 @@ public class SessionUtilsTest {
}
@After
public void after() throws Exception {
public void after() {
LoggerConfig.getConfig(SessionUtils.class).removeHandler(testLogHandler);
}
/** User needs to be logged in before calling checkRegistrarConsoleLogin */
@Test
public void testCheckRegistrarConsoleLogin_notLoggedIn_throwsIllegalStateException()
throws Exception {
public void testCheckRegistrarConsoleLogin_notLoggedIn_throwsIllegalStateException() {
assertThrows(
IllegalStateException.class,
() -> {
@ -107,7 +106,7 @@ public class SessionUtilsTest {
* access should be granted.
*/
@Test
public void testCheckRegistrarConsoleLogin_hasSession_noAccess_isNotAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_hasSession_noAccess_isNotAdmin() {
when(session.getAttribute("clientId")).thenReturn(DEFAULT_CLIENT_ID);
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, UNAUTHORIZED_USER)).isFalse();
verify(session).invalidate();
@ -121,7 +120,7 @@ public class SessionUtilsTest {
* access should be revoked. The admin flag should be ignored.
*/
@Test
public void testCheckRegistrarConsoleLogin_hasSession_noAccess_isAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_hasSession_noAccess_isAdmin() {
when(session.getAttribute("clientId")).thenReturn(DEFAULT_CLIENT_ID);
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, UNAUTHORIZED_ADMIN)).isFalse();
verify(session).invalidate();
@ -135,7 +134,7 @@ public class SessionUtilsTest {
* should be allowed.
*/
@Test
public void testCheckRegistrarConsoleLogin_hasSession_hasAccess_isNotAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_hasSession_hasAccess_isNotAdmin() {
when(session.getAttribute("clientId")).thenReturn(DEFAULT_CLIENT_ID);
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, AUTHORIZED_USER)).isTrue();
verify(session).getAttribute("clientId");
@ -154,7 +153,7 @@ public class SessionUtilsTest {
* should be allowed. The admin flag should be ignored.
*/
@Test
public void testCheckRegistrarConsoleLogin_hasSession_hasAccess_isAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_hasSession_hasAccess_isAdmin() {
when(session.getAttribute("clientId")).thenReturn(DEFAULT_CLIENT_ID);
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, AUTHORIZED_ADMIN)).isTrue();
verify(session).getAttribute("clientId");
@ -173,7 +172,7 @@ public class SessionUtilsTest {
* should be granted to that registrar.
*/
@Test
public void testCheckRegistrarConsoleLogin_noSession_hasAccess_isNotAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_noSession_hasAccess_isNotAdmin() {
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, AUTHORIZED_USER)).isTrue();
verify(session).setAttribute(eq("clientId"), eq(DEFAULT_CLIENT_ID));
assertAboutLogs()
@ -190,7 +189,7 @@ public class SessionUtilsTest {
* should be granted to that registrar. The admin flag should be ignored.
*/
@Test
public void testCheckRegistrarConsoleLogin_noSession_hasAccess_isAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_noSession_hasAccess_isAdmin() {
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, AUTHORIZED_ADMIN)).isTrue();
verify(session).setAttribute(eq("clientId"), eq(DEFAULT_CLIENT_ID));
assertAboutLogs()
@ -208,8 +207,7 @@ public class SessionUtilsTest {
* configured adminClientId is empty or null, no access is granted.
*/
@Test
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin_adminClientIdEmpty()
throws Exception {
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin_adminClientIdEmpty() {
sessionUtils.registryAdminClientId = "";
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, UNAUTHORIZED_ADMIN)).isFalse();
assertAboutLogs()
@ -228,8 +226,7 @@ public class SessionUtilsTest {
* configured adminClientId does not reference a registry, then no access is granted.
*/
@Test
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin_adminClientIdInvalid()
throws Exception {
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin_adminClientIdInvalid() {
sessionUtils.registryAdminClientId = "NonexistentRegistry";
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, UNAUTHORIZED_ADMIN)).isFalse();
assertAboutLogs()
@ -247,7 +244,7 @@ public class SessionUtilsTest {
* user is an admin, then grant the user access to the validated configured adminClientId.
*/
@Test
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin() {
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, UNAUTHORIZED_ADMIN)).isTrue();
verify(session).setAttribute(eq("clientId"), eq(ADMIN_CLIENT_ID));
assertAboutLogs()
@ -269,8 +266,7 @@ public class SessionUtilsTest {
* We continue to grant the admin access.
*/
@Test
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin_secondRequest()
throws Exception {
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isAdmin_secondRequest() {
when(session.getAttribute("clientId")).thenReturn(ADMIN_CLIENT_ID);
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, UNAUTHORIZED_ADMIN)).isTrue();
assertAboutLogs()
@ -287,7 +283,7 @@ public class SessionUtilsTest {
* access should not be granted.
*/
@Test
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isNotAdmin() throws Exception {
public void testCheckRegistrarConsoleLogin_noSession_noAccess_isNotAdmin() {
assertThat(sessionUtils.checkRegistrarConsoleLogin(req, UNAUTHORIZED_USER)).isFalse();
assertAboutLogs()
.that(testLogHandler)
@ -299,7 +295,7 @@ public class SessionUtilsTest {
}
@Test
public void testHasAccessToRegistrar_orphanedContact_returnsFalse() throws Exception {
public void testHasAccessToRegistrar_orphanedContact_returnsFalse() {
deleteResource(loadRegistrar(DEFAULT_CLIENT_ID));
assertThat(
sessionUtils.hasAccessToRegistrar(DEFAULT_CLIENT_ID, THE_REGISTRAR_GAE_USER_ID, false))
@ -307,7 +303,7 @@ public class SessionUtilsTest {
}
@Test
public void testHasAccessToRegistrar_accessRevoked_returnsFalse() throws Exception {
public void testHasAccessToRegistrar_accessRevoked_returnsFalse() {
RegistrarContact.updateContacts(loadRegistrar(DEFAULT_CLIENT_ID), new java.util.HashSet<>());
assertThat(
sessionUtils.hasAccessToRegistrar(DEFAULT_CLIENT_ID, THE_REGISTRAR_GAE_USER_ID, false))
@ -315,8 +311,7 @@ public class SessionUtilsTest {
}
@Test
public void testHasAccessToRegistrar_orphanedAdmin_notAdminRegistrar_returnsFalse()
throws Exception {
public void testHasAccessToRegistrar_orphanedAdmin_notAdminRegistrar_returnsFalse() {
RegistrarContact.updateContacts(loadRegistrar(DEFAULT_CLIENT_ID), new java.util.HashSet<>());
assertThat(
sessionUtils.hasAccessToRegistrar(DEFAULT_CLIENT_ID, THE_REGISTRAR_GAE_USER_ID, true))
@ -324,8 +319,7 @@ public class SessionUtilsTest {
}
@Test
public void testHasAccessToRegistrar_orphanedAdmin_onAdminRegistrar_returnsTrue()
throws Exception {
public void testHasAccessToRegistrar_orphanedAdmin_onAdminRegistrar_returnsTrue() {
RegistrarContact.updateContacts(loadRegistrar(ADMIN_CLIENT_ID), new java.util.HashSet<>());
assertThat(
sessionUtils.hasAccessToRegistrar(ADMIN_CLIENT_ID, THE_REGISTRAR_GAE_USER_ID, true))
@ -333,7 +327,7 @@ public class SessionUtilsTest {
}
@Test
public void testNullness() throws Exception {
public void testNullness() {
new NullPointerTester()
.setDefault(HttpServletRequest.class, req)
.setDefault(HttpServletResponse.class, rsp)

View file

@ -37,7 +37,7 @@ import org.junit.runners.JUnit4;
public class WhoisSettingsTest extends RegistrarSettingsActionTestCase {
@Test
public void testPost_update_success() throws Exception {
public void testPost_update_success() {
Registrar modified =
loadRegistrar(CLIENT_ID)
.asBuilder()
@ -63,7 +63,7 @@ public class WhoisSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_badUsStateCode_returnsFormFieldError() throws Exception {
public void testPost_badUsStateCode_returnsFormFieldError() {
Registrar modified =
loadRegistrar(CLIENT_ID)
.asBuilder()
@ -88,7 +88,7 @@ public class WhoisSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_badAddress_returnsFormFieldError() throws Exception {
public void testPost_badAddress_returnsFormFieldError() {
Registrar modified =
loadRegistrar(CLIENT_ID)
.asBuilder()
@ -114,7 +114,7 @@ public class WhoisSettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
public void testPost_badWhoisServer_returnsFormFieldError() throws Exception {
public void testPost_badWhoisServer_returnsFormFieldError() {
Registrar modified =
loadRegistrar(CLIENT_ID).asBuilder().setWhoisServer("tears@dry.tragical.lol").build();
Map<String, Object> response =