mirror of
https://github.com/google/nomulus.git
synced 2025-05-28 13:51:15 +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
|
@ -26,6 +26,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
|
|||
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
|
||||
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;
|
||||
|
@ -40,6 +41,11 @@ import google.registry.model.ofy.Ofy;
|
|||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
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;
|
||||
|
@ -82,6 +88,7 @@ public class RdapDomainActionTest {
|
|||
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);
|
||||
|
||||
private RdapDomainAction action;
|
||||
|
||||
|
@ -256,6 +263,7 @@ public class RdapDomainActionTest {
|
|||
action = new RdapDomainAction();
|
||||
action.clock = clock;
|
||||
action.request = request;
|
||||
action.requestMethod = Action.Method.GET;
|
||||
action.fullServletPath = "https://example.com/rdap";
|
||||
action.response = response;
|
||||
action.registrarParam = Optional.empty();
|
||||
|
@ -264,6 +272,7 @@ public class RdapDomainActionTest {
|
|||
action.rdapWhoisServer = null;
|
||||
action.sessionUtils = sessionUtils;
|
||||
action.authResult = AuthResult.create(AuthLevel.USER, userAuthInfo);
|
||||
action.rdapMetrics = rdapMetrics;
|
||||
}
|
||||
|
||||
private void login(String clientId) {
|
||||
|
@ -617,4 +626,23 @@ public class RdapDomainActionTest {
|
|||
"rdap_domain_deleted.json"));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetrics() throws Exception {
|
||||
generateActualJson("cat.lol");
|
||||
verify(rdapMetrics)
|
||||
.updateMetrics(
|
||||
RdapMetrics.RdapMetricInformation.builder()
|
||||
.setEndpointType(EndpointType.DOMAIN)
|
||||
.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