Add "pubapi" App Engine service for check API, WHOIS, and RDAP

The migration plan is as follows:
1. This CL, which adds the new "pubapi" service that serves the check API, WHOIS, and RDAP.
2a. Update our public facing sites to switch over to use the new service.
2b. (either order) Rewrite the check API to remove dependencies on flows.
3. ... eventually, once the frontend service is no longer being hit by this traffic, remove its handling of these public endpoints.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=197716346
This commit is contained in:
mcilwain 2018-05-23 06:45:35 -07:00 committed by jianglai
parent a5abb05761
commit ac500652ac
22 changed files with 865 additions and 0 deletions

View file

@ -0,0 +1,35 @@
package(
default_testonly = 1,
default_visibility = ["//java/google/registry:registry_project"],
)
licenses(["notice"]) # Apache 2.0
java_library(
name = "pubapi",
srcs = glob(["*.java"]),
resources = glob(["testdata/*"]),
runtime_deps = [
# TODO(b/19332643): Remove this dependency when Modules is lazy.
"@com_google_appengine_api_1_0_sdk//:testonly",
],
deps = [
"//java/google/registry/module/pubapi",
"//java/google/registry/request",
"//javatests/google/registry/testing",
"@com_google_guava",
"@com_google_truth",
"@com_google_truth_extensions_truth_java8_extension",
"@javax_servlet_api",
"@junit",
"@org_mockito_all",
],
)
load("//java/com/google/testing/builddefs:GenTestRules.bzl", "GenTestRules")
GenTestRules(
name = "GeneratedTestRules",
test_files = glob(["*Test.java"]),
deps = [":pubapi"],
)

View file

@ -0,0 +1,33 @@
// Copyright 2018 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.module.pubapi;
import google.registry.testing.GoldenFileTestHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link PubApiRequestComponent}. */
@RunWith(JUnit4.class)
public class PubApiRequestComponentTest {
@Test
public void testRoutingMap() throws Exception {
GoldenFileTestHelper.assertThatRoutesFromComponent(PubApiRequestComponent.class)
.describedAs("pubapi routing map")
.isEqualToGolden(PubApiRequestComponentTest.class, "pubapi_routing.txt");
}
}

View file

@ -0,0 +1,47 @@
// Copyright 2018 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.module.pubapi;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import google.registry.testing.AppEngineRule;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link PubApiServlet}. */
@RunWith(JUnit4.class)
public class PubApiServletTest {
@Rule
public final AppEngineRule appEngine =
AppEngineRule.builder().withDatastore().withLocalModules().build();
private final HttpServletRequest req = mock(HttpServletRequest.class);
private final HttpServletResponse rsp = mock(HttpServletResponse.class);
@Test
public void testService_unknownPath_returnNotFound() throws Exception {
when(req.getMethod()).thenReturn("GET");
when(req.getRequestURI()).thenReturn("/lol");
new PubApiServlet().service(req, rsp);
verify(rsp).sendError(404);
}
}

View file

@ -0,0 +1,13 @@
PATH CLASS METHODS OK AUTH_METHODS MIN USER_POLICY
/_dr/whois WhoisAction POST n INTERNAL,API APP PUBLIC
/check CheckApiAction GET n INTERNAL NONE PUBLIC
/rdap/autnum/(*) RdapAutnumAction GET,HEAD n INTERNAL NONE PUBLIC
/rdap/domain/(*) RdapDomainAction GET,HEAD n INTERNAL,API,LEGACY NONE PUBLIC
/rdap/domains RdapDomainSearchAction GET,HEAD n INTERNAL,API,LEGACY NONE PUBLIC
/rdap/entities RdapEntitySearchAction GET,HEAD n INTERNAL,API,LEGACY NONE PUBLIC
/rdap/entity/(*) RdapEntityAction GET,HEAD n INTERNAL,API,LEGACY NONE PUBLIC
/rdap/help(*) RdapHelpAction GET,HEAD n INTERNAL NONE PUBLIC
/rdap/ip/(*) RdapIpAction GET,HEAD n INTERNAL NONE PUBLIC
/rdap/nameserver/(*) RdapNameserverAction GET,HEAD n INTERNAL NONE PUBLIC
/rdap/nameservers RdapNameserverSearchAction GET,HEAD n INTERNAL NONE PUBLIC
/whois/(*) WhoisHttpAction GET n INTERNAL NONE PUBLIC