1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 06:15:42 +00:00

Allow for no fee extension with free premium domains (#2660)

This isn't a situation we'll encounter often, but if the client has an
allocation token that's valid for premium domains that gives a 0 cost,
we shouldn't require them to include the fee extension when creating the
domain. We already don't require it for standard domains.
This commit is contained in:
gbrodman
2025-02-06 15:40:24 -05:00
committed by GitHub
parent 96a864dbd6
commit 9aaf7ee36a
2 changed files with 22 additions and 1 deletions

View File

@@ -64,7 +64,7 @@ public class FeesAndCredits extends ImmutableObject implements Buildable {
}
public boolean hasAnyPremiumFees() {
return fees.stream().anyMatch(BaseFee::isPremium);
return fees.stream().anyMatch(fee -> fee.isPremium() && !fee.hasZeroCost());
}
/** Returns the create cost for the event. */

View File

@@ -1741,6 +1741,27 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.marshalsToXml();
}
@Test
void testSuccess_token_premiumDomainZeroPrice_noFeeExtension() throws Exception {
createTld("example");
persistContactsAndHosts();
persistResource(
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(SINGLE_USE)
.setDiscountFraction(1)
.setDiscountPremiums(true)
.setDomainName("rich.example")
.build());
setEppInput(
"domain_create_allocationtoken.xml",
ImmutableMap.of("YEARS", "1", "DOMAIN", "rich.example"));
// The response should be the standard successful create response, but with 1 year instead of 2
runFlowAssertResponse(
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "rich.example"))
.replace("2001", "2000"));
}
@Test
void testFailure_promotionNotActive() {
persistContactsAndHosts();