Add simple registration type command extension for domain creates

Note that it doesn't do anything yet beyond basic XML validation
because the default registry system doesn't use registration types,
but this serves as a template for the other domain commands using
registration types and provides a method that TLDs implementing custom
logic can use.  This also explicitly doesn't yet handle the response
extensions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123245388
This commit is contained in:
mcilwain 2016-05-25 13:15:32 -07:00 committed by Ben McIlwain
parent ee148ce630
commit a09f478ac0
11 changed files with 142 additions and 3 deletions

View file

@ -63,7 +63,8 @@ public class EppXmlTransformer {
"dsig.xsd", "dsig.xsd",
"smd.xsd", "smd.xsd",
"launch.xsd", "launch.xsd",
"allocate.xsd"); "allocate.xsd",
"regtype.xsd");
private static final XmlTransformer INPUT_TRANSFORMER = private static final XmlTransformer INPUT_TRANSFORMER =
new XmlTransformer(SCHEMAS, EppInput.class); new XmlTransformer(SCHEMAS, EppInput.class);

View file

@ -32,6 +32,7 @@ import google.registry.model.domain.DomainResource.Builder;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.fee.FeeCreateExtension; import google.registry.model.domain.fee.FeeCreateExtension;
import google.registry.model.domain.launch.LaunchCreateExtension; import google.registry.model.domain.launch.LaunchCreateExtension;
import google.registry.model.domain.regtype.RegTypeCreateExtension;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.Registry.TldState;
@ -98,6 +99,8 @@ public class DomainCreateFlow extends DomainCreateOrAllocateFlow {
private static final Set<TldState> QLP_SMD_ALLOWED_STATES = private static final Set<TldState> QLP_SMD_ALLOWED_STATES =
Sets.immutableEnumSet(TldState.SUNRISE, TldState.SUNRUSH); Sets.immutableEnumSet(TldState.SUNRISE, TldState.SUNRUSH);
protected RegTypeCreateExtension regTypeExtension;
private boolean isAnchorTenant() { private boolean isAnchorTenant() {
return isAnchorTenantViaReservation || isAnchorTenantViaExtension; return isAnchorTenantViaReservation || isAnchorTenantViaExtension;
} }
@ -123,7 +126,9 @@ public class DomainCreateFlow extends DomainCreateOrAllocateFlow {
@Override @Override
protected final void initDomainCreateOrAllocateFlow() { protected final void initDomainCreateOrAllocateFlow() {
registerExtensions(FeeCreateExtension.class, LaunchCreateExtension.class); registerExtensions(
FeeCreateExtension.class, LaunchCreateExtension.class, RegTypeCreateExtension.class);
regTypeExtension = eppInput.getSingleExtension(RegTypeCreateExtension.class);
} }
@Override @Override

View file

@ -0,0 +1,42 @@
// 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 com.google.common.base.Splitter;
import google.registry.model.ImmutableObject;
import google.registry.model.eppinput.EppInput.CommandExtension;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
/**
* Base class for general domain commands with registration types (create, update, check, and
* info).
*
* @see "https://gitlab.centralnic.com/centralnic/epp-registration-type-extension/tree/master"
*/
public class BaseRegTypeCommand extends ImmutableObject implements CommandExtension {
/** The registration type (which may be a comma-delimited list of values). */
@XmlElement(name = "type")
String type;
public List<String> getRegistrationTypes() {
return Splitter.on(',').splitToList(type);
}
}

View file

@ -0,0 +1,23 @@
// 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 javax.xml.bind.annotation.XmlRootElement;
/**
* A registration type extension that may be present on EPP domain create commands.
*/
@XmlRootElement(name = "create")
public class RegTypeCreateExtension extends BaseRegTypeCommand {}

View file

@ -0,0 +1,27 @@
// 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.
@XmlSchema(
namespace = "urn:ietf:params:xml:ns:regtype-0.2",
xmlns = @XmlNs(prefix = "regType", namespaceURI = "urn:ietf:params:xml:ns:regtype-0.2"),
elementFormDefault = XmlNsForm.QUALIFIED)
@XmlAccessorType(XmlAccessType.FIELD)
package google.registry.model.domain.regtype;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;

View file

@ -26,6 +26,7 @@ import google.registry.model.domain.allocate.AllocateCreateExtension;
import google.registry.model.domain.fee.FeeCheckExtension; import google.registry.model.domain.fee.FeeCheckExtension;
import google.registry.model.domain.launch.LaunchCreateExtension; import google.registry.model.domain.launch.LaunchCreateExtension;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.domain.regtype.RegTypeCreateExtension;
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.eppinput.EppInput.CommandExtension; import google.registry.model.eppinput.EppInput.CommandExtension;
@ -53,7 +54,8 @@ public class ProtocolDefinition {
SECURE_DNS_1_1(SecDnsCreateExtension.class, true), SECURE_DNS_1_1(SecDnsCreateExtension.class, true),
FEE_0_6(FeeCheckExtension.class, true), FEE_0_6(FeeCheckExtension.class, true),
ALLOCATE_1_0(AllocateCreateExtension.class, false), ALLOCATE_1_0(AllocateCreateExtension.class, false),
METADATA_1_0(MetadataExtension.class, false); METADATA_1_0(MetadataExtension.class, false),
REGTYPE_0_2(RegTypeCreateExtension.class, true);
private String uri; private String uri;
private boolean visible; private boolean visible;

View file

@ -37,6 +37,7 @@ 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.RegTypeCreateExtension;
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;
@ -276,6 +277,7 @@ 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 = RegTypeCreateExtension.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

@ -1274,4 +1274,11 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistContactsAndHosts(); persistContactsAndHosts();
doSuccessfulTest(); doSuccessfulTest();
} }
@Test
public void testSuccess_regTypeExtensionValidates() throws Exception {
setEppInput("domain_create_regtype.xml");
persistContactsAndHosts();
doSuccessfulTest("tld", "domain_create_response.xml");
}
} }

View file

@ -0,0 +1,28 @@
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<create>
<domain:create
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.tld</domain:name>
<domain:period unit="y">2</domain:period>
<domain:ns>
<domain:hostObj>ns1.example.net</domain:hostObj>
<domain:hostObj>ns2.example.net</domain:hostObj>
</domain:ns>
<domain:registrant>jd1234</domain:registrant>
<domain:contact type="admin">sh8013</domain:contact>
<domain:contact type="tech">sh8013</domain:contact>
<domain:authInfo>
<domain:pw>2fooBAR</domain:pw>
</domain:authInfo>
</domain:create>
</create>
<extension>
<regType:create
xmlns:regType="urn:ietf:params:xml:ns:regtype-0.2">
<regType:type>foobar</regType:type>
</regType:create>
</extension>
<clTRID>ABC-12345</clTRID>
</command>
</epp>

View file

@ -13,6 +13,7 @@
<extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI> <extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI>
<extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI> <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
<extURI>urn:ietf:params:xml:ns:fee-0.6</extURI> <extURI>urn:ietf:params:xml:ns:fee-0.6</extURI>
<extURI>urn:ietf:params:xml:ns:regtype-0.2</extURI>
</svcExtension> </svcExtension>
</svcMenu> </svcMenu>
<dcp> <dcp>

View file

@ -13,6 +13,7 @@
<extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI> <extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI>
<extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI> <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
<extURI>urn:ietf:params:xml:ns:fee-0.6</extURI> <extURI>urn:ietf:params:xml:ns:fee-0.6</extURI>
<extURI>urn:ietf:params:xml:ns:regtype-0.2</extURI>
</svcExtension> </svcExtension>
</svcMenu> </svcMenu>
<dcp> <dcp>