mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Display pricing tier even when a domain is reserved
Even though it's not directly related, I also fixed a typo in PREMIUM because it bugged me. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237796791
This commit is contained in:
parent
dc0c1583f5
commit
44e3668510
3 changed files with 39 additions and 11 deletions
|
@ -28,7 +28,7 @@ import static google.registry.monitoring.whitebox.CheckApiMetric.Status.INVALID_
|
|||
import static google.registry.monitoring.whitebox.CheckApiMetric.Status.INVALID_REGISTRY_PHASE;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Status.SUCCESS;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Status.UNKNOWN_ERROR;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.PREMINUM;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.PREMIUM;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.STANDARD;
|
||||
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
import static google.registry.util.DomainNameUtils.canonicalizeDomainName;
|
||||
|
@ -139,10 +139,9 @@ public class CheckApiAction implements Runnable {
|
|||
responseBuilder.put("status", "success").put("available", availability.equals(AVAILABLE));
|
||||
|
||||
boolean isPremium = isDomainPremium(domainString, now);
|
||||
metricBuilder.tier(isPremium ? PREMINUM : STANDARD);
|
||||
if (availability.equals(AVAILABLE)) {
|
||||
responseBuilder.put("tier", isPremium ? "premium" : "standard");
|
||||
} else {
|
||||
metricBuilder.tier(isPremium ? PREMIUM : STANDARD);
|
||||
responseBuilder.put("tier", isPremium ? "premium" : "standard");
|
||||
if (!AVAILABLE.equals(availability)) {
|
||||
responseBuilder.put("reason", errorMsg);
|
||||
}
|
||||
return responseBuilder.build();
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class CheckApiMetric {
|
|||
/** Price tier of a domain name. */
|
||||
public enum Tier {
|
||||
STANDARD("standard"),
|
||||
PREMINUM("premium");
|
||||
PREMIUM("premium");
|
||||
|
||||
private final String displayLabel;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
|
|||
import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.AVAILABLE;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.REGISTERED;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.RESERVED;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.PREMINUM;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.PREMIUM;
|
||||
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.STANDARD;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
||||
|
@ -70,7 +70,9 @@ public class CheckApiActionTest {
|
|||
persistResource(
|
||||
Registry.get("example")
|
||||
.asBuilder()
|
||||
.setReservedLists(persistReservedList("example-reserved", "foo,FULLY_BLOCKED"))
|
||||
.setReservedLists(
|
||||
persistReservedList(
|
||||
"example-reserved", "foo,FULLY_BLOCKED", "gold,RESERVED_FOR_SPECIFIC_USE"))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -213,14 +215,15 @@ public class CheckApiActionTest {
|
|||
"available", true,
|
||||
"tier", "premium");
|
||||
|
||||
verifySuccessMetric(PREMINUM, AVAILABLE);
|
||||
verifySuccessMetric(PREMIUM, AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_alreadyRegistered() {
|
||||
public void testSuccess_registered_standard() {
|
||||
persistActiveDomain("somedomain.example");
|
||||
assertThat(getCheckResponse("somedomain.example"))
|
||||
.containsExactly(
|
||||
"tier", "standard",
|
||||
"status", "success",
|
||||
"available", false,
|
||||
"reason", "In use");
|
||||
|
@ -229,9 +232,10 @@ public class CheckApiActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_reserved() {
|
||||
public void testSuccess_reserved_standard() {
|
||||
assertThat(getCheckResponse("foo.example"))
|
||||
.containsExactly(
|
||||
"tier", "standard",
|
||||
"status", "success",
|
||||
"available", false,
|
||||
"reason", "Reserved");
|
||||
|
@ -239,6 +243,31 @@ public class CheckApiActionTest {
|
|||
verifySuccessMetric(STANDARD, RESERVED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_registered_premium() {
|
||||
persistActiveDomain("rich.example");
|
||||
assertThat(getCheckResponse("rich.example"))
|
||||
.containsExactly(
|
||||
"tier", "premium",
|
||||
"status", "success",
|
||||
"available", false,
|
||||
"reason", "In use");
|
||||
|
||||
verifySuccessMetric(PREMIUM, REGISTERED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_reserved_premium() {
|
||||
assertThat(getCheckResponse("gold.example"))
|
||||
.containsExactly(
|
||||
"tier", "premium",
|
||||
"status", "success",
|
||||
"available", false,
|
||||
"reason", "Reserved");
|
||||
|
||||
verifySuccessMetric(PREMIUM, RESERVED);
|
||||
}
|
||||
|
||||
private void verifySuccessMetric(Tier tier, Availability availability) {
|
||||
verify(checkApiMetrics).incrementCheckApiRequest(metricCaptor.capture());
|
||||
CheckApiMetric metric = metricCaptor.getValue();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue