mirror of
https://github.com/google/nomulus.git
synced 2025-06-28 07:13:34 +02:00
Add RDAP metrics for non-search endpoints
This CL uses the previously-defined RDAP metrics class to record basic metrics for all RDAP endpoints, and handles testing of non-search endpoints. Searches are more complicated, and will be handled in future CLs. The default wildcard type is now INVALID rather than NO_WILDCARD. A change to getMatchingResources() (adding an additional parameter) is also included in this CL, as it was needed to set the incompleteness warning type correctly. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175719265
This commit is contained in:
parent
0ffd3553c3
commit
358fe68f09
14 changed files with 288 additions and 31 deletions
|
@ -21,6 +21,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistH
|
|||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
||||
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.appengine.api.users.User;
|
||||
|
@ -29,6 +30,11 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.rdap.RdapMetrics.EndpointType;
|
||||
import google.registry.rdap.RdapMetrics.SearchType;
|
||||
import google.registry.rdap.RdapMetrics.WildcardType;
|
||||
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.auth.AuthLevel;
|
||||
import google.registry.request.auth.AuthResult;
|
||||
import google.registry.request.auth.UserAuthInfo;
|
||||
|
@ -68,6 +74,7 @@ public class RdapNameserverActionTest {
|
|||
private final User user = new User("rdap.user@example.com", "gmail.com", "12345");
|
||||
private final UserAuthInfo userAuthInfo = UserAuthInfo.create(user, false);
|
||||
private final UserAuthInfo adminUserAuthInfo = UserAuthInfo.create(user, true);
|
||||
private final RdapMetrics rdapMetrics = mock(RdapMetrics.class);
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
@ -111,6 +118,7 @@ public class RdapNameserverActionTest {
|
|||
RdapNameserverAction action = new RdapNameserverAction();
|
||||
action.clock = clock;
|
||||
action.request = request;
|
||||
action.requestMethod = Action.Method.GET;
|
||||
action.fullServletPath = "https://example.tld/rdap";
|
||||
action.response = response;
|
||||
action.requestPath = RdapNameserverAction.PATH.concat(input);
|
||||
|
@ -120,6 +128,7 @@ public class RdapNameserverActionTest {
|
|||
action.rdapWhoisServer = null;
|
||||
action.authResult = authResult;
|
||||
action.sessionUtils = sessionUtils;
|
||||
action.rdapMetrics = rdapMetrics;
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@ -427,4 +436,23 @@ public class RdapNameserverActionTest {
|
|||
generateActualJson("ns1.cat.lol", Optional.of("otherregistrar"), Optional.of(false));
|
||||
assertThat(response.getStatus()).isEqualTo(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetrics() throws Exception {
|
||||
generateActualJson("ns1.cat.lol");
|
||||
verify(rdapMetrics)
|
||||
.updateMetrics(
|
||||
RdapMetrics.RdapMetricInformation.builder()
|
||||
.setEndpointType(EndpointType.NAMESERVER)
|
||||
.setSearchType(SearchType.NONE)
|
||||
.setWildcardType(WildcardType.INVALID)
|
||||
.setPrefixLength(0)
|
||||
.setIncludeDeleted(false)
|
||||
.setRegistrarSpecified(false)
|
||||
.setRole(RdapAuthorization.Role.PUBLIC)
|
||||
.setRequestMethod(Action.Method.GET)
|
||||
.setStatusCode(200)
|
||||
.setIncompletenessWarningType(IncompletenessWarningType.COMPLETE)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue