Add domain check and update registration type extensions

This completes the command extensions for the regType 0.2 extension.
Up next will be the response extensions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123322887
This commit is contained in:
mcilwain 2016-05-26 08:48:02 -07:00 committed by Ben McIlwain
parent 510da196d7
commit 041b2c4116
11 changed files with 158 additions and 6 deletions

View file

@ -31,6 +31,7 @@ import google.registry.model.domain.fee.FeeCheckExtension;
import google.registry.model.domain.fee.FeeCheckResponseExtension; import google.registry.model.domain.fee.FeeCheckResponseExtension;
import google.registry.model.domain.fee.FeeCheckResponseExtension.FeeCheck; import google.registry.model.domain.fee.FeeCheckResponseExtension.FeeCheck;
import google.registry.model.domain.launch.LaunchCheckExtension; import google.registry.model.domain.launch.LaunchCheckExtension;
import google.registry.model.domain.regtype.RegTypeCheckExtension;
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension; import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
import google.registry.model.eppoutput.CheckData; import google.registry.model.eppoutput.CheckData;
import google.registry.model.eppoutput.CheckData.DomainCheck; import google.registry.model.eppoutput.CheckData.DomainCheck;
@ -65,9 +66,13 @@ import java.util.Set;
*/ */
public class DomainCheckFlow extends BaseDomainCheckFlow { public class DomainCheckFlow extends BaseDomainCheckFlow {
protected RegTypeCheckExtension regTypeExtension;
@Override @Override
protected void initDomainCheckFlow() throws EppException { protected void initDomainCheckFlow() throws EppException {
registerExtensions(LaunchCheckExtension.class, FeeCheckExtension.class); registerExtensions(
LaunchCheckExtension.class, FeeCheckExtension.class, RegTypeCheckExtension.class);
regTypeExtension = eppInput.getSingleExtension(RegTypeCheckExtension.class);
} }
private String getMessageForCheck(String targetId, Set<String> existingIds) { private String getMessageForCheck(String targetId, Set<String> existingIds) {

View file

@ -28,6 +28,7 @@ import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainResource;
import google.registry.model.domain.DomainResource.Builder; import google.registry.model.domain.DomainResource.Builder;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.regtype.RegTypeUpdateExtension;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.SecDnsUpdateExtension; import google.registry.model.domain.secdns.SecDnsUpdateExtension;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -67,9 +68,12 @@ import java.util.Set;
*/ */
public class DomainUpdateFlow extends BaseDomainUpdateFlow<DomainResource, Builder> { public class DomainUpdateFlow extends BaseDomainUpdateFlow<DomainResource, Builder> {
protected RegTypeUpdateExtension regTypeExtension;
@Override @Override
protected void initDomainUpdateFlow() { protected void initDomainUpdateFlow() {
registerExtensions(SecDnsUpdateExtension.class); registerExtensions(SecDnsUpdateExtension.class, RegTypeUpdateExtension.class);
regTypeExtension = eppInput.getSingleExtension(RegTypeUpdateExtension.class);
} }
@Override @Override

View file

@ -17,7 +17,6 @@ package google.registry.model.domain.regtype;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.eppinput.EppInput.CommandExtension;
import java.util.List; import java.util.List;
@ -29,7 +28,7 @@ import javax.xml.bind.annotation.XmlElement;
* *
* @see "https://gitlab.centralnic.com/centralnic/epp-registration-type-extension/tree/master" * @see "https://gitlab.centralnic.com/centralnic/epp-registration-type-extension/tree/master"
*/ */
public class BaseRegTypeCommand extends ImmutableObject implements CommandExtension { public class BaseRegTypeCommand extends ImmutableObject {
/** The registration type (which may be a comma-delimited list of values). */ /** The registration type (which may be a comma-delimited list of values). */
@XmlElement(name = "type") @XmlElement(name = "type")

View file

@ -0,0 +1,25 @@
// Copyright 2016 The Domain Registry 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.model.domain.regtype;
import google.registry.model.eppinput.EppInput.CommandExtension;
import javax.xml.bind.annotation.XmlRootElement;
/**
* A registration type extension that may be present on domain check EPP commands.
*/
@XmlRootElement(name = "check")
public class RegTypeCheckExtension extends BaseRegTypeCommand implements CommandExtension {}

View file

@ -14,10 +14,12 @@
package google.registry.model.domain.regtype; package google.registry.model.domain.regtype;
import google.registry.model.eppinput.EppInput.CommandExtension;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
/** /**
* A registration type extension that may be present on EPP domain create commands. * A registration type extension that may be present on domain create EPP commands.
*/ */
@XmlRootElement(name = "create") @XmlRootElement(name = "create")
public class RegTypeCreateExtension extends BaseRegTypeCommand {} public class RegTypeCreateExtension extends BaseRegTypeCommand implements CommandExtension {}

View file

@ -0,0 +1,37 @@
// Copyright 2016 The Domain Registry 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.model.domain.regtype;
import google.registry.model.ImmutableObject;
import google.registry.model.eppinput.EppInput.CommandExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* A registration type extension that may be present on domain update EPP commands.
*/
@XmlRootElement(name = "update")
public class RegTypeUpdateExtension extends ImmutableObject implements CommandExtension {
@XmlElement(name = "chg")
protected BaseRegTypeCommand regTypeChg;
public List<String> getRegistrationTypes() {
return regTypeChg.getRegistrationTypes();
}
}

View file

@ -37,7 +37,9 @@ import google.registry.model.domain.launch.LaunchDeleteExtension;
import google.registry.model.domain.launch.LaunchInfoExtension; import google.registry.model.domain.launch.LaunchInfoExtension;
import google.registry.model.domain.launch.LaunchUpdateExtension; import google.registry.model.domain.launch.LaunchUpdateExtension;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.domain.regtype.RegTypeCheckExtension;
import google.registry.model.domain.regtype.RegTypeCreateExtension; import google.registry.model.domain.regtype.RegTypeCreateExtension;
import google.registry.model.domain.regtype.RegTypeUpdateExtension;
import google.registry.model.domain.rgp.RgpUpdateExtension; import google.registry.model.domain.rgp.RgpUpdateExtension;
import google.registry.model.domain.secdns.SecDnsCreateExtension; import google.registry.model.domain.secdns.SecDnsCreateExtension;
import google.registry.model.domain.secdns.SecDnsUpdateExtension; import google.registry.model.domain.secdns.SecDnsUpdateExtension;
@ -277,7 +279,9 @@ public class EppInput extends ImmutableObject {
@XmlElementRef(type = LaunchInfoExtension.class), @XmlElementRef(type = LaunchInfoExtension.class),
@XmlElementRef(type = LaunchUpdateExtension.class), @XmlElementRef(type = LaunchUpdateExtension.class),
@XmlElementRef(type = MetadataExtension.class), @XmlElementRef(type = MetadataExtension.class),
@XmlElementRef(type = RegTypeCheckExtension.class),
@XmlElementRef(type = RegTypeCreateExtension.class), @XmlElementRef(type = RegTypeCreateExtension.class),
@XmlElementRef(type = RegTypeUpdateExtension.class),
@XmlElementRef(type = RgpUpdateExtension.class), @XmlElementRef(type = RgpUpdateExtension.class),
@XmlElementRef(type = SecDnsCreateExtension.class), @XmlElementRef(type = SecDnsCreateExtension.class),
@XmlElementRef(type = SecDnsUpdateExtension.class) }) @XmlElementRef(type = SecDnsUpdateExtension.class) })

View file

@ -408,4 +408,14 @@ public class DomainCheckFlowTest
setEppInput("domain_check_fee_invalid_command.xml"); setEppInput("domain_check_fee_invalid_command.xml");
runFlow(); runFlow();
} }
@Test
public void testSuccess_regTypeExtensionValidates() throws Exception {
setEppInput("domain_check_regtype.xml");
persistActiveDomain("example1.tld");
doCheckTest(
create(false, "example1.tld", "In use"),
create(true, "example2.tld", null),
create(true, "example3.tld", null));
}
} }

View file

@ -1108,4 +1108,12 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.build()); .build());
doSuccessfulTest(); doSuccessfulTest();
} }
@Test
public void testSuccess_regTypeExtensionValidates() throws Exception {
setEppInput("domain_update_regtype.xml");
persistReferencedEntities();
persistDomain();
doSuccessfulTest();
}
} }

View file

@ -0,0 +1,18 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<check>
<domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example1.tld</domain:name>
<domain:name>example2.tld</domain:name>
<domain:name>example3.tld</domain:name>
</domain:check>
</check>
<extension>
<regtype:check
xmlns:regtype="urn:ietf:params:xml:ns:regtype-0.2">
<regtype:type>foo,bar,baz</regtype:type>
</regtype:check>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -0,0 +1,40 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<update>
<domain:update
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:add>
<domain:ns>
<domain:hostObj>ns2.example.foo</domain:hostObj>
</domain:ns>
<domain:contact type="tech">mak21</domain:contact>
<domain:status s="clientHold"
lang="en">Payment overdue.</domain:status>
</domain:add>
<domain:rem>
<domain:ns>
<domain:hostObj>ns1.example.foo</domain:hostObj>
</domain:ns>
<domain:contact type="tech">sh8013</domain:contact>
<domain:status s="clientUpdateProhibited"/>
</domain:rem>
<domain:chg>
<domain:registrant>sh8013</domain:registrant>
<domain:authInfo>
<domain:pw>2BARfoo</domain:pw>
</domain:authInfo>
</domain:chg>
</domain:update>
</update>
<extension>
<regType:update
xmlns:regType="urn:ietf:params:xml:ns:regtype-0.2">
<regType:chg>
<regType:type>bar,foo</regType:type>
</regType:chg>
</regType:update>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>