Remove more old-console-related files (#2866)

This commit is contained in:
gbrodman
2025-11-05 19:43:59 +00:00
committed by GitHub
parent 34bea69a48
commit 7b8d07954b
20 changed files with 6 additions and 2012 deletions
@@ -30,7 +30,6 @@ import google.registry.monitoring.whitebox.StackdriverModule;
import google.registry.privileges.secretmanager.SecretManagerModule;
import google.registry.request.Modules;
import google.registry.request.auth.AuthModule;
import google.registry.ui.ConsoleDebug;
import google.registry.util.UtilsModule;
import jakarta.inject.Singleton;
@@ -40,7 +39,6 @@ import jakarta.inject.Singleton;
AuthModule.class,
CloudTasksUtilsModule.class,
RegistryConfig.ConfigModule.class,
ConsoleDebug.ConsoleConfigModule.class,
CredentialModule.class,
CustomLogicFactoryModule.class,
CloudTasksUtilsModule.class,
@@ -35,12 +35,6 @@ public final class RegistryTestServer {
public static final ImmutableMap<String, Path> RUNFILES =
new ImmutableMap.Builder<String, Path>()
.put(
"/index.html",
PROJECT_ROOT.resolve("core/src/main/java/google/registry/ui/html/index.html"))
.put(
"/error.html",
PROJECT_ROOT.resolve("core/src/main/java/google/registry/ui/html/error.html"))
.put("/console/*", PROJECT_ROOT.resolve("console-webapp/staged/dist"))
.build();
@@ -28,7 +28,6 @@ import google.registry.request.auth.AuthResult;
import google.registry.request.auth.OidcTokenAuthenticationMechanism;
import google.registry.testing.DatabaseHelper;
import google.registry.tools.params.HostAndPortParameter;
import google.registry.ui.ConsoleDebug;
import java.util.List;
/** Command-line interface for {@link RegistryTestServer}. */
@@ -42,11 +41,6 @@ public final class RegistryTestServerMain {
private static final String LIGHT_PURPLE = "\u001b[38;5;139m";
private static final String ORANGE = "\u001b[1;38;5;172m";
@Parameter(
names = "--mode",
description = "UI console debug mode. RAW allows live editing; DEBUG allows rename testing.")
private ConsoleDebug mode = ConsoleDebug.PRODUCTION;
@Parameter(
names = "--address",
description = "Listening address.",
@@ -67,14 +61,10 @@ public final class RegistryTestServerMain {
arity = 1)
private boolean loginIsAdmin = true;
@Parameter(
names = "--jetty_debug",
description = "Enables Jetty debug logging.")
@Parameter(names = "--jetty_debug", description = "Enables Jetty debug logging.")
private boolean jettyDebug;
@Parameter(
names = "--jetty_verbose",
description = "Enables Jetty verbose logging.")
@Parameter(names = "--jetty_verbose", description = "Enables Jetty verbose logging.")
private boolean jettyVerbose;
@Parameter(
@@ -96,7 +86,6 @@ public final class RegistryTestServerMain {
}
private void run() throws Throwable {
ConsoleDebug.set(mode);
if (jettyDebug) {
System.setProperty("DEBUG", "true");
}
@@ -105,7 +94,7 @@ public final class RegistryTestServerMain {
}
System.out.printf(
"""
"""
CHARLESTON ROAD REGISTRY SHARED REGISTRATION SYSTEM
ICANN-GTLD-AGB-20120604
@@ -1,62 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.ui.forms;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.testing.NullPointerTester;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link FormFieldException}. */
class FormFieldExceptionTest {
@Test
void testGetFieldName_multiplePropagations_joinsUsingJsonNotation() {
assertThat(
new FormFieldException("This field is required.")
.propagate("attack")
.propagate("cat")
.propagate(0)
.propagate("lol")
.getFieldName())
.isEqualTo("lol[0].cat.attack");
}
@Test
void testGetFieldName_singlePropagations_noFancyJoining() {
assertThat(
new FormFieldException("This field is required.")
.propagate("cat")
.getFieldName())
.isEqualTo("cat");
}
@Test
void testGetFieldName_noPropagations_throwsIse() {
assertThrows(
IllegalStateException.class,
() -> new FormFieldException("This field is required.").getFieldName());
}
@Test
void testNullness() {
NullPointerTester tester = new NullPointerTester()
.setDefault(FormField.class, FormField.named("love").build());
tester.testAllPublicConstructors(FormFieldException.class);
tester.testAllPublicStaticMethods(FormFieldException.class);
tester.testAllPublicInstanceMethods(new FormFieldException("lol"));
}
}
@@ -1,486 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.ui.forms;
import static com.google.common.collect.Range.atLeast;
import static com.google.common.collect.Range.atMost;
import static com.google.common.collect.Range.closed;
import static com.google.common.truth.Truth.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.testing.NullPointerTester;
import com.google.re2j.Pattern;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link FormField}. */
class FormFieldTest {
private enum ICanHazEnum {
LOL,
CAT
}
@Test
void testConvert_nullString_notPresent() {
assertThat(FormField.named("lol").build().convert(null)).isEmpty();
}
@Test
void testConvert_emptyString_returnsEmpty() {
assertThat(FormField.named("lol").build().convert("")).hasValue("");
}
@Test
void testWithDefault_hasValue_returnsValue() {
assertThat(FormField.named("lol").withDefault("default").build().convert("return me!"))
.hasValue("return me!");
}
@Test
void testWithDefault_nullValue_returnsDefault() {
assertThat(FormField.named("lol").withDefault("default").build().convert(null))
.hasValue("default");
}
@Test
void testEmptyToNull_emptyString_notPresent() {
assertThat(FormField.named("lol").emptyToNull().build().convert("")).isEmpty();
}
@Test
void testEmptyToNullRequired_emptyString_throwsFfe() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() -> FormField.named("lol").emptyToNull().required().build().convert(""));
assertThat(thrown, equalTo(new FormFieldException("This field is required.").propagate("lol")));
}
@Test
void testEmptyToNull_typeMismatch() {
assertThrows(
IllegalStateException.class, () -> FormField.named("lol", Object.class).emptyToNull());
}
@Test
void testNamedLong() {
assertThat(FormField.named("lol", Long.class).build().convert(666L)).hasValue(666L);
}
@Test
void testUppercased() {
FormField<String, String> field = FormField.named("lol").uppercased().build();
assertThat(field.convert(null)).isEmpty();
assertThat(field.convert("foo")).hasValue("FOO");
assertThat(field.convert("BAR")).hasValue("BAR");
}
@Test
void testLowercased() {
FormField<String, String> field = FormField.named("lol").lowercased().build();
assertThat(field.convert(null)).isEmpty();
assertThat(field.convert("foo")).hasValue("foo");
assertThat(field.convert("BAR")).hasValue("bar");
}
@Test
void testIn_passesThroughNull() {
FormField<String, String> field =
FormField.named("lol").in(ImmutableSet.of("foo", "bar")).build();
assertThat(field.convert(null)).isEmpty();
}
@Test
void testIn_valueIsContainedInSet() {
FormField<String, String> field =
FormField.named("lol").in(ImmutableSet.of("foo", "bar")).build();
assertThat(field.convert("foo")).hasValue("foo");
assertThat(field.convert("bar")).hasValue("bar");
}
@Test
void testIn_valueMissingFromSet() {
FormField<String, String> field =
FormField.named("lol").in(ImmutableSet.of("foo", "bar")).build();
FormFieldException thrown = assertThrows(FormFieldException.class, () -> field.convert("omfg"));
assertThat(thrown, equalTo(new FormFieldException("Unrecognized value.").propagate("lol")));
}
@Test
void testRange_hasLowerBound_nullValue_passesThrough() {
assertThat(FormField.named("lol").range(atLeast(5)).build().convert(null)).isEmpty();
}
@Test
void testRange_minimum_stringLengthEqualToMinimum_doesNothing() {
assertThat(FormField.named("lol").range(atLeast(5)).build().convert("hello")).hasValue("hello");
}
@Test
void testRange_minimum_stringLengthShorterThanMinimum_throwsFfe() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() -> FormField.named("lol").range(atLeast(4)).build().convert("lol"));
assertThat(thrown).hasMessageThat().contains("Number of characters (3) not in range [4");
}
@Test
void testRange_noLowerBound_nullValue_passThrough() {
assertThat(FormField.named("lol").range(atMost(5)).build().convert(null)).isEmpty();
}
@Test
void testRange_maximum_stringLengthEqualToMaximum_doesNothing() {
assertThat(FormField.named("lol").range(atMost(5)).build().convert("hello")).hasValue("hello");
}
@Test
void testRange_maximum_stringLengthShorterThanMaximum_throwsFfe() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() -> FormField.named("lol").range(atMost(5)).build().convert("omgomg"));
assertThat(thrown).hasMessageThat().contains("Number of characters (6) not in range");
}
@Test
void testRange_numericTypes() {
FormField.named("lol", Byte.class).range(closed(5, 10)).build().convert((byte) 7);
FormField.named("lol", Short.class).range(closed(5, 10)).build().convert((short) 7);
FormField.named("lol", Integer.class).range(closed(5, 10)).build().convert(7);
FormField.named("lol", Long.class).range(closed(5, 10)).build().convert(7L);
FormField.named("lol", Float.class).range(closed(5, 10)).build().convert(7F);
FormField.named("lol", Double.class).range(closed(5, 10)).build().convert(7D);
}
@Test
void testRange_typeMismatch() {
assertThrows(
IllegalStateException.class, () -> FormField.named("lol", Object.class).range(atMost(5)));
}
@Test
void testMatches_matches_doesNothing() {
assertThat(FormField.named("lol").matches(Pattern.compile("[a-z]+")).build().convert("abc"))
.hasValue("abc");
}
@Test
void testMatches_mismatch_throwsFfeAndShowsDefaultErrorMessageWithPattern() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() ->
FormField.named("lol")
.matches(Pattern.compile("[a-z]+"))
.build()
.convert("123abc456"));
assertThat(
thrown, equalTo(new FormFieldException("Must match pattern: [a-z]+").propagate("lol")));
}
@Test
void testMatches_typeMismatch() {
assertThrows(
IllegalStateException.class,
() -> FormField.named("lol", Object.class).matches(Pattern.compile(".")));
}
@Test
void testRetains() {
assertThat(
FormField.named("lol")
.retains(CharMatcher.anyOf("0123456789"))
.build()
.convert(" 123 1593-43 453 45 4 4 \t"))
.hasValue("1231593434534544");
}
@Test
void testCast() {
assertThat(
FormField.named("lol")
.transform(Integer.class, Integer::parseInt)
.build()
.convert("123"))
.hasValue(123);
}
@Test
void testCast_twice() {
assertThat(
FormField.named("lol")
.transform(Object.class, Integer::parseInt)
.transform(String.class, Object::toString)
.build()
.convert("123"))
.hasValue("123");
}
@Test
void testAsList_null_notPresent() {
assertThat(FormField.named("lol").asList().build().convert(null)).isEmpty();
}
@Test
void testAsList_empty_returnsEmpty() {
assertThat(FormField.named("lol").asList().build().convert(ImmutableList.of()))
.hasValue(ImmutableList.of());
}
@Test
void testAsListEmptyToNullRequired_empty_throwsFfe() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() ->
FormField.named("lol")
.asList()
.emptyToNull()
.required()
.build()
.convert(ImmutableList.of()));
assertThat(thrown, equalTo(new FormFieldException("This field is required.").propagate("lol")));
}
@Test
void testListEmptyToNull_empty_notPresent() {
assertThat(FormField.named("lol").asList().emptyToNull().build().convert(ImmutableList.of()))
.isEmpty();
}
@Test
void testAsEnum() {
FormField<String, ICanHazEnum> omgField =
FormField.named("omg").asEnum(ICanHazEnum.class).build();
assertThat(omgField.convert("LOL")).hasValue(ICanHazEnum.LOL);
assertThat(omgField.convert("CAT")).hasValue(ICanHazEnum.CAT);
}
@Test
void testAsEnum_lowercase_works() {
FormField<String, ICanHazEnum> omgField =
FormField.named("omg").asEnum(ICanHazEnum.class).build();
assertThat(omgField.convert("lol")).hasValue(ICanHazEnum.LOL);
assertThat(omgField.convert("cat")).hasValue(ICanHazEnum.CAT);
}
@Test
void testAsEnum_badInput_throwsFfe() {
FormField<String, ICanHazEnum> omgField =
FormField.named("omg").asEnum(ICanHazEnum.class).build();
FormFieldException thrown =
assertThrows(FormFieldException.class, () -> omgField.convert("helo"));
assertThat(
thrown,
equalTo(
new FormFieldException("Enum ICanHazEnum does not contain 'helo'").propagate("omg")));
}
@Test
void testSplitList() {
FormField<String, List<String>> field =
FormField.named("lol").asList(Splitter.on(',').omitEmptyStrings()).build();
assertThat(field.convert("oh,my,goth").get()).containsExactly("oh", "my", "goth").inOrder();
assertThat(field.convert("").get()).isEmpty();
assertThat(field.convert(null)).isEmpty();
}
@Test
void testSplitSet() {
FormField<String, Set<String>> field =
FormField.named("lol").uppercased().asSet(Splitter.on(',').omitEmptyStrings()).build();
assertThat(field.convert("oh,my,goth").get()).containsExactly("OH", "MY", "GOTH").inOrder();
assertThat(field.convert("").get()).isEmpty();
assertThat(field.convert(null)).isEmpty();
}
@Test
void testAsList() {
assertThat(
FormField.named("lol")
.asList()
.build()
.convert(ImmutableList.of("lol", "cat", ""))
.get())
.containsExactly("lol", "cat", "")
.inOrder();
}
@Test
void testAsList_trimmedEmptyToNullOnItems() {
assertThat(
FormField.named("lol")
.trimmed()
.emptyToNull()
.matches(Pattern.compile("[a-z]+"))
.asList()
.range(closed(1, 2))
.build()
.convert(ImmutableList.of("lol\n", "\tcat "))
.get())
.containsExactly("lol", "cat")
.inOrder();
}
@Test
void testAsList_nullElements_getIgnored() {
assertThat(
FormField.named("lol")
.emptyToNull()
.asList()
.build()
.convert(ImmutableList.of("omg", ""))
.get())
.containsExactly("omg");
}
@Test
void testAsListRequiredElements_nullElement_throwsFfeWithIndex() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() ->
FormField.named("lol")
.emptyToNull()
.required()
.asList()
.build()
.convert(ImmutableList.of("omg", "")));
assertThat(
thrown,
equalTo(new FormFieldException("This field is required.").propagate(1).propagate("lol")));
}
@Test
void testMapAsListRequiredElements_nullElement_throwsFfeWithIndexAndKey() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() ->
FormField.mapNamed("lol")
.transform(
String.class,
input ->
FormField.named("cat")
.emptyToNull()
.required()
.build()
.extractUntyped(input)
.get())
.asList()
.build()
.convert(ImmutableList.of(ImmutableMap.of("cat", ""))));
assertThat(
thrown,
equalTo(
new FormFieldException("This field is required.")
.propagate("cat")
.propagate(0)
.propagate("lol")));
}
@Test
void testAsListTrimmed_typeMismatch() {
FormField.named("lol").trimmed().asList();
assertThrows(IllegalStateException.class, () -> FormField.named("lol").asList().trimmed());
}
@Test
void testAsMatrix() {
assertThat(
FormField.named("lol", Integer.class)
.transform(input -> input * 2)
.asList()
.asList()
.build()
.convert(
Lists.cartesianProduct(
ImmutableList.of(ImmutableList.of(1, 2), ImmutableList.of(3, 4))))
.get())
.containsExactly(
ImmutableList.of(2, 6),
ImmutableList.of(2, 8),
ImmutableList.of(4, 6),
ImmutableList.of(4, 8))
.inOrder();
}
@Test
void testAsSet() {
assertThat(
FormField.named("lol")
.asSet()
.build()
.convert(ImmutableList.of("lol", "cat", "cat"))
.get())
.containsExactly("lol", "cat");
}
@Test
void testTrimmed() {
assertThat(FormField.named("lol").trimmed().build().convert(" \thello \t\n")).hasValue("hello");
}
@Test
void testTrimmed_typeMismatch() {
assertThrows(IllegalStateException.class, () -> FormField.named("lol", Object.class).trimmed());
}
@Test
void testAsBuilder() {
FormField<String, String> field = FormField.named("omg").uppercased().build();
assertThat(field.name()).isEqualTo("omg");
assertThat(field.convert("hello")).hasValue("HELLO");
field = field.asBuilder().build();
assertThat(field.name()).isEqualTo("omg");
assertThat(field.convert("hello")).hasValue("HELLO");
}
@Test
void testAsBuilderNamed() {
FormField<String, String> field = FormField.named("omg").uppercased().build();
assertThat(field.name()).isEqualTo("omg");
assertThat(field.convert("hello")).hasValue("HELLO");
field = field.asBuilderNamed("bog").build();
assertThat(field.name()).isEqualTo("bog");
assertThat(field.convert("hello")).hasValue("HELLO");
}
@Test
void testNullness() {
NullPointerTester tester =
new NullPointerTester()
.setDefault(Class.class, Object.class)
.setDefault(Function.class, x -> x)
.setDefault(Pattern.class, Pattern.compile("."))
.setDefault(String.class, "hello.com");
tester.testAllPublicStaticMethods(FormField.class);
tester.testAllPublicInstanceMethods(FormField.named("lol"));
tester.testAllPublicInstanceMethods(FormField.named("lol").build());
}
}
@@ -1,108 +0,0 @@
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.ui.forms;
import static com.google.common.truth.Truth.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.testing.NullPointerTester;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link FormFields}. */
class FormFieldsTest {
@Test
void testXsToken_collapsesAndTrimsWhitespace() {
assertThat(FormFields.XS_TOKEN.convert(" hello \r\n\t there\n")).hasValue("hello there");
}
@Test
void testXsNormalizedString_extraSpaces_doesntCare() {
assertThat(FormFields.XS_NORMALIZED_STRING.convert("hello there")).hasValue("hello there");
}
@Test
void testXsNormalizedString_sideSpaces_doesntCare() {
assertThat(FormFields.XS_NORMALIZED_STRING.convert(" hello there ")).hasValue(" hello there ");
}
@Test
void testXsNormalizedString_containsNonSpaceWhitespace_fails() {
FormFieldException thrown =
assertThrows(
FormFieldException.class,
() -> FormFields.XS_NORMALIZED_STRING.convert(" hello \r\n\t there\n"));
assertThat(
thrown,
equalTo(
new FormFieldException("Must not contain tabs or multiple lines.")
.propagate("xsNormalizedString")));
}
@Test
void testXsEppE164PhoneNumber_nanpaNumber_validates() {
assertThat(FormFields.XS_NORMALIZED_STRING.convert("+1.2125650000")).hasValue("+1.2125650000");
}
@Test
void testXsEppE164PhoneNumber_londonNumber_validates() {
assertThat(FormFields.XS_NORMALIZED_STRING.convert("+44.2011112222"))
.hasValue("+44.2011112222");
}
@Test
void testXsEppE164PhoneNumber_localizedNumber_fails() {
FormFieldException thrown =
assertThrows(
FormFieldException.class, () -> FormFields.PHONE_NUMBER.convert("(212) 565-0000"));
assertThat(thrown)
.hasMessageThat()
.contains("Must be a valid +E.164 phone number, e.g. +1.2125650000");
}
@Test
void testXsEppE164PhoneNumber_appliesXsTokenTransform() {
assertThat(FormFields.PHONE_NUMBER.convert(" +1.2125650000 \r")).hasValue("+1.2125650000");
}
@Test
void testXsEppRoid_correctSyntax_validates() {
assertThat(FormFields.ROID.convert("SH8013-REP")).hasValue("SH8013-REP");
}
@Test
void testXsEppRoid_lowerCase_validates() {
assertThat(FormFields.ROID.convert("sh8013-rep")).hasValue("sh8013-rep");
}
@Test
void testXsEppRoid_missingHyphen_fails() {
FormFieldException thrown =
assertThrows(FormFieldException.class, () -> FormFields.ROID.convert("SH8013REP"));
assertThat(thrown).hasMessageThat().contains("Please enter a valid EPP ROID, e.g. SH8013-REP");
}
@Test
void testXsEppRoid_appliesXsTokenTransform() {
assertThat(FormFields.ROID.convert("\n FOO-BAR \r")).hasValue("FOO-BAR");
}
@Test
void testNullness() {
new NullPointerTester().testAllPublicStaticMethods(FormFields.class);
}
}