mirror of
https://github.com/google/nomulus.git
synced 2025-08-05 09:21:49 +02:00
Upgrade Nomulus to latest Closure Rules
Significant technical debt has been eliminated. The latest best practices are also now adopted for dealing with runfiles and dealing with files across repositories. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=140762937
This commit is contained in:
parent
79a72387ee
commit
59f4984083
28 changed files with 193 additions and 361 deletions
|
@ -29,9 +29,9 @@ zip_contents_test(
|
|||
name = "zip_emptyMapping_leavesShortPathsInTact",
|
||||
src = "basic.zip",
|
||||
contents = {
|
||||
"javatests/google/registry/builddefs/generated.txt": "generated",
|
||||
"javatests/google/registry/builddefs/hello.txt": "hello",
|
||||
"javatests/google/registry/builddefs/world.txt": "world",
|
||||
"domain_registry/javatests/google/registry/builddefs/generated.txt": "generated",
|
||||
"domain_registry/javatests/google/registry/builddefs/hello.txt": "hello",
|
||||
"domain_registry/javatests/google/registry/builddefs/world.txt": "world",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -39,7 +39,7 @@ zip_file(
|
|||
name = "stripped",
|
||||
srcs = ["hello.txt"],
|
||||
out = "stripped.zip",
|
||||
mappings = {"javatests/google/registry/builddefs": ""},
|
||||
mappings = {"domain_registry/javatests/google/registry/builddefs": ""},
|
||||
)
|
||||
|
||||
zip_contents_test(
|
||||
|
@ -57,8 +57,8 @@ zip_file(
|
|||
],
|
||||
out = "repath.zip",
|
||||
mappings = {
|
||||
"javatests/google/registry/builddefs": "a/b/c",
|
||||
"javatests/google/registry/builddefs/generated.txt": "x/y/z/generated.txt",
|
||||
"domain_registry/javatests/google/registry/builddefs": "a/b/c",
|
||||
"domain_registry/javatests/google/registry/builddefs/generated.txt": "x/y/z/generated.txt",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -76,7 +76,7 @@ zip_file(
|
|||
name = "overridden",
|
||||
srcs = ["override/hello.txt"],
|
||||
out = "overridden.zip",
|
||||
mappings = {"javatests/google/registry/builddefs/override": "a/b/c"},
|
||||
mappings = {"domain_registry/javatests/google/registry/builddefs/override": "a/b/c"},
|
||||
deps = [":repath"],
|
||||
)
|
||||
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
|
||||
"""Build rule for unit testing the zip_file() rule."""
|
||||
|
||||
load('//java/google/registry/builddefs:defs.bzl', 'ZIPPER', 'runpath')
|
||||
load('//java/google/registry/builddefs:defs.bzl', 'ZIPPER')
|
||||
|
||||
def _impl(ctx):
|
||||
"""Implementation of zip_contents_test() rule."""
|
||||
cmd = [
|
||||
'set -e',
|
||||
'repo="$(pwd)"',
|
||||
'zipper="${repo}/%s"' % runpath(ctx.file._zipper),
|
||||
'archive="${repo}/%s"' % runpath(ctx.file.src),
|
||||
'zipper="${repo}/%s"' % ctx.file._zipper.short_path,
|
||||
'archive="${repo}/%s"' % ctx.file.src.short_path,
|
||||
('listing="$("${zipper}" v "${archive}"' +
|
||||
' | grep -v ^d | awk \'{print $3}\' | LC_ALL=C sort)"'),
|
||||
'if [[ "${listing}" != "%s" ]]; then' % (
|
||||
|
|
|
@ -30,17 +30,22 @@ public final class RegistryTestServer {
|
|||
new ImmutableMap.Builder<String, Path>()
|
||||
.put(
|
||||
"/index.html",
|
||||
Paths.get("java/google/registry/ui/html/index.html"))
|
||||
Paths.get(
|
||||
"../domain_registry/java/google/registry/ui/html/index.html"))
|
||||
.put(
|
||||
"/error.html",
|
||||
Paths.get("java/google/registry/ui/html/error.html"))
|
||||
.put("/assets/js/*", Paths.get("java/google/registry/ui"))
|
||||
.put("/assets/css/*", Paths.get("java/google/registry/ui/css"))
|
||||
Paths.get(
|
||||
"../domain_registry/java/google/registry/ui/html/error.html"))
|
||||
.put(
|
||||
"/assets/sources/deps.js",
|
||||
Paths.get("java/google/registry/ui/deps.js"))
|
||||
.put("/assets/sources/*", Paths.get(""))
|
||||
.put("/assets/*", Paths.get("java/google/registry/ui/assets"))
|
||||
"/assets/js/*",
|
||||
Paths.get("../domain_registry/java/google/registry/ui"))
|
||||
.put(
|
||||
"/assets/css/*",
|
||||
Paths.get("../domain_registry/java/google/registry/ui/css"))
|
||||
.put("/assets/sources/*", Paths.get(".."))
|
||||
.put(
|
||||
"/assets/*",
|
||||
Paths.get("../domain_registry/java/google/registry/ui/assets"))
|
||||
.build();
|
||||
|
||||
private static final ImmutableList<Route> ROUTES = ImmutableList.of(
|
||||
|
|
|
@ -16,6 +16,7 @@ package google.registry.server;
|
|||
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.HostAndPort;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
|
@ -27,6 +28,7 @@ import org.junit.runner.Description;
|
|||
import org.junit.runners.model.Statement;
|
||||
|
||||
/** Command-line interface for {@link RegistryTestServer}. */
|
||||
@Parameters(separators = " =", commandDescription = "Runs web development server.")
|
||||
public final class RegistryTestServerMain {
|
||||
|
||||
private static final String RESET = "\u001b[0m";
|
||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.server;
|
|||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Verify.verify;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_FORBIDDEN;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
|
||||
|
||||
|
@ -122,12 +121,7 @@ public final class StaticResourceServlet extends HttpServlet {
|
|||
|
||||
Optional<Path> doHead(HttpServletRequest req, HttpServletResponse rsp) throws IOException {
|
||||
verify(req.getRequestURI().startsWith(prefix));
|
||||
Path file = root.resolve(req.getRequestURI().substring(prefix.length())).normalize();
|
||||
if (!file.startsWith(root)) {
|
||||
logger.infofmt("Evil request: %s (%s) (%s + %s)", req.getRequestURI(), file, root, prefix);
|
||||
rsp.sendError(SC_BAD_REQUEST, "Naughty naughty!");
|
||||
return Optional.absent();
|
||||
}
|
||||
Path file = root.resolve(req.getRequestURI().substring(prefix.length()));
|
||||
if (!Files.exists(file)) {
|
||||
logger.infofmt("Not found: %s (%s)", req.getRequestURI(), file);
|
||||
rsp.sendError(SC_NOT_FOUND, "Not found");
|
||||
|
|
|
@ -11,8 +11,8 @@ closure_js_library(
|
|||
name = "testing",
|
||||
srcs = ["testing.js"],
|
||||
deps = [
|
||||
"//javascript/closure",
|
||||
"//javascript/closure:testing",
|
||||
"@io_bazel_rules_closure//closure/library",
|
||||
"@io_bazel_rules_closure//closure/library:testing",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -25,7 +25,7 @@ closure_js_test(
|
|||
deps = [
|
||||
":testing",
|
||||
"//java/google/registry/ui/js",
|
||||
"//javascript/closure",
|
||||
"//javascript/closure:testing",
|
||||
"@io_bazel_rules_closure//closure/library",
|
||||
"@io_bazel_rules_closure//closure/library:testing",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -13,8 +13,8 @@ closure_js_library(
|
|||
deps = [
|
||||
"//java/google/registry/ui/js",
|
||||
"//java/google/registry/ui/js/registrar",
|
||||
"//javascript/closure",
|
||||
"//javascript/closure:testing",
|
||||
"@io_bazel_rules_closure//closure/library",
|
||||
"@io_bazel_rules_closure//closure/library:testing",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -28,9 +28,9 @@ closure_js_test(
|
|||
":console_test_util",
|
||||
"//java/google/registry/ui/js",
|
||||
"//java/google/registry/ui/js/registrar",
|
||||
"//java/google/registry/ui/soy/registrar:Console",
|
||||
"//javascript/closure",
|
||||
"//javascript/closure:testing",
|
||||
"//java/google/registry/ui/soy/registrar",
|
||||
"//javatests/google/registry/ui/js:testing",
|
||||
"@io_bazel_rules_closure//closure/library",
|
||||
"@io_bazel_rules_closure//closure/library:testing",
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue