diff --git a/docs/flows.md b/docs/flows.md index d69a5caa1..1330ee3c0 100644 --- a/docs/flows.md +++ b/docs/flows.md @@ -945,7 +945,6 @@ An EPP flow for login. * 2103 * Specified extension is not implemented. * 2200 - * GAE User can't access the requested registrar. * Registrar certificate does not match stored certificate. * Registrar IP address is not in stored whitelist. * Registrar certificate not present. diff --git a/java/google/registry/flows/EppConsoleAction.java b/java/google/registry/flows/EppConsoleAction.java deleted file mode 100644 index 339d8074d..000000000 --- a/java/google/registry/flows/EppConsoleAction.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 The Nomulus 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.flows; - -import com.google.appengine.api.users.UserService; -import google.registry.model.eppcommon.ProtocolDefinition; -import google.registry.request.Action; -import google.registry.request.Action.Method; -import google.registry.request.Parameter; -import google.registry.request.Payload; -import google.registry.request.auth.Auth; -import google.registry.request.auth.AuthenticatedRegistrarAccessor; -import javax.inject.Inject; -import javax.servlet.http.HttpSession; - -/** Runs EPP from the console and requires GAE user authentication. */ -@Action( - service = Action.Service.DEFAULT, - path = "/registrar-xhr", - method = Method.POST, - auth = Auth.AUTH_PUBLIC_LOGGED_IN) -public class EppConsoleAction implements Runnable { - - @Inject @Payload byte[] inputXmlBytes; - @Inject HttpSession session; - @Inject EppRequestHandler eppRequestHandler; - @Inject UserService userService; - @Inject AuthenticatedRegistrarAccessor registrarAccessor; - @Inject @Parameter("clientId") String clientId; - @Inject EppConsoleAction() {} - - @Override - public void run() { - eppRequestHandler.executeEpp( - new StatelessRequestSessionMetadata(clientId, - ProtocolDefinition.getVisibleServiceExtensionUris()), - new GaeUserCredentials(registrarAccessor), - EppRequestSource.CONSOLE, - false, // This endpoint is never a dry run. - false, // This endpoint is never a superuser. - inputXmlBytes); - } -} diff --git a/java/google/registry/flows/GaeUserCredentials.java b/java/google/registry/flows/GaeUserCredentials.java deleted file mode 100644 index 9e773e000..000000000 --- a/java/google/registry/flows/GaeUserCredentials.java +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2017 The Nomulus 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.flows; - -import static com.google.common.base.MoreObjects.toStringHelper; - -import google.registry.flows.EppException.AuthenticationErrorException; -import google.registry.model.registrar.Registrar; -import google.registry.request.auth.AuthenticatedRegistrarAccessor; -import google.registry.request.auth.AuthenticatedRegistrarAccessor.RegistrarAccessDeniedException; - -/** Credentials provided by {@link com.google.appengine.api.users.UserService}. */ -public class GaeUserCredentials implements TransportCredentials { - - private final AuthenticatedRegistrarAccessor registrarAccessor; - - public GaeUserCredentials(AuthenticatedRegistrarAccessor registrarAccessor) { - this.registrarAccessor = registrarAccessor; - } - - @Override - public void validate(Registrar registrar, String ignoredPassword) - throws AuthenticationErrorException { - try { - registrarAccessor.verifyAccess(registrar.getClientId()); - } catch (RegistrarAccessDeniedException e) { - throw new UserForbiddenException(e); - } - } - - @Override - public String toString() { - return toStringHelper(getClass()).add("user", registrarAccessor.userIdForLogging()).toString(); - } - - /** GAE User can't access the requested registrar. */ - public static class UserForbiddenException extends AuthenticationErrorException { - public UserForbiddenException(RegistrarAccessDeniedException e) { - super(e.getMessage()); - } - } -} diff --git a/java/google/registry/flows/session/LoginFlow.java b/java/google/registry/flows/session/LoginFlow.java index 78b949ad6..ea02e8438 100644 --- a/java/google/registry/flows/session/LoginFlow.java +++ b/java/google/registry/flows/session/LoginFlow.java @@ -51,7 +51,6 @@ import javax.inject.Inject; * @error {@link google.registry.flows.EppException.UnimplementedExtensionException} * @error {@link google.registry.flows.EppException.UnimplementedObjectServiceException} * @error {@link google.registry.flows.EppException.UnimplementedProtocolVersionException} - * @error {@link google.registry.flows.GaeUserCredentials.UserForbiddenException} * @error {@link google.registry.flows.TlsCredentials.BadRegistrarCertificateException} * @error {@link google.registry.flows.TlsCredentials.BadRegistrarIpAddressException} * @error {@link google.registry.flows.TlsCredentials.MissingRegistrarCertificateException} diff --git a/java/google/registry/module/frontend/FrontendRequestComponent.java b/java/google/registry/module/frontend/FrontendRequestComponent.java index 42743cb83..c8d2b1352 100644 --- a/java/google/registry/module/frontend/FrontendRequestComponent.java +++ b/java/google/registry/module/frontend/FrontendRequestComponent.java @@ -17,7 +17,6 @@ package google.registry.module.frontend; import dagger.Module; import dagger.Subcomponent; import google.registry.dns.DnsModule; -import google.registry.flows.EppConsoleAction; import google.registry.flows.EppTlsAction; import google.registry.flows.FlowComponent; import google.registry.flows.TlsCredentials.EppTlsModule; @@ -46,7 +45,6 @@ interface FrontendRequestComponent { ConsoleOteSetupAction consoleOteSetupAction(); ConsoleRegistrarCreatorAction consoleRegistrarCreatorAction(); ConsoleUiAction consoleUiAction(); - EppConsoleAction eppConsoleAction(); EppTlsAction eppTlsAction(); FlowComponent.Builder flowComponentBuilder(); OteStatusAction oteStatusAction(); diff --git a/java/google/registry/ui/js/component.js b/java/google/registry/ui/js/component.js index e0f899d06..0a03269d1 100644 --- a/java/google/registry/ui/js/component.js +++ b/java/google/registry/ui/js/component.js @@ -14,13 +14,7 @@ goog.provide('registry.Component'); -goog.require('goog.dom'); -goog.require('goog.dom.TagName'); -goog.require('goog.dom.classlist'); -goog.require('goog.events'); goog.require('goog.events.EventHandler'); -goog.require('goog.events.EventType'); -goog.require('registry.soy.forms'); goog.require('registry.util'); goog.forwardDeclare('registry.Console'); @@ -38,16 +32,9 @@ goog.forwardDeclare('registry.Console'); * ^ * \ * |-ui/js/resource_component.js - JSON resources - * | ^ - * | \ - * | |- ui/js/registrar/settings.js - * | - * |-ui/js/registrar/xml_resource_component.js - EPP resources - * ^ - * \ - * |- ui/js/registrar/contact.js - * |- ui/js/registrar/domain.js - * |- ui/js/registrar/host.js + * ^ + * \ + * |- ui/js/registrar/settings.js * * * @param {!registry.Console} cons the console singleton. @@ -91,122 +78,3 @@ goog.inherits(registry.Component, goog.events.EventHandler); registry.Component.prototype.bindToDom = function(id) { registry.util.unbutter(); }; - - -// XXX: Should clean up the many remove button handler setup funcs. -/** - * Shared functionality for contact and host add button click events - * to add form elements for inputing a new item name. Requires the - * template to have: - * - * - * - * @param {string} type e.g. 'contact', 'host'. - * @param {function(): string} newFieldNameFn generates new form field's name. - * @param {function(string): (?Element)=} opt_onAddFn currying further setup. - * @param {function()=} opt_tmpl input element template. - * @param {!Object=} opt_tmplArgs input element template parameter object. - * @param {boolean=} opt_disable optionally disable the add button. - * @protected - */ -registry.Component.prototype.addRemBtnHandlers = function( - type, - newFieldNameFn, - opt_onAddFn, - opt_tmpl, - opt_tmplArgs, - opt_disable) { - var addBtnId = 'domain-' + type + '-add-button'; - var addBtn = goog.dom.getRequiredElement(addBtnId); - if (!opt_disable) { - addBtn.removeAttribute('disabled'); - } - var addButtonClickCallback = function() { - var fieldElts = []; - var newFieldName = newFieldNameFn(); - var tmpl = - opt_tmpl ? opt_tmpl : registry.soy.forms.inputFieldRow; - var tmplArgs = opt_tmplArgs ? opt_tmplArgs : { - label: 'New ' + type, - name: newFieldName + '.value' - }; - var newFieldInputRow = registry.util.renderBeforeRow( - 'domain-' + type + 's-footer', tmpl, tmplArgs); - fieldElts.push(newFieldInputRow); - // Save the add/rem op type as a hidden elt for use by - // determine EPP add/remove semantics in subclasses. - // e.g. domain.js#saveItem() - var opElt = goog.dom.createDom(goog.dom.TagName.INPUT, { - 'type': 'hidden', - 'name': newFieldName + '.op', - 'value': 'add' - }); - newFieldInputRow.lastChild.appendChild(opElt); - if (opt_onAddFn) { - var elt = opt_onAddFn(newFieldName); - if (elt) { - fieldElts.push(elt); - } - } - this.appendRemoveBtn( - goog.dom.getLastElementChild(newFieldInputRow), - fieldElts, - goog.bind(function() { - this.typeCounts[type]--; - }, this)); - this.typeCounts[type]++; - }; - goog.events.listen(goog.dom.getRequiredElement(addBtnId), - goog.events.EventType.CLICK, - goog.bind(addButtonClickCallback, this)); -}; - - -/** - * Helper for making an element removable. - * @param {Element} parent The element to append the remove button to. - * @param {(Array.|function())=} opt_eltsToRemove - * Elements to remove when the button is clicked or Function to do - * the removing for full customization. - * @param {function()=} opt_cb callback will be called if no - * customized function is given. - */ -registry.Component.prototype.appendRemoveBtn = - function(parent, opt_eltsToRemove, opt_cb) { - var rmBtn = goog.dom.createDom(goog.dom.TagName.BUTTON, - goog.getCssName('kd-button'), - 'Remove'); - goog.dom.appendChild(parent, rmBtn); - var clickCb; - if (opt_eltsToRemove instanceof Function) { - clickCb = opt_eltsToRemove; - } else { - var eltsToRemove = opt_eltsToRemove ? opt_eltsToRemove : [parent]; - clickCb = function() { - for (var i = 0; i < eltsToRemove.length; i++) { - goog.dom.removeNode(eltsToRemove[i]); - } - if (opt_cb) { - opt_cb(); - } - }; - } - goog.events.listen(rmBtn, goog.events.EventType.CLICK, clickCb, true); -}; - - -/** - * Bind the remove button action for the given container element. - * @param {!Element} containerElt - */ -registry.Component.prototype.enableRemoveButton = function(containerElt) { - var rmBtn = goog.dom.getElementByClass( - goog.getCssName('remove'), containerElt); - goog.dom.classlist.toggle(rmBtn, goog.getCssName('hidden')); - goog.events.listen(rmBtn, goog.events.EventType.CLICK, function() { - goog.dom.removeNode(goog.dom.getParentElement(rmBtn)); - }); -}; diff --git a/java/google/registry/ui/js/console.js b/java/google/registry/ui/js/console.js index 2de59f4b6..309576b76 100644 --- a/java/google/registry/ui/js/console.js +++ b/java/google/registry/ui/js/console.js @@ -24,17 +24,15 @@ goog.require('goog.history.EventType'); goog.require('registry.util'); goog.forwardDeclare('goog.events.KeyEvent'); -goog.forwardDeclare('registry.Session'); /** * Abstract console for both admin and registrar console UIs. - * @param {?registry.Session} session server request session. * @constructor * @extends {goog.Disposable} */ -registry.Console = function(session) { +registry.Console = function() { registry.Console.base(this, 'constructor'); /** @@ -42,19 +40,37 @@ registry.Console = function(session) { * @protected */ this.history = new goog.History(); +}; +goog.inherits(registry.Console, goog.Disposable); + +/** + * Registers the console's events and sets everything up. + * + * Should be called after the constructor. + * + * The reason this isn't done in the constructor is that this is a base class + * designed to be extended. We have to wait for the actual implementation to + * finish constructing before using it. + */ +registry.Console.prototype.setUp = function() { goog.events.listen( this.history, goog.history.EventType.NAVIGATE, goog.bind(this.handleHashChange, this)); - /** - * @type {?registry.Session} The server session. - */ - this.session = session; - this.bindToDom(); + + // goog.History always starts off as "not enabled", meaning it doesn't trigger + // the listeners on change. + // + // When it's set to be enabled, it will start triggering the listeners on + // every change, but it also triggers the listeners immediately with the + // current history entry. + // + // This means the handleHashChange listener registered above will be called + // now. + this.history.setEnabled(true); }; -goog.inherits(registry.Console, goog.Disposable); /** @@ -86,6 +102,8 @@ registry.Console.prototype.handleHashChange = goog.abstractMethod; * @param {string} resourcePath Resource description path. */ registry.Console.prototype.view = function(resourcePath) { + // Setting the new history token will also trigger the handleHashChange + // listener registered in the setUp() function. this.history.setToken(resourcePath); }; diff --git a/java/google/registry/ui/js/edit_item.js b/java/google/registry/ui/js/edit_item.js index 4ee507f1b..d0e8428b7 100644 --- a/java/google/registry/ui/js/edit_item.js +++ b/java/google/registry/ui/js/edit_item.js @@ -305,9 +305,9 @@ registry.EditItem.prototype.prepareUpdate = goog.abstractMethod; /** - * Subclasses should provide a function to parse either XML or JSON response - * from server and return a result object as described below. - * @param {!Object} rsp Decoded XML/JSON response from the server. + * Subclasses should provide a function to parse JSON response from server and + * return a result object as described below. + * @param {!Object} rsp Decoded JSON response from the server. * @return {!Object} a result object describing next steps. On * success, if next is defined, visit(ret.next) is called, otherwise * if err is set, the butterbar message is set to it. diff --git a/java/google/registry/ui/js/registrar/console.js b/java/google/registry/ui/js/registrar/console.js index 6542c03ea..2da01a153 100644 --- a/java/google/registry/ui/js/registrar/console.js +++ b/java/google/registry/ui/js/registrar/console.js @@ -22,13 +22,9 @@ goog.require('goog.net.XhrIo'); goog.require('registry.Console'); goog.require('registry.Resource'); goog.require('registry.registrar.AdminSettings'); -goog.require('registry.registrar.Contact'); goog.require('registry.registrar.ContactSettings'); goog.require('registry.registrar.ContactUs'); goog.require('registry.registrar.Dashboard'); -goog.require('registry.registrar.Domain'); -goog.require('registry.registrar.EppSession'); -goog.require('registry.registrar.Host'); goog.require('registry.registrar.Resources'); goog.require('registry.registrar.SecuritySettings'); goog.require('registry.registrar.WhoisSettings'); @@ -49,16 +45,13 @@ goog.forwardDeclare('registry.Component'); * @final */ registry.registrar.Console = function(params) { + registry.registrar.Console.base(this, 'constructor'); + /** * @type {!Object} */ - // We have to define this before creating an EppSession because EppSession's - // constructor expects us to have it as an attribute. this.params = params; - registry.registrar.Console.base( - this, 'constructor', new registry.registrar.EppSession(this)); - /** * Component that's currently embedded in the page. * @type {?registry.Component} @@ -66,13 +59,9 @@ registry.registrar.Console = function(params) { */ this.component_ = null; - // XXX: This was in parent ctor but was triggering event dispatching before - // ready here. - this.history.setEnabled(true); - /** * Last active nav element. - * @type {Element} + * @type {?Element} */ this.lastActiveNavElt; @@ -107,13 +96,6 @@ registry.registrar.Console = function(params) { if (this.params.isAdmin) { this.pageMap['admin-settings'] = registry.registrar.AdminSettings; } - - // sending EPPs through the console. Currently hidden (doesn't have a "tab") - // but still accessible if the user manually puts #domain (or other) in the - // fragment - this.pageMap['contact'] = registry.registrar.Contact; - this.pageMap['domain'] = registry.registrar.Domain; - this.pageMap['host'] = registry.registrar.Host; }; goog.inherits(registry.registrar.Console, registry.Console); @@ -134,17 +116,7 @@ goog.inherits(registry.registrar.Console, registry.Console); */ registry.registrar.Console.prototype.handleHashChange = function() { var hashToken = this.history.getToken(); - // On page reloads, opening a new tab, etc. it's possible that the - // session cookie for a logged-in session exists, but the - // this.session is not yet aware, so come back here after syncing. - // - // XXX: Method should be refactored to avoid this 2-stage behavior. - if (!this.session.isEppLoggedIn()) { - this.session.login(goog.bind(this.handleHashChange, this)); - return; - } - // Otherwise, a resource operation. var parts = hashToken.split('/'); var type = ''; var id = ''; diff --git a/java/google/registry/ui/js/registrar/contact.js b/java/google/registry/ui/js/registrar/contact.js deleted file mode 100644 index 5aa9611fd..000000000 --- a/java/google/registry/ui/js/registrar/contact.js +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.provide('registry.registrar.Contact'); - -goog.require('goog.dom'); -goog.require('registry.registrar.XmlResourceComponent'); -goog.require('registry.soy.registrar.contact'); -goog.require('registry.soy.registrar.contactepp'); - -goog.forwardDeclare('registry.registrar.Console'); - - - -/** - * The `Contact` class respresents a registry contact object and - * binds UI CRUD operations to it. - * @param {!registry.registrar.Console} console the - * console singleton. - * @constructor - * @extends {registry.registrar.XmlResourceComponent} - * @final - */ -registry.registrar.Contact = function(console) { - registry.registrar.Contact.base( - this, 'constructor', - /** @type {function()} */(registry.soy.registrar.contact.item), - registry.soy.registrar.contactepp, - console); -}; -goog.inherits(registry.registrar.Contact, - registry.registrar.XmlResourceComponent); - - -/** @override */ -registry.registrar.Contact.prototype.processItem = function() { - this.model.item = this.model['epp']['response']['resData']['contact:infData']; - if (!goog.isArray(this.model.item['contact:postalInfo'])) { - this.model.item['contact:postalInfo'] = - [this.model.item['contact:postalInfo']]; - } - - // XXX: Is this code necessary? - var fixPlus = function(val) { - var str = (val || '') + ''; - if (str == '' || str.match(/\+.*/)) { - return str; - } else { - return '+' + str; - } - }; - - // Both of these are optional. - if (this.model.item['contact:voice']) { - this.model.item['contact:voice']['keyValue'] = - fixPlus(this.model.item['contact:voice']['keyValue']); - } - if (this.model.item['contact:voice']) { - this.model.item['contact:fax']['keyValue'] = - fixPlus(this.model.item['contact:fax']['keyValue']); - } -}; - - -/** @override */ -registry.registrar.Contact.prototype.setupEditor = function(objArgs) { - // For now always keep the first contact and make it i18n. Toggle button - // disables to enforce state. - // - // XXX: Should be simplified to make more modular. - var postalElt = goog.dom.getRequiredElement('contact-postalInfo'); - var addPostalInfoBtn = goog.dom.getRequiredElement( - 'domain-contact-postalInfo-add-button'); - this.typeCounts['contact-postalInfo'] = postalElt.childNodes.length; - // 4 child nodes means both addresses are present: - // 2 data tables, the footer id elt and a hidden input. - var setupRemoveBtns = this.typeCounts['contact-postalInfo'] == 4; - if (setupRemoveBtns) { - this.appendRemoveBtn(/** @type {!Element} */ (postalElt.childNodes[0])); - this.appendRemoveBtn(/** @type {!Element} */ (postalElt.childNodes[1])); - } else { - addPostalInfoBtn.removeAttribute('disabled'); - } - - this.addRemBtnHandlers( - 'contact-postalInfo', - function() { - return 'contact:postalInfo[1].contact:'; - }, - function() { - addPostalInfoBtn.setAttribute('disabled', true); - return null; - }, - /** @type {function()} */ (registry.soy.registrar.contact.postalInfo), - { - item: {}, - localized: true, - itemPrefix: 'contact:', - namePrefix: 'contact:postalInfo[1].contact:' - }, - setupRemoveBtns); -}; - - -/** @override */ -registry.registrar.Contact.prototype.prepareCreate = function(params) { - params.nextId = params.item['contact:id']; - return registry.soy.registrar.contactepp.create( - /** @type {{clTrid: ?, item: ?}} */ (params)).toString(); -}; - - -/** @override */ -registry.registrar.Contact.prototype.prepareUpdate = function(params) { - params.nextId = params.item['contact:id']; - return registry.soy.registrar.contactepp.update( - /** @type {{clTrid: ?, item: ?}} */(params)).toString(); -}; diff --git a/java/google/registry/ui/js/registrar/contact_settings.js b/java/google/registry/ui/js/registrar/contact_settings.js index 5284f6ad1..a09a85a36 100644 --- a/java/google/registry/ui/js/registrar/contact_settings.js +++ b/java/google/registry/ui/js/registrar/contact_settings.js @@ -221,7 +221,7 @@ registry.registrar.ContactSettings.prototype.prepareUpdate = * Handler for contact save that navigates to that item on success. * Does nothing on failure as UI will be left with error messages for * the user to resolve. - * @param {!Object} rsp Decoded XML/JSON response from the server. + * @param {!Object} rsp Decoded JSON response from the server. * @override */ registry.registrar.ContactSettings.prototype.handleCreateResponse = @@ -238,7 +238,7 @@ registry.registrar.ContactSettings.prototype.handleCreateResponse = * Handler for contact delete that navigates back to the collection on success. * Does nothing on failure as UI will be left with error messages for * the user to resolve. - * @param {!Object} rsp Decoded XML/JSON response from the server. + * @param {!Object} rsp Decoded JSON response from the server. * @override */ registry.registrar.ContactSettings.prototype.handleDeleteResponse = diff --git a/java/google/registry/ui/js/registrar/dashboard.js b/java/google/registry/ui/js/registrar/dashboard.js index 17ffbaad7..660a87c3a 100644 --- a/java/google/registry/ui/js/registrar/dashboard.js +++ b/java/google/registry/ui/js/registrar/dashboard.js @@ -40,10 +40,10 @@ registry.registrar.Dashboard = function(console) { /** @private {number} */ this.x_ = 0; - /** @private {Element} */ + /** @private {?Element} */ this.gear_ = null; - /** @private {goog.Timer} */ + /** @private {?goog.Timer} */ this.timer_ = null; }; goog.inherits(registry.registrar.Dashboard, registry.Component); @@ -63,14 +63,6 @@ registry.registrar.Dashboard.prototype.bindToDom = function(id) { }; -/** - * Do EPP logout. - */ -registry.registrar.Dashboard.prototype.doEppLogout = function() { - this.console.session.logout(); -}; - - /** * Let's do the twist. * @private diff --git a/java/google/registry/ui/js/registrar/domain.js b/java/google/registry/ui/js/registrar/domain.js deleted file mode 100644 index 4dc5156c8..000000000 --- a/java/google/registry/ui/js/registrar/domain.js +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.provide('registry.registrar.Domain'); - -goog.require('goog.json'); -goog.require('registry.registrar.XmlResourceComponent'); -goog.require('registry.soy.forms'); -goog.require('registry.soy.registrar.domain'); -goog.require('registry.soy.registrar.domainepp'); -goog.require('registry.util'); - -goog.forwardDeclare('registry.registrar.Console'); - - - -/** - * CRUD for EPP domain objects. - * @param {!registry.registrar.Console} console - * @constructor - * @extends {registry.registrar.XmlResourceComponent} - * @final - */ -registry.registrar.Domain = function(console) { - registry.registrar.Domain.base( - this, 'constructor', - /** @type {function()} */ (registry.soy.registrar.domain.item), - registry.soy.registrar.domainepp, - console); -}; -goog.inherits(registry.registrar.Domain, - registry.registrar.XmlResourceComponent); - - -/** @override */ -registry.registrar.Domain.prototype.newModel = function() { - var newModel = {item: {'domain:period': ''}}; - return newModel; -}; - - -/** - * Prepare a fetch query for the domain by its id. - * @param {!Object} params should have a name field with a - * possibly extended domain name id of the form "example.tld:1234" - * where the 1234 is the domain application id assigned by the - * backend flows. - * @override - */ -registry.registrar.Domain.prototype.prepareFetch = function(params) { - return registry.soy.registrar.domainepp.info( - /** @type {{clTrid: ?, id: ?}} */ (params)).toString(); -}; - - -/** @override */ -registry.registrar.Domain.prototype.processItem = function() { - this.model.item = this.model['epp']['response']['resData']['domain:infData']; - // Hoist extensions for easy soy access. - var extension = this.model['epp']['response']['extension']; - if (extension && extension['launch:infData']) { - var extendedInfData = extension['launch:infData']; - - var mark = extendedInfData['mark:mark']; - if (mark) { - this.model.item['mark:mark'] = {'keyValue': goog.json.serialize(mark)}; - } - } - - // Wrap single item into an array. - if (this.model.item['domain:ns'] && - this.model.item['domain:ns']['domain:hostObj']) { - var hostObj = this.model.item['domain:ns']['domain:hostObj']; - if (!goog.isArray(hostObj)) { - this.model.item['domain:ns']['domain:hostObj'] = [hostObj]; - } - } -}; - - -/** @override */ -registry.registrar.Domain.prototype.setupEditor = function(objArgs) { - this.typeCounts['contact'] = objArgs.item['domain:contact'] ? - objArgs.item['domain:contact'].length : 0; - - var ji = objArgs.item['domain:ns']; - this.typeCounts['host'] = - ji && ji['domain:hostObj'] ? ji['domain:hostObj'].length : 0; - - this.formInputRowRemovable( - document.querySelectorAll('input.domain-hostObj[readonly]')); - - this.formInputRowRemovable( - document.querySelectorAll('input.domain-contact[readonly]')); - - this.addRemBtnHandlers( - 'contact', - goog.bind(function() { - return 'domain:contact[' + this.typeCounts['contact'] + ']'; - }, this), - goog.bind(function(newFieldName) { - return registry.util.renderBeforeRow( - 'domain-contacts-footer', - /** @type {function()} */(registry.soy.forms.selectRow), { - label: 'Type', - name: newFieldName + '.@type', - options: ['admin', 'tech', 'billing'] - }); - }, this)); - - this.addRemBtnHandlers('host', goog.bind(function() { - return 'domain:ns.domain:hostObj[' + this.typeCounts['host'] + ']'; - }, this)); -}; - - -/** @override */ -registry.registrar.Domain.prototype.prepareCreate = function(params) { - var form = params.item; - params.nextId = form['domain:name']; - - // The presence of this field is used to signal extended template, so remove - // if not used. - if (form['smd:encodedSignedMark'] == '') { - delete form['smd:encodedSignedMark']; - } - var xml = registry.soy.registrar.domainepp.create( - /** @type {{clTrid: ?, item: ?}} */(params)); - return xml.toString(); -}; - - -/** @override */ -registry.registrar.Domain.prototype.prepareUpdate = - function(params) { - var form = params.item; - var nextId = form['domain:name']; - params.nextId = nextId; - - if (form['domain:contact']) { - this.addRem(form['domain:contact'], 'Contacts', params); - } - - if (form['domain:ns'] && form['domain:ns']['domain:hostObj']) { - this.addRem(form['domain:ns']['domain:hostObj'], 'Hosts', params); - } - - if (form['domain:ns'] && form['domain:ns']['domain:hostObj']) { - this.addRem(form['domain:ns']['domain:hostObj'], 'Hosts', params); - } - this.addRem(form['domain:contact'], 'Contacts', params); - var xml = registry.soy.registrar.domainepp.update( - /** @type {{clTrid: ?, item: ?}} */(params)); - - return xml.toString(); -}; diff --git a/java/google/registry/ui/js/registrar/epp_session.js b/java/google/registry/ui/js/registrar/epp_session.js deleted file mode 100644 index ab0c9e89e..000000000 --- a/java/google/registry/ui/js/registrar/epp_session.js +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.provide('registry.registrar.EppSession'); - -goog.require('goog.Uri'); -goog.require('registry.Session'); -goog.require('registry.soy.registrar.epp'); -goog.require('registry.util'); -goog.require('registry.xml'); - -goog.forwardDeclare('registry.registrar.Console'); - - - -/** - * Session state for console. - * @param {!registry.registrar.Console} console - * @constructor - * @extends {registry.Session} - * @final - */ -registry.registrar.EppSession = function(console) { - registry.registrar.EppSession.base( - this, 'constructor', - new goog.Uri('/registrar-xhr') - .setParameterValue('clientId', console.params.clientId), - console.params.xsrfToken, - registry.Session.ContentType.EPP); - - /** - * @type {!registry.registrar.Console} - */ - this.console = console; - - /** - * @type {!boolean} - * @private - */ - this.isEppLoggedIn_ = false; -}; -goog.inherits(registry.registrar.EppSession, registry.Session); - - -/** - * Whether the session has received an EPP success response to an EPP - * login attempt. - * @return {boolean} Whether the user is logged into an EPP session. - */ -registry.registrar.EppSession.prototype.isEppLoggedIn = function() { - return this.isEppLoggedIn_; -}; - - -/** - * Get the clientId if the user is logged in, or throw Error. - * @throws Error if the user is not logged in. - * @return {string} the clientId. - */ -registry.registrar.EppSession.prototype.getClientId = function() { - return this.console.params.clientId; -}; - - -/** - * Login or display butterbar info about error. - * @param {function()} successCb to be called on success. - */ -registry.registrar.EppSession.prototype.login = function(successCb) { - var eppArgs = {clId: this.console.params.clientId, clTrid: 'asdf-1235'}; - this.send( - registry.soy.registrar.epp.login(eppArgs).getContent(), - goog.bind(function(xml) { - var result = xml['epp']['response']['result']; - var eppCode = result['@code']; - if (eppCode == '1000' || eppCode == '2002') { - // Success || Already logged in. - this.isEppLoggedIn_ = true; - successCb(); - } else { - // Failure. - this.isEppLoggedIn_ = false; - registry.util.butter('login error: ' + eppCode); - } - }, this)); -}; - - -/** - * Logout or display butterbar info about error. - */ -registry.registrar.EppSession.prototype.logout = function() { - this.send( - registry.soy.registrar.epp.logout( - {clTrid: 'asdf-1235'}).getContent(), - goog.bind(function(xml) { - var result = xml['epp']['response']['result']; - var eppCode = result['@code']; - registry.util.butter( - 'logout ' + eppCode + ': ' + result['msg']['keyValue']); - // Going to be safe here and force a login either way. - this.isEppLoggedIn_ = false; - }, this)); -}; - - -/** - * Send xml to the server. - * @param {string} xml Request document. - * @param {function(!Object)} callback For XhrIo result throws. - */ -registry.registrar.EppSession.prototype.send = function(xml, callback) { - var toXmlJsonCb = function(rspXml) { - callback(registry.xml.convertToJson(rspXml)); - }; - this.sendXhrIo(xml, toXmlJsonCb); -}; diff --git a/java/google/registry/ui/js/registrar/host.js b/java/google/registry/ui/js/registrar/host.js deleted file mode 100644 index 45bd03f43..000000000 --- a/java/google/registry/ui/js/registrar/host.js +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.provide('registry.registrar.Host'); - -goog.require('registry.registrar.XmlResourceComponent'); -goog.require('registry.soy.registrar.host'); -goog.require('registry.soy.registrar.hostepp'); - -goog.forwardDeclare('registry.registrar.Console'); - - - -/** - * CRUD for EPP host objects. - * @param {!registry.registrar.Console} console - * @constructor - * @extends {registry.registrar.XmlResourceComponent} - * @final - */ -registry.registrar.Host = function(console) { - registry.registrar.Host.base( - this, 'constructor', - registry.soy.registrar.host.item, - registry.soy.registrar.hostepp, - console); -}; -goog.inherits(registry.registrar.Host, - registry.registrar.XmlResourceComponent); - - -/** @override */ -registry.registrar.Host.prototype.processItem = function() { - this.model.item = this.model['epp']['response']['resData']['host:infData']; - if (this.model.item['host:addr']) { - if (!goog.isArray(this.model.item['host:addr'])) { - this.model.item['host:addr'] = [this.model.item['host:addr']]; - } - } else { - this.model.item['host:addr'] = []; - } -}; - - -/** @override */ -registry.registrar.Host.prototype.setupEditor = function(objArgs) { - this.typeCounts['host-addr'] = - objArgs.item['host:addr'] ? objArgs.item['host:addr'].length : 0; - this.addRemBtnHandlers('host-addr', goog.bind(function() { - return 'host:addr[' + this.typeCounts['host-addr'] + ']'; - }, this)); - - this.formInputRowRemovable(document.querySelectorAll('input[readonly]')); -}; - - -/** @override */ -registry.registrar.Host.prototype.prepareCreate = function(params) { - params.nextId = params.item['host:name']; - return registry.soy.registrar.hostepp.create( - /** @type {{clTrid: ?, item: ?}} */(params)).toString(); -}; - - -/** @override */ -registry.registrar.Host.prototype.prepareUpdate = function(params) { - var form = params.item; - var addAddrs = []; - var remAddrs = []; - if (form['host:addr']) { - var oldAddrs = form['host:oldAddr'] || []; - var newAddrs = form['host:addr']; - var length = Math.max(oldAddrs.length, newAddrs.length); - for (var i = 0; i < length; i++) { - if (i >= oldAddrs.length) { - addAddrs.push(newAddrs[i]['value']); - } else if (i >= newAddrs.length) { - remAddrs.push(oldAddrs[i]['value']); - } else { - if (newAddrs[i]['value'] == oldAddrs[i]['value']) { - // Do nothing. - } else if (newAddrs[i]['value'] == '') { - remAddrs.push(oldAddrs[i]['value']); - } else { - remAddrs.push(oldAddrs[i]['value']); - addAddrs.push(newAddrs[i]['value']); - } - } - } - } - params.addAddrs = addAddrs; - params.remAddrs = remAddrs; - params.nextId = form['host:chgName']; - return registry.soy.registrar.hostepp.update( - /** @type {{clTrid: ?, item: ?}} */(params)).toString(); -}; diff --git a/java/google/registry/ui/js/registrar/main.js b/java/google/registry/ui/js/registrar/main.js index 1a8ad1df4..1bfbd7030 100644 --- a/java/google/registry/ui/js/registrar/main.js +++ b/java/google/registry/ui/js/registrar/main.js @@ -38,11 +38,10 @@ goog.require('registry.registrar.Console'); * @param {string} technicalDocsUrl * @export */ -registry.registrar.main = function(xsrfToken, clientId, isAdmin, isOwner, - productName, integrationEmail, supportEmail, - announcementsEmail, supportPhoneNumber, - technicalDocsUrl) { - new registry.registrar.Console({ +registry.registrar.main = function( + xsrfToken, clientId, isAdmin, isOwner, productName, integrationEmail, + supportEmail, announcementsEmail, supportPhoneNumber, technicalDocsUrl) { + const console = new registry.registrar.Console({ xsrfToken: xsrfToken, clientId: clientId, isAdmin: isAdmin, @@ -54,4 +53,6 @@ registry.registrar.main = function(xsrfToken, clientId, isAdmin, isOwner, supportPhoneNumber: supportPhoneNumber, technicalDocsUrl: technicalDocsUrl }); + + console.setUp(); }; diff --git a/java/google/registry/ui/js/registrar/xml_resource_component.js b/java/google/registry/ui/js/registrar/xml_resource_component.js deleted file mode 100644 index 2f736bc08..000000000 --- a/java/google/registry/ui/js/registrar/xml_resource_component.js +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.provide('registry.registrar.XmlResourceComponent'); - -goog.require('goog.dom'); -goog.require('goog.dom.TagName'); -goog.require('goog.dom.classlist'); -goog.require('registry.EditItem'); -goog.require('registry.util'); - -goog.forwardDeclare('registry.registrar.Console'); - - - -/** - * The ResourceComponent class respresents server state for a named - * resource and binds UI CRUD operations on it, or its constituent - * collection. - * @param {function()} itemTmpl - * @param {!Object} eppTmpls Epp xml templates for info requests. - * @param {!registry.registrar.Console} console - * @constructor - * @extends {registry.EditItem} - */ -registry.registrar.XmlResourceComponent = function( - itemTmpl, eppTmpls, console) { - registry.registrar.XmlResourceComponent.base( - this, 'constructor', console, itemTmpl, console.params.isOwner); - - /** @type {!Object} */ - this.eppTmpls = eppTmpls; -}; -goog.inherits(registry.registrar.XmlResourceComponent, registry.EditItem); - - -/** @override */ -registry.registrar.XmlResourceComponent.prototype.bindToDom = - function(id) { - // XXX: EPP resources still use null state. - registry.registrar.XmlResourceComponent.base( - this, 'bindToDom', (id || '')); - if (id) { - this.fetchItem(id); - } else { - // Start edit of empty object. - this.edit(); - } -}; - - -/** @override */ -registry.registrar.XmlResourceComponent.prototype.fetchItem = function(id) { - var queryParams = {id: id, clTrid: 'abc-1234'}; - var xml = this.prepareFetch(queryParams); - this.console.session.send(xml, goog.bind(this.handleFetchItem, this, id)); -}; - - -/** @override */ -registry.registrar.XmlResourceComponent.prototype.handleFetchItem = - function(id, rsp) { - this.model = rsp; - var result = rsp['epp']['response']['result']; - var resCode = result['@code']; - // XXX: Should use enum. - if (resCode == 1000) { // OK - this.model.readonly = true; - this.processItem(); - this.renderItem(this.model); - } else if (resCode == 2303) { // Missing - registry.util.butter( - 'Could not find: "' + id + '". Please enter as "type/id"'); - } else { - // includes general failure. - registry.util.butter(resCode + ':' + result['msg']['keyValue']); - } -}; - - -/** - * Sublcasses should override to populate create queryParams with form - * fields as needed. `queryParams.nextId` MUST be set to the - * new object's ID. - * @param {!Object} queryParams - */ -registry.registrar.XmlResourceComponent.prototype.prepareCreate = - goog.abstractMethod; - - -/** - * Calls prepareCreate with template params and then send the returned - * XML to the server - * @override - */ -registry.registrar.XmlResourceComponent.prototype.sendCreate = function() { - var form = registry.util.parseForm('item'); - var queryParams = {item: form, clTrid: 'abc-1234'}; - var xml = this.prepareCreate(queryParams); - this.nextId = queryParams.nextId; - this.console.session.send(xml, goog.bind(this.handleUpdateResponse, this)); -}; - - -/** - * Calls prepareUpdate with template params and then send the returned - * XML to the server. - * @override - */ -registry.registrar.XmlResourceComponent.prototype.sendUpdate = function() { - var form = registry.util.parseForm('item'); - var queryParams = {item: form, clTrid: 'abc-1234'}; - var xml = this.prepareUpdate(queryParams); - this.nextId = queryParams.nextId; - this.console.session.send(xml, goog.bind(this.handleUpdateResponse, this)); -}; - - -/** - * Sublcasses should override to populate fetch queryParams with form - * fields as needed. - * @param {!Object} queryParams - * @return {string} EPP xml string - */ -registry.registrar.XmlResourceComponent.prototype.prepareFetch = - function(queryParams) { - return this.eppTmpls.info(queryParams).toString(); -}; - - -/** @override */ -registry.registrar.XmlResourceComponent.prototype.handleUpdateResponse = - function(rsp) { - var result = rsp['epp']['response']['result']; - if (result['@code'] == 1000) { - // XXX: Consider timer, probably just as a seconds arg with impl in butter. - registry.util.butter('Saved.'); - this.fetchItem(this.nextId || ''); - this.nextId = null; - this.toggleEdit(); - } else { - registry.util.butter(result['msg']['keyValue']); - } - return rsp; -}; - - -/** - * Helper to add add/remove hosts/contacts on queryParams: - * - * queryParams[op + fieldType] = formFields. - * - * @param {Array.} formFields named form item representations - * that have an associated {op: (add|rem)} attribute. - * @param {string} fieldType capitalized pluralized type name, e.g. "Contacts". - * @param {!Object} queryParams - */ -registry.registrar.XmlResourceComponent.prototype.addRem = - function(formFields, fieldType, queryParams) { - var add = []; - var rem = []; - for (var i = 0; i < formFields.length; i++) { - var formField = formFields[i]; - var op = formField['op']; - switch (op) { - case 'add': - add.push(formField); - break; - case 'rem': - rem.push(formField); - break; - default: - registry.util.log( - 'Unknown op attribute ' + op + ' on form field:', - formField); - } - } - if (add.length > 0) { - queryParams['add' + fieldType] = add; - } - if (rem.length > 0) { - queryParams['rem' + fieldType] = rem; - } -}; - - -/** - * Make the given form input rows removable. - * @param {NodeList} elts array of input elements. - * @param {function()=} opt_onclickCb called when remove button is clicked. - */ -registry.registrar.XmlResourceComponent.prototype.formInputRowRemovable = - function(elts, opt_onclickCb) { - for (var i = 0; i < elts.length; i++) { - var parent = goog.dom.getParentElement(elts[i]); - this.appendRemoveBtn(parent, goog.partial(function(elt) { - var eppRemInput = goog.dom.createDom(goog.dom.TagName.INPUT, { - 'name': elt.name.replace(/\.value/, '.op'), - 'value': 'rem', - 'type': 'hidden' - }); - goog.dom.appendChild(goog.dom.getParentElement(elt), eppRemInput); - goog.dom.classlist.add( - goog.dom.getParentElement( - goog.dom.getParentElement(elt)), goog.getCssName('hidden')); - }, elts[i])); - } -}; diff --git a/java/google/registry/ui/js/resource.js b/java/google/registry/ui/js/resource.js index 5209672e2..8dd040a98 100644 --- a/java/google/registry/ui/js/resource.js +++ b/java/google/registry/ui/js/resource.js @@ -31,8 +31,7 @@ goog.forwardDeclare('goog.Uri'); * @constructor */ registry.Resource = function(baseUri, id, xsrfToken) { - registry.Resource.base(this, 'constructor', baseUri, xsrfToken, - registry.Session.ContentType.JSON); + registry.Resource.base(this, 'constructor', baseUri, xsrfToken); /** @const @private {string} the ID of the target resource. */ this.id_ = id; }; diff --git a/java/google/registry/ui/js/session.js b/java/google/registry/ui/js/session.js index 5aa47c1a7..2fee38028 100644 --- a/java/google/registry/ui/js/session.js +++ b/java/google/registry/ui/js/session.js @@ -23,14 +23,13 @@ goog.forwardDeclare('goog.Uri'); /** - * XHR launcher for both JSON and XML requests. + * XHR launcher for JSON requests. * @param {!goog.Uri} defaultUri URI to which requests are POSTed. * @param {string} xsrfToken Cross-site request forgery protection token. - * @param {!registry.Session.ContentType} contentType Payload mode. * @constructor * @template REQUEST, RESPONSE */ -registry.Session = function(defaultUri, xsrfToken, contentType) { +registry.Session = function(defaultUri, xsrfToken) { /** * URI to which requests are posted. @@ -39,36 +38,19 @@ registry.Session = function(defaultUri, xsrfToken, contentType) { */ this.uri = defaultUri; - /** - * Content type set in request body. - * @private {!registry.Session.ContentType} - * @const - */ - this.contentType_ = contentType; - /** * XHR request headers. * @private {!Object} * @const */ this.headers_ = { - 'Content-Type': contentType, + 'Content-Type': 'application/json; charset=utf-8', 'X-CSRF-Token': xsrfToken, 'X-Requested-With': 'XMLHttpRequest' }; }; -/** - * Payload modes supported by this class. - * @enum {string} - */ -registry.Session.ContentType = { - JSON: 'application/json; charset=utf-8', - EPP: 'application/epp+xml' -}; - - /** * Abstract method to send a request to the server. * @param {REQUEST} body HTTP request body as a string or JSON object. @@ -99,9 +81,7 @@ registry.Session.prototype.sendXhrIo = registry.Session.prototype.onXhrComplete_ = function(onSuccess, onError, e) { if (e.target.isSuccess()) { onSuccess(/** @type {!RESPONSE} */ ( - this.contentType_ == registry.Session.ContentType.JSON ? - e.target.getResponseJson(registry.Session.PARSER_BREAKER_) : - e.target.getResponseXml())); + e.target.getResponseJson(registry.Session.PARSER_BREAKER_))); } else { onError(e.target.getLastError()); } diff --git a/java/google/registry/ui/js/xml.js b/java/google/registry/ui/js/xml.js deleted file mode 100644 index fba15bdbc..000000000 --- a/java/google/registry/ui/js/xml.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.provide('registry.xml'); -goog.provide('registry.xml.XmlJson'); - -goog.require('goog.dom.NodeType'); -goog.require('goog.object'); - - -/** - * Turns XML document into a JSON data structure. This function is similar to - * Mozilla JXON - * except it handles text differently. This routine will not coalesce text - * interspersed with elements. This routine does not coerce string types to - * number, boolean, or null. - * @param {!Node} node - * @return {!Object} - * @throws {Error} upon encountering interspersed text. - */ -registry.xml.convertToJson = function(node) { - var result = goog.object.create(); - if (goog.isDefAndNotNull(node.attributes)) { - for (var i = 0; i < node.attributes.length; i++) { - var attr = node.attributes.item(i); - goog.object.set(result, '@' + attr.name, attr.value || ''); - } - } - for (var j = 0; j < node.childNodes.length; j++) { - var child = node.childNodes.item(j); - switch (child.nodeType) { - case goog.dom.NodeType.TEXT: - case goog.dom.NodeType.CDATA_SECTION: - var text = String(child.nodeValue).trim(); - if (text != '') { - var curr = goog.object.get(result, registry.xml.jsonValueFieldName_); - if (goog.isDef(curr)) { - throw new Error( - 'XML text "' + curr + '" interspersed with "' + text + '"'); - } - goog.object.set(result, registry.xml.jsonValueFieldName_, text); - } - break; - case goog.dom.NodeType.ELEMENT: - var json = registry.xml.convertToJson(child); - var name = child.nodeName; - if (goog.object.containsKey(result, name)) { - var field = goog.object.get(result, name); - if (goog.isArray(field)) { - field.push(json); - } else { - goog.object.set(result, name, [field, json]); - } - } else { - goog.object.set(result, name, json); - } - break; - } - } - return result; -}; - - -/** - * XML JSON object recursive type definition. - * @typedef {(string| - * !Array| - * !Object)} - */ -registry.xml.XmlJson; - - -/** - * XML JSON value field name, inherited from JXON. - * @private {string} - * @const - */ -registry.xml.jsonValueFieldName_ = 'keyValue'; diff --git a/java/google/registry/ui/soy/registrar/Contact.soy b/java/google/registry/ui/soy/registrar/Contact.soy deleted file mode 100644 index 32b8262af..000000000 --- a/java/google/registry/ui/soy/registrar/Contact.soy +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -{namespace registry.soy.registrar.contact} - - -/** - * Set view for contacts. - */ -{template .set} -
-

Please enter a query for a single contact in the form "contact/[contact id]". -

-{/template} - - -/** - * Item view for contact. - */ -{template .item} - {@param? item: ?} - {@param? readonly: ?} /** passed through to field rendering. */ -
-

- {if isNonnull($item['contact:id'])} - {$item['contact:id']['keyValue']} - {else} - New Contact - {/if} -

- - - - - {if not isNonnull($item['contact:id'])} - {call registry.soy.forms.inputFieldRow data="all"} - {param label: 'Contact ID *' /} - {param name: 'contact:id' /} - {/call} - {/if} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Password *' /} - {param name: 'contact:authInfo.contact:pw' /} - {param value: isNonnull($item['contact:authInfo']) ? - $item['contact:authInfo']['contact:pw'] : '' /} - {/call} - - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Email *' /} - {param name: 'contact:email' /} - {param value: $item['contact:email'] /} - {/call} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Phone' /} - {param name: 'contact:voice' /} - {param value: $item['contact:voice'] /} - {param placeholder: 'e.g. +1.6508675309' /} - {/call} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Fax' /} - {param name: 'contact:fax' /} - {param value: $item['contact:fax'] /} - {param placeholder: 'e.g. +1.2125552638' /} - {/call} - - - - - - -

Authentication

Contacts

-

Postal address(es)

- -
-
- {if isNonnull($item['contact:postalInfo'])} - {for $pi in $item['contact:postalInfo']} - {call .postalInfo data="all"} - {param localized: index($pi) == 1 /} - {param item: $pi/} - {param namePrefix: 'contact:postalInfo[' + index($pi) + '].contact:' /} - {/call} - {/for} - {else} - {call .postalInfo data="all"} - {param namePrefix: 'contact:postalInfo[0].contact:' /} - {/call} - {/if} - -
-
- {if isNonnull($item['contact:id'])} - - {/if} -
-{/template} - - -/** - * Postal info. - */ -{template .postalInfo} - {@param item: ?} - {@param namePrefix: ?} - {@param? localized: ?} /** if true, this is the second, localized postalInfo. */ - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Name *' /} - {param name: 'name' /} - {param value: $item['contact:name']/} - {/call} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Organization' /} - {param name: 'org' /} - {param value: $item['contact:org'] /} - {/call} - {call registry.soy.forms.textareaFieldRowWithValue data="all"} - {param label: 'Street' /} - {param name: 'street' /} - {param namePrefix: $namePrefix + 'addr.contact:' /} - {param value: isNonnull($item['contact:addr']) ? $item['contact:addr']['contact:street'] : '' /} - {/call} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'City *' /} - {param name: 'city' /} - {param namePrefix: $namePrefix + 'addr.contact:' /} - {param value: isNonnull($item['contact:addr']) ? $item['contact:addr']['contact:city'] : '' /} - {/call} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'State / Region' /} - {param name: 'sp' /} - {param namePrefix: $namePrefix + 'addr.contact:' /} - {param value: isNonnull($item['contact:addr']) ? $item['contact:addr']['contact:sp'] : '' /} - {param placeholder: 'e.g. CA' /} - {/call} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Zip / Postal code' /} - {param name: 'pc' /} - {param namePrefix: $namePrefix + 'addr.contact:' /} - {param value: isNonnull($item['contact:addr']) ? $item['contact:addr']['contact:pc'] : '' /} - {param placeholder: 'e.g. 10282' /} - {/call} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Country code *' /} - {param name: 'cc' /} - {param namePrefix: $namePrefix + 'addr.contact:' /} - {param value: isNonnull($item['contact:addr']) ? $item['contact:addr']['contact:cc'] : '' /} - {param placeholder: 'e.g. US' /} - {/call} -
- {if $localized} - Localized address
- Full UTF-8 charsets allowed - {else} - Internationalized address
- Only 7-bit ASCII allowed - {/if} -
-{/template} diff --git a/java/google/registry/ui/soy/registrar/ContactEpp.soy b/java/google/registry/ui/soy/registrar/ContactEpp.soy deleted file mode 100644 index 181c59d0e..000000000 --- a/java/google/registry/ui/soy/registrar/ContactEpp.soy +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -{namespace registry.soy.registrar.contactepp} - - -/* XXX: Forces first postalInfo type to be "int" and second "loc" if it is - * present, for compatibility with the server. */ -/** - * Contact create request. - */ -{template .create stricthtml="false"} - {@param item: ?} - {@param clTrid: ?} - - - - - {$item['contact:id']} - {for $pi in $item['contact:postalInfo']} - - {$pi['contact:name']} - {$pi['contact:org']} - - {let $addr: $pi['contact:addr'] /} - {$addr['contact:street']} - {$addr['contact:city']} - {$addr['contact:sp']} - {$addr['contact:pc']} - {$addr['contact:cc']} - - - {/for} - {$item['contact:voice']} - {$item['contact:fax']} - {$item['contact:email']} - - {$item['contact:authInfo']['contact:pw']} - - - - {$clTrid} - - -{/template} - - -/* XXX: Forces first postalInfo type to be "int" and second "loc" if it is - * present, for compatibility with the server. */ -/** - * Contact update request. - */ -{template .update stricthtml="false"} - {@param item: ?} - {@param clTrid: ?} - - - - - {$item['contact:id']} - - {for $pi in $item['contact:postalInfo']} - - {$pi['contact:name']} - {$pi['contact:org']} - {let $addr: $pi['contact:addr'] /} - - {$addr['contact:street']} - {$addr['contact:city']} - {$addr['contact:sp']} - {$addr['contact:pc']} - {$addr['contact:cc']} - - - {/for} - {$item['contact:voice']} - {$item['contact:fax']} - {$item['contact:email']} - - {$item['contact:authInfo']['contact:pw']} - - - - - {$clTrid} - - -{/template} - - -/** - * Contact info request. - */ -{template .info stricthtml="false"} - {@param id: ?} - {@param clTrid: ?} - - - - - {$id} - - - {$clTrid} - - -{/template} diff --git a/java/google/registry/ui/soy/registrar/Domain.soy b/java/google/registry/ui/soy/registrar/Domain.soy deleted file mode 100644 index 3a3b2b065..000000000 --- a/java/google/registry/ui/soy/registrar/Domain.soy +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -{namespace registry.soy.registrar.domain} - - -/** - * Set view for domains. - */ -{template .set} -
-

Please enter a query for a single contact in the form "domain/[domain id]". -

-{/template} - - -/** - * Item view for domain. - */ -{template .item} - {@param item: ?} - {@param? readonly: ?} /** passed through to field rendering. */ - {let $isEdit: isNonnull($item['domain:name']) /} -
-

- {if $isEdit} - {$item['domain:name']['keyValue']} - {else} - New Domain - {/if} -

- - {if not $isEdit} - - - - {call registry.soy.forms.inputFieldRow data="all"} - {param label: 'Domain name *' /} - {param name: 'domain:name' /} - {/call} - {call registry.soy.forms.inputFieldRow data="all"} - {param label: 'Period (in years) *' /} - {param name: 'domain:period' /} - {/call} - {/if} - {if isNonnull($item['domain:exDate'])} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Expiration date' /} - {param name: 'domain:exDate' /} - {param value: $item['domain:exDate'] /} - {/call} - {/if} - - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Password *' /} - {param name: 'domain:authInfo.domain:pw' /} - {param value: isNonnull($item['domain:authInfo']) ? - $item['domain:authInfo']['domain:pw'] : '' /} - {/call} - - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Registrant *' /} - {param name: 'domain:registrant' /} - {param value: $item['domain:registrant'] /} - {/call} - {if isNonnull($item['domain:contact'])} - // Render contact list with stable ordering for the screenshot tests. - {call .showContact_ data="all"} - {param contacts: $item['domain:contact'] /} - {param type: 'admin' /} - {/call} - {call .showContact_ data="all"} - {param contacts: $item['domain:contact'] /} - {param type: 'billing' /} - {/call} - {call .showContact_ data="all"} - {param contacts: $item['domain:contact'] /} - {param type: 'tech' /} - {/call} - {/if} - - - - - {if isNonnull($item['domain:ns']) and isNonnull($item['domain:ns']['domain:hostObj'])} - {for $hostObj in $item['domain:ns']['domain:hostObj']} - {let $hostIdx: index($hostObj) /} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Host ' + $hostIdx /} - {param name: 'domain:ns.domain:hostObj[' + $hostIdx + '].value' /} - {param value: $hostObj /} - {param clazz kind="text"}{css('domain-hostObj')}{/param} - {/call} - {/for} - {/if} - - - {if isNonnull($item['mark:mark'])} - - - - {/if} -

Domain

Authentication

-

Contact information

- -
-

Nameservers

- -
Mark Data - - -
- {if $isEdit} - - {/if} -
-{/template} - - -/** Renders an input form row for a specific type of contact. */ -{template .showContact_ visibility="private"} - {@param contacts: list>} /** List of EPP domain:contacts. */ - {@param type: string} /** Type of contact (e.g. admin, tech) */ - {for $contact in $contacts} - {if $type == $contact['@type']} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: $contact['@type'] + ' contact' /} - {param name: 'domain:contact[' + index($contact) + '].value' /} - {param value: $contact /} - {param clazz: 'domain-contact' /} - {/call} - - {/if} - {/for} -{/template} - - -/* XXX: Should change support for admin/tech. */ -/** - * Update domain. - */ -{template .update} - {@param? item: ?} -
-

{$item['domain:name']['keyValue']}

- - - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Registrant' /} - {param name: 'domain:registrant' /} - {param value: $item['domain:registrant'] /} - {/call} - - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Password' /} - {param name: 'domain:authInfo.domain:pw' /} - {param value: isNonnull($item['domain:authInfo']) ? - $item['domain:authInfo']['domain:pw'] : '' /} - {/call} - -

Contact

Authentication

-
-{/template} diff --git a/java/google/registry/ui/soy/registrar/DomainEpp.soy b/java/google/registry/ui/soy/registrar/DomainEpp.soy deleted file mode 100644 index 8981d4fad..000000000 --- a/java/google/registry/ui/soy/registrar/DomainEpp.soy +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -{namespace registry.soy.registrar.domainepp} - - -/* General Availability. */ -/** - * Domain create request. - */ -{template .create stricthtml="false"} - {@param item: ?} - {@param clTrid: ?} - - - - - {$item['domain:name']} - {if isNonnull($item['domain:period'])} - {$item['domain:period']} - {/if} - {if isNonnull($item['domain:ns'])} - - {for $hostObj in $item['domain:ns']['domain:hostObj']} - {$hostObj.value} - {/for} - - {/if} - {if isNonnull($item['domain:registrant'])} - {$item['domain:registrant']} - {/if} - {if isNonnull($item['domain:contact'])} - {for $contact in $item['domain:contact']} - {$contact.value} - {/for} - {/if} - - {$item['domain:authInfo']['domain:pw']} - - - - {$clTrid} - - -{/template} - - -/** - * Domain info request. - */ -{template .info stricthtml="false"} - {@param id: ?} - {@param clTrid: ?} - - - - - {$id} - - - {$clTrid} - - -{/template} - - -/** - * Domain update request. - */ -{template .update stricthtml="false"} - {@param item: ?} - {@param clTrid: ?} - {@param? addHosts: ?} /** list of hostObj to add. */ - {@param? remHosts: ?} /** list of hostObj to remove. */ - {@param? addContacts: ?} /** list of contact to add. */ - {@param? remContacts: ?} /** list of contact to remove. */ - - - - - {$item['domain:name']} - {if isNonnull($addHosts) or isNonnull($addContacts)} - {call .addRem} - {param isAdd: true /} - {param hosts: $addHosts /} - {param contacts: $addContacts /} - {/call} - {/if} - {if isNonnull($remHosts) or isNonnull($remContacts)} - {call .addRem} - {param isAdd: false /} - {param hosts: $remHosts /} - {param contacts: $remContacts /} - {/call} - {/if} - - {$item['domain:registrant']} - - {$item['domain:authInfo']['domain:pw']} - - - - - {$clTrid} - - -{/template} - - -{template .addRem} - {@param isAdd: ?} - {@param? hosts: ?} - {@param? contacts: ?} -{let $tagName: $isAdd ? 'domain:add' : 'domain:rem' /} -<{$tagName}> - {if isNonnull($hosts)} - - {for $host in $hosts} - {$host.value} - {/for} - - {/if} - {if isNonnull($contacts)} - {for $contact in $contacts} - {$contact.value} - {/for} - {/if} - -{/template} diff --git a/java/google/registry/ui/soy/registrar/Epp.soy b/java/google/registry/ui/soy/registrar/Epp.soy deleted file mode 100644 index d299ef927..000000000 --- a/java/google/registry/ui/soy/registrar/Epp.soy +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -{namespace registry.soy.registrar.epp} - - -/** - * Login request. - * @param clId - * @param pw - * @param clTrid - */ -{template .login stricthtml="false"} - - - - {$clId} - {$pw} - - 1.0 - en - - - urn:ietf:params:xml:ns:host-1.0 - urn:ietf:params:xml:ns:domain-1.0 - urn:ietf:params:xml:ns:contact-1.0 - - - {$clTrid} - - -{/template} - - -/** - * Logout request. - * @param clTrid - */ -{template .logout stricthtml="false"} - - - - {$clTrid} - - -{/template} diff --git a/java/google/registry/ui/soy/registrar/Host.soy b/java/google/registry/ui/soy/registrar/Host.soy deleted file mode 100644 index 97f22231f..000000000 --- a/java/google/registry/ui/soy/registrar/Host.soy +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -{namespace registry.soy.registrar.host} - - -/** - * Set view for hosts. - */ -{template .set} -
-

Please enter a query for a single host in the form "host/[hostname]". -

-{/template} - - -/** - * Item view for host. - * @param? item - * @param? readonly passed through to field rendering. - */ -{template .item} -
-

- {if isNonnull($item['host:name'])} - {$item['host:name']['keyValue']} - {else} - New Host - {/if} -

- - - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Name *' /} - {param name: isNonnull($item['host:name']) ? 'host:chgName' : 'host:name' /} - {param value: $item['host:name'] /} - {/call} - - - - {if isNonnull($item['host:addr'])} - {for $addr in $item['host:addr']} - {if not $readonly} - - {/if} - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Address No. ' + (index($addr) + 1) /} - {param name: 'host:addr[' + index($addr) + '].value' /} - {param value: $item['host:addr'][index($addr)] /} - {/call} - {/for} - {/if} - -

Host

-

Addresses

- -
- {if isNonnull($item['host:name'])} - - {/if} -
-{/template} - - -/** - * Item view for host. - * @param? item - * @param? readonly passed through to field rendering. - */ -{template .update} -
-

{$item['host:name']['keyValue']}

- - - - - {call registry.soy.forms.inputFieldRowWithValue data="all"} - {param label: 'Name' /} - {param name: 'host:chgName' /} - {param value: $item['host:name'] /} - {/call} -

Host

- {if isNonnull($item['host:name'])} - - {/if} -
-{/template} diff --git a/java/google/registry/ui/soy/registrar/HostEpp.soy b/java/google/registry/ui/soy/registrar/HostEpp.soy deleted file mode 100644 index 902882963..000000000 --- a/java/google/registry/ui/soy/registrar/HostEpp.soy +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -{namespace registry.soy.registrar.hostepp} - - -/** - * Host create request. - */ -{template .create stricthtml="false"} - {@param item: ?} - {@param clTrid: ?} - - - - - {$item['host:name']} - {if isNonnull($item['host:addr'])} - {for $addr in $item['host:addr']} - {let $type: strContains($addr['value'], ':') ? 'v6' : 'v4' /} - {$addr['value']} - {/for} - {/if} - - - {$clTrid} - - -{/template} - - -/** - * Host update request. - */ -{template .update stricthtml="false"} - {@param item: ?} - {@param clTrid: ?} - {@param? addAddrs: ?} /** list of addrs to add. */ - {@param? remAddrs: ?} /** list of addrs to remove. */ - - - - - {$item['host:name']} - {call .addRem} - {param isAdd: true /} - {param addrs: $addAddrs /} - {/call} - {call .addRem} - {param isAdd: false /} - {param addrs: $remAddrs /} - {/call} - {if $item['host:name'] != $item['host:chgName']} - - {$item['host:chgName']} - - {/if} - - - {$clTrid} - - -{/template} - - -/** - * Host info request. - */ -{template .info stricthtml="false"} - {@param clTrid: ?} - {@param id: ?} /** The hostname (named "id" to preserve component API). */ - - - - - {$id} - - - {$clTrid} - - -{/template} - - -{template .addRem} - {@param isAdd: ?} - {@param? addrs: ?} - {let $tagName: $isAdd ? 'host:add' : 'host:rem' /} - {if length($addrs) > 0} - <{$tagName}> - {for $addr in $addrs} - {let $type: strContains($addr, ':') ? 'v6' : 'v4' /} - {$addr} - {/for} - - {/if} -{/template} diff --git a/javatests/google/registry/flows/EppConsoleActionTest.java b/javatests/google/registry/flows/EppConsoleActionTest.java deleted file mode 100644 index 1ff177eb3..000000000 --- a/javatests/google/registry/flows/EppConsoleActionTest.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2017 The Nomulus 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.flows; - -import static com.google.appengine.api.users.UserServiceFactory.getUserService; -import static com.google.common.truth.Truth.assertThat; -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import com.google.common.collect.ImmutableSetMultimap; -import google.registry.request.auth.AuthenticatedRegistrarAccessor; -import google.registry.testing.AppEngineRule; -import google.registry.testing.FakeHttpSession; -import google.registry.testing.ShardableTestCase; -import google.registry.testing.UserInfo; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.ArgumentCaptor; - -/** Tests for {@link EppConsoleAction}. */ -@RunWith(JUnit4.class) -public class EppConsoleActionTest extends ShardableTestCase { - - private static final byte[] INPUT_XML_BYTES = "".getBytes(UTF_8); - - @Rule - public final AppEngineRule appEngine = AppEngineRule.builder() - .withUserService(UserInfo.create("person@example.com", "12345")) - .build(); - - @Test - public void testAction() { - EppConsoleAction action = new EppConsoleAction(); - action.inputXmlBytes = INPUT_XML_BYTES; - action.session = new FakeHttpSession(); - action.clientId = "ClientIdentifier"; - action.eppRequestHandler = mock(EppRequestHandler.class); - action.userService = getUserService(); - action.registrarAccessor = - AuthenticatedRegistrarAccessor.createForTesting(ImmutableSetMultimap.of()); - action.run(); - ArgumentCaptor credentialsCaptor = - ArgumentCaptor.forClass(TransportCredentials.class); - ArgumentCaptor metadataCaptor = ArgumentCaptor.forClass(SessionMetadata.class); - verify(action.eppRequestHandler) - .executeEpp( - metadataCaptor.capture(), - credentialsCaptor.capture(), - eq(EppRequestSource.CONSOLE), - eq(false), - eq(false), - eq(INPUT_XML_BYTES)); - assertThat(credentialsCaptor.getValue().toString()).contains("user=TestUserId"); - assertThat(metadataCaptor.getValue().getClientId()).isEqualTo("ClientIdentifier"); - } -} diff --git a/javatests/google/registry/flows/EppLoginAdminUserTest.java b/javatests/google/registry/flows/EppLoginAdminUserTest.java deleted file mode 100644 index 6f1a830ea..000000000 --- a/javatests/google/registry/flows/EppLoginAdminUserTest.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2017 The Nomulus 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.flows; - -import com.google.common.collect.ImmutableSetMultimap; -import google.registry.request.auth.AuthenticatedRegistrarAccessor; -import google.registry.testing.AppEngineRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test logging in with appengine admin user credentials. */ -@RunWith(JUnit4.class) -public class EppLoginAdminUserTest extends EppTestCase { - - @Rule - public final AppEngineRule appEngine = AppEngineRule.builder() - .withDatastore() - .build(); - - @Before - public void initTransportCredentials() { - setTransportCredentials( - new GaeUserCredentials( - AuthenticatedRegistrarAccessor.createForTesting( - ImmutableSetMultimap.of( - "TheRegistrar", AuthenticatedRegistrarAccessor.Role.ADMIN, - "NewRegistrar", AuthenticatedRegistrarAccessor.Role.ADMIN)))); - } - - @Test - public void testLoginLogout_wrongPasswordStillWorks() throws Exception { - // For user-based logins the password in the epp xml is ignored. - assertThatLoginSucceeds("NewRegistrar", "incorrect"); - assertThatLogoutSucceeds(); - } - - @Test - public void testNonAuthedMultiLogin_succeedsAsAdmin() throws Exception { - // The admin can log in as different registrars. - assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); - assertThatLogoutSucceeds(); - assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); - assertThatLogoutSucceeds(); - assertThatLoginSucceeds("TheRegistrar", "password2"); - } -} diff --git a/javatests/google/registry/flows/EppLoginUserTest.java b/javatests/google/registry/flows/EppLoginUserTest.java deleted file mode 100644 index 1d581ba47..000000000 --- a/javatests/google/registry/flows/EppLoginUserTest.java +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2017 The Nomulus 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.flows; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSetMultimap; -import google.registry.request.auth.AuthenticatedRegistrarAccessor; -import google.registry.testing.AppEngineRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test logging in with appengine user credentials, such as via the console. */ -@RunWith(JUnit4.class) -public class EppLoginUserTest extends EppTestCase { - - @Rule - public final AppEngineRule appEngine = AppEngineRule.builder() - .withDatastore() - .build(); - - @Before - public void initTest() { - setTransportCredentials( - new GaeUserCredentials( - AuthenticatedRegistrarAccessor.createForTesting( - ImmutableSetMultimap.of( - "NewRegistrar", AuthenticatedRegistrarAccessor.Role.OWNER)))); - } - - @Test - public void testLoginLogout() throws Exception { - assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); - assertThatLogoutSucceeds(); - } - - @Test - public void testNonAuthedLogin_fails() throws Exception { - assertThatLogin("TheRegistrar", "password2") - .hasResponse( - "response_error.xml", - ImmutableMap.of( - "CODE", "2200", - "MSG", "TestUserId doesn't have access to registrar TheRegistrar")); - } - - @Test - public void testMultiLogin() throws Exception { - assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); - assertThatLogoutSucceeds(); - assertThatLoginSucceeds("NewRegistrar", "foo-BAR2"); - assertThatLogoutSucceeds(); - assertThatLogin("TheRegistrar", "password2") - .hasResponse( - "response_error.xml", - ImmutableMap.of( - "CODE", "2200", - "MSG", "TestUserId doesn't have access to registrar TheRegistrar")); - } - - @Test - public void testLoginLogout_wrongPasswordStillWorks() throws Exception { - // For user-based logins the password in the epp xml is ignored. - assertThatLoginSucceeds("NewRegistrar", "incorrect"); - assertThatLogoutSucceeds(); - } -} diff --git a/javatests/google/registry/flows/FlowRunnerTest.java b/javatests/google/registry/flows/FlowRunnerTest.java index c66cc5d78..ac0db7275 100644 --- a/javatests/google/registry/flows/FlowRunnerTest.java +++ b/javatests/google/registry/flows/FlowRunnerTest.java @@ -26,14 +26,12 @@ import static org.mockito.Mockito.verify; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSetMultimap; import com.google.common.flogger.LoggerConfig; import com.google.common.testing.TestLogHandler; import google.registry.model.eppcommon.Trid; import google.registry.model.eppoutput.EppOutput.ResponseOrGreeting; import google.registry.model.eppoutput.EppResponse; import google.registry.monitoring.whitebox.EppMetric; -import google.registry.request.auth.AuthenticatedRegistrarAccessor; import google.registry.testing.AppEngineRule; import google.registry.testing.FakeClock; import google.registry.testing.FakeHttpSession; @@ -140,16 +138,6 @@ public class FlowRunnerTest extends ShardableTestCase { + "{clientId=TheRegistrar, failedLoginAttempts=0, serviceExtensionUris=}"); } - @Test - public void testRun_loggingStatement_gaeUserCredentials() throws Exception { - flowRunner.credentials = - new GaeUserCredentials(AuthenticatedRegistrarAccessor.createForTesting( - ImmutableSetMultimap.of())); - flowRunner.run(eppMetricBuilder); - assertThat(findFirstLogMessageByPrefix(handler, "EPP Command\n\t")) - .contains("user=TestUserId"); - } - @Test public void testRun_loggingStatement_tlsCredentials() throws Exception { flowRunner.credentials = new TlsCredentials(true, "abc123def", Optional.of("127.0.0.1")); diff --git a/javatests/google/registry/flows/session/LoginFlowViaConsoleTest.java b/javatests/google/registry/flows/session/LoginFlowViaConsoleTest.java deleted file mode 100644 index 768390d17..000000000 --- a/javatests/google/registry/flows/session/LoginFlowViaConsoleTest.java +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2017 The Nomulus 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.flows.session; - - -import com.google.common.collect.ImmutableSetMultimap; -import google.registry.flows.GaeUserCredentials; -import google.registry.flows.GaeUserCredentials.UserForbiddenException; -import google.registry.request.auth.AuthenticatedRegistrarAccessor; -import org.junit.Test; - -/** - * Unit tests for {@link LoginFlow} when accessed via a web frontend - * transport, i.e. with GAIA ids. - */ -public class LoginFlowViaConsoleTest extends LoginFlowTestCase { - - @Test - public void testSuccess_withAccess() throws Exception { - credentials = - new GaeUserCredentials( - AuthenticatedRegistrarAccessor.createForTesting( - ImmutableSetMultimap.of( - "NewRegistrar", AuthenticatedRegistrarAccessor.Role.OWNER))); - doSuccessfulTest("login_valid.xml"); - } - - @Test - public void testFailure_withoutAccess() { - credentials = - new GaeUserCredentials( - AuthenticatedRegistrarAccessor.createForTesting( - ImmutableSetMultimap.of())); - doFailingTest("login_valid.xml", UserForbiddenException.class); - } - - @Test - public void testFailure_withAccessToDifferentRegistrar() { - credentials = - new GaeUserCredentials( - AuthenticatedRegistrarAccessor.createForTesting( - ImmutableSetMultimap.of( - "TheRegistrar", AuthenticatedRegistrarAccessor.Role.OWNER))); - doFailingTest("login_valid.xml", UserForbiddenException.class); - } -} diff --git a/javatests/google/registry/module/frontend/testdata/frontend_routing.txt b/javatests/google/registry/module/frontend/testdata/frontend_routing.txt index 7bb31fbf9..8c9fa277a 100644 --- a/javatests/google/registry/module/frontend/testdata/frontend_routing.txt +++ b/javatests/google/registry/module/frontend/testdata/frontend_routing.txt @@ -5,4 +5,3 @@ PATH CLASS METHODS OK AUTH_METHODS /registrar-ote-setup ConsoleOteSetupAction POST,GET n INTERNAL,API,LEGACY NONE PUBLIC /registrar-ote-status OteStatusAction POST n API,LEGACY USER PUBLIC /registrar-settings RegistrarSettingsAction POST n API,LEGACY USER PUBLIC -/registrar-xhr EppConsoleAction POST n API,LEGACY USER PUBLIC diff --git a/javatests/google/registry/server/RegistryTestServer.java b/javatests/google/registry/server/RegistryTestServer.java index 610701666..7bd9ac690 100644 --- a/javatests/google/registry/server/RegistryTestServer.java +++ b/javatests/google/registry/server/RegistryTestServer.java @@ -26,7 +26,6 @@ import google.registry.module.frontend.FrontendServlet; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; - import java.util.Optional; import javax.servlet.Filter; @@ -54,7 +53,6 @@ public final class RegistryTestServer { // Frontend Services route("/whois/*", FrontendServlet.class), route("/rdap/*", FrontendServlet.class), - route("/registrar-xhr", FrontendServlet.class), route("/check", FrontendServlet.class), // Proxy Services diff --git a/javatests/google/registry/ui/js/registrar/console_test.js b/javatests/google/registry/ui/js/registrar/console_test.js index 489fc19b2..3830e1b7d 100644 --- a/javatests/google/registry/ui/js/registrar/console_test.js +++ b/javatests/google/registry/ui/js/registrar/console_test.js @@ -21,7 +21,6 @@ goog.require('goog.testing.MockControl'); goog.require('goog.testing.PropertyReplacer'); goog.require('goog.testing.asserts'); goog.require('goog.testing.jsunit'); -goog.require('goog.testing.mockmatchers'); goog.require('goog.testing.net.XhrIo'); goog.require('registry.registrar.ConsoleTestUtil'); goog.require('registry.testing'); @@ -71,36 +70,6 @@ function testButter() { } -/** - * The EPP login should be triggered if the user `isGaeLoggedIn` - * but not yet `isEppLoggedIn`. - */ -function testEppLogin() { - // This is a little complex, as handleHashChange triggers an async - // event to do the EPP login with a callback to come back to - // handleHashChange after completion. - registry.registrar.ConsoleTestUtil.visit( - test, { - isEppLoggedIn: true, - clientId: test.testClientId, - xsrfToken: test.testXsrfToken, - productName: 'Foo Registry' - }, function() { - test.sessionMock.login( - goog.testing.mockmatchers.isFunction).$does(function() { - test.sessionMock.$reset(); - test.sessionMock.isEppLoggedIn().$returns(true).$anyTimes(); - test.sessionMock.getClientId().$returns( - test.testClientId).$anyTimes(); - test.sessionMock.$replay(); - test.console.handleHashChange(test.testClientId); - }).$anyTimes(); - }); - assertTrue(test.console.session.isEppLoggedIn()); - assertNotNull(goog.dom.getElement('domain-registrar-dashboard')); -} - - /** Authed user with no path op specified should nav to welcome page. */ function testShowLoginOrDash() { registry.registrar.ConsoleTestUtil.visit(test, { diff --git a/javatests/google/registry/ui/js/registrar/console_test_util.js b/javatests/google/registry/ui/js/registrar/console_test_util.js index 023c1cc06..bf835c84f 100644 --- a/javatests/google/registry/ui/js/registrar/console_test_util.js +++ b/javatests/google/registry/ui/js/registrar/console_test_util.js @@ -16,14 +16,9 @@ goog.provide('registry.registrar.ConsoleTestUtil'); goog.setTestOnly('registry.registrar.ConsoleTestUtil'); goog.require('goog.History'); -goog.require('goog.asserts'); -goog.require('goog.dom.xml'); goog.require('goog.soy'); -goog.require('goog.testing.mockmatchers'); goog.require('registry.registrar.Console'); -goog.require('registry.registrar.EppSession'); goog.require('registry.soy.registrar.console'); -goog.require('registry.xml'); /** @@ -34,14 +29,8 @@ goog.require('registry.xml'); */ registry.registrar.ConsoleTestUtil.setup = function(test) { test.historyMock = test.mockControl.createLooseMock(goog.History, true); - test.sessionMock = test.mockControl.createLooseMock( - registry.registrar.EppSession, true); test.mockControl.createConstructorMock(goog, 'History')() .$returns(test.historyMock); - test.mockControl - .createConstructorMock(registry.registrar, 'EppSession')( - goog.testing.mockmatchers.isObject) - .$returns(test.sessionMock); }; /** @@ -76,10 +65,10 @@ registry.registrar.ConsoleTestUtil.renderConsoleMain = function( /** - * Simulates visiting a page on the console. Sets path, then mocks - * session and calls `handleHashChange_`. + * Simulates visiting a page on the console. Sets path, then calls + * `handleHashChange_`. * @param {!Object} test the test case to configure. - * @param {?Object=} opt_args may include path, isEppLoggedIn. + * @param {?Object=} opt_args may include path. * @param {?Function=} opt_moar extra setup after called just before * `$replayAll`. See memegen/3437690. */ @@ -99,33 +88,17 @@ registry.registrar.ConsoleTestUtil.visit = function( if (opt_args.isOwner === undefined) { opt_args.isOwner = !opt_args.isAdmin; } - if (opt_args.isEppLoggedIn === undefined) { - opt_args.isEppLoggedIn = true; - } test.historyMock.$reset(); - test.sessionMock.$reset(); test.historyMock.getToken().$returns(opt_args.path).$anyTimes(); - test.sessionMock.isEppLoggedIn().$returns(opt_args.isEppLoggedIn).$anyTimes(); - test.sessionMock.getClientId().$returns(opt_args.isEppLoggedIn ? - opt_args.clientId : null).$anyTimes(); - if (opt_args.rspXml) { - test.sessionMock - .send(goog.testing.mockmatchers.isString, - goog.testing.mockmatchers.isFunction) - .$does(function(args, cb) { - // XXX: Args should be checked. - const xml = goog.dom.xml.loadXml(opt_args.rspXml); - goog.asserts.assert(xml != null); - cb(registry.xml.convertToJson(xml)); - }).$anyTimes(); - } if (opt_moar) { opt_moar(); } test.mockControl.$replayAll(); /** @type {!registry.registrar.Console} */ test.console = new registry.registrar.Console(opt_args); - // XXX: Should be triggered via event passing. + test.console.setUp(); + // Should be triggered via the History object in test.console.setUp(), but + // since we're using a mock that isn't happening. So we call it manually. test.console.handleHashChange(); test.mockControl.$verifyAll(); }; diff --git a/javatests/google/registry/ui/js/registrar/contact_test.js b/javatests/google/registry/ui/js/registrar/contact_test.js deleted file mode 100644 index a639458d0..000000000 --- a/javatests/google/registry/ui/js/registrar/contact_test.js +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.setTestOnly(); - -goog.require('goog.dispose'); -goog.require('goog.dom'); -goog.require('goog.testing.MockControl'); -goog.require('goog.testing.asserts'); -goog.require('goog.testing.jsunit'); -goog.require('registry.registrar.ConsoleTestUtil'); -goog.require('registry.testing'); - - -const $ = goog.dom.getRequiredElement; - -const test = { - mockControl: new goog.testing.MockControl() -}; - - -function setUp() { - registry.testing.addToDocument('
'); - registry.testing.addToDocument('
'); - registry.registrar.ConsoleTestUtil.renderConsoleMain($('test'), {}); - registry.registrar.ConsoleTestUtil.setup(test); -} - - -function tearDown() { - goog.dispose(test.console); - test.mockControl.$tearDown(); -} - - -/** Contact hash path should nav to contact page. */ -function testVisitContact() { - registry.registrar.ConsoleTestUtil.visit(test, { - path: 'contact/pabloistrad', - rspXml: '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' pabloistrad' + - ' 1-roid' + - ' ' + - ' ' + - ' name2' + - ' ' + - ' ' + - ' city2' + - ' US' + - ' ' + - ' ' + - ' ' + - ' ' + - ' test2.ui@example.com' + - ' daddy' + - ' daddy' + - ' 2014-05-06T22:16:36Z' + - ' daddy' + - ' 2014-05-07T16:20:07Z' + - ' ' + - ' asdfasdf' + - ' ' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' c4O3B0pRRKKSrrXsJvxP5w==-2' + - ' ' + - ' ' + - '' - }); - assertEquals(2, $('contact-postalInfo').childNodes.length); -} - - -/** Contact hash path should nav to contact page. */ -function testEdit() { - testVisitContact(); - registry.testing.assertVisible($('reg-app-btns-edit')); - registry.testing.click($('reg-app-btn-edit')); - registry.testing.assertHidden($('reg-app-btns-edit')); - registry.testing.assertVisible($('reg-app-btns-save')); -} - - -/** Contact hash path should nav to contact page. */ -function testAddPostalInfo() { - testEdit(); - const addPiBtn = $('domain-contact-postalInfo-add-button'); - assertNull(addPiBtn.getAttribute('disabled')); - registry.testing.click(addPiBtn); - assertTrue(addPiBtn.hasAttribute('disabled')); - assertEquals(3, $('contact-postalInfo').childNodes.length); -} diff --git a/javatests/google/registry/ui/js/registrar/domain_test.js b/javatests/google/registry/ui/js/registrar/domain_test.js deleted file mode 100644 index abe8e0416..000000000 --- a/javatests/google/registry/ui/js/registrar/domain_test.js +++ /dev/null @@ -1,475 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.setTestOnly(); - -goog.require('goog.History'); -goog.require('goog.dispose'); -goog.require('goog.dom'); -goog.require('goog.testing.MockControl'); -goog.require('goog.testing.PropertyReplacer'); -goog.require('goog.testing.asserts'); -goog.require('goog.testing.jsunit'); -goog.require('goog.testing.mockmatchers'); -goog.require('goog.testing.net.XhrIo'); -goog.require('registry.registrar.Console'); -goog.require('registry.registrar.ConsoleTestUtil'); -goog.require('registry.testing'); - - -const $ = goog.dom.getRequiredElement; -const _ = goog.testing.mockmatchers.ignoreArgument; -const stubs = new goog.testing.PropertyReplacer(); -const mocks = new goog.testing.MockControl(); - -let historyMock; -let registrarConsole; - - -function setUp() { - registry.testing.addToDocument('
'); - registry.testing.addToDocument('
'); - registry.registrar.ConsoleTestUtil.renderConsoleMain($('test'), {}); - stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo); - - historyMock = mocks.createStrictMock(goog.History); - mocks.createConstructorMock(goog, 'History')().$returns(historyMock); - historyMock.addEventListener(_, _, _); - historyMock.setEnabled(true); - - mocks.$replayAll(); - registrarConsole = new registry.registrar.Console({ - xsrfToken: '☢', - clientId: 'jartine' - }); - mocks.$verifyAll(); -} - - -function tearDown() { - goog.dispose(registrarConsole); - stubs.reset(); - mocks.$tearDown(); - goog.testing.net.XhrIo.cleanup(); -} - - -/** Handles EPP login. */ -function handleLogin() { - const request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' jartine' + - ' undefined' + - ' ' + - ' 1.0' + - ' en' + - ' ' + - ' ' + - ' urn:ietf:params:xml:ns:host-1.0' + - ' urn:ietf:params:xml:ns:domain-1.0' + - ' urn:ietf:params:xml:ns:contact-1.0' + - ' ' + - ' ' + - ' asdf-1235' + - ' ' + - ''); - const response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Registrar is already logged in' + - ' ' + - ' ' + - ' asdf-1235' + - ' ytk1RO+8SmaDQxrTIdulnw==-3' + - ' ' + - ' ' + - ''); - const xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue(xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); -} - - -function testView() { - historyMock.$reset(); - historyMock.getToken().$returns('domain/justine.lol').$anyTimes(); - - mocks.$replayAll(); - - registrarConsole.handleHashChange(); - handleLogin(); - - const request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' justine.lol' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - const response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' justine.lol' + - ' 6-roid' + - ' ' + - ' GK Chesterton' + - ' <justine>' + - ' candycrush' + - ' krieger' + - ' ' + - ' ns1.justine.lol' + - ' ns2.justine.lol' + - ' ' + - ' ns1.justine.lol' + - ' justine' + - ' justine' + - ' 2014-07-10T02:17:02Z' + - ' 2015-07-10T02:17:02Z' + - ' ' + - ' lolcat' + - ' ' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' ytk1RO+8SmaDQxrTIdulnw==-4' + - ' ' + - ' ' + - ''); - const xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - assertEquals('We require more vespene gas.', - 0, goog.testing.net.XhrIo.getSendInstances().length); - - mocks.$verifyAll(); - - assertTrue('Form should be read-only.', $('domain:exDate').readOnly); - assertContains('justine.lol', $('reg-content').innerHTML); - assertEquals('2015-07-10T02:17:02Z', $('domain:exDate').value); - assertEquals('GK Chesterton', $('domain:registrant').value); - assertEquals('', $('domain:contact[0].value').value); - assertEquals('candycrush', $('domain:contact[1].value').value); - assertEquals('krieger', $('domain:contact[2].value').value); - assertEquals('lolcat', $('domain:authInfo.domain:pw').value); - assertEquals('ns1.justine.lol', $('domain:ns.domain:hostObj[0].value').value); - assertEquals('ns2.justine.lol', $('domain:ns.domain:hostObj[1].value').value); -} - - -function testEdit() { - testView(); - - historyMock.$reset(); - - mocks.$replayAll(); - - registry.testing.click($('reg-app-btn-edit')); - assertFalse('Form should be edible.', $('domain:exDate').readOnly); - $('domain:registrant').value = 'Jonathan Swift'; - $('domain:authInfo.domain:pw').value = '(✿◕‿◕)ノ'; - - registry.testing.click($('reg-app-btn-save')); - - let request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' justine.lol' + - ' ' + - ' Jonathan Swift' + - ' ' + - ' (✿◕‿◕)ノ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - let response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' This world is built from a million lies.' + - ' ' + - ' ' + - ' abc-1234' + - ' 214CjbYuTsijoP8sgyFUNg==-e' + - ' ' + - ' ' + - ''); - let xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - - request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' justine.lol' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' How can we live in the land of the dead?' + - ' ' + - ' ' + - ' ' + - ' justine.lol' + - ' 6-roid' + - ' ' + - ' Jonathan Swift' + - ' <justine>' + - ' candycrush' + - ' krieger' + - ' ' + - ' ns1.justine.lol' + - ' ns2.justine.lol' + - ' ' + - ' ns1.justine.lol' + - ' justine' + - ' justine' + - ' 2014-07-10T02:17:02Z' + - ' 2015-07-10T02:17:02Z' + - ' ' + - ' (✿◕‿◕)ノ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' ytk1RO+8SmaDQxrTIdulnw==-4' + - ' ' + - ' ' + - ''); - xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - assertEquals('We require more vespene gas.', - 0, goog.testing.net.XhrIo.getSendInstances().length); - - mocks.$verifyAll(); - - assertTrue($('domain:exDate').readOnly); - assertContains('justine.lol', $('reg-content').innerHTML); - assertEquals('2015-07-10T02:17:02Z', $('domain:exDate').value); - assertEquals('Jonathan Swift', $('domain:registrant').value); - assertEquals('', $('domain:contact[0].value').value); - assertEquals('candycrush', $('domain:contact[1].value').value); - assertEquals('krieger', $('domain:contact[2].value').value); - assertEquals('(✿◕‿◕)ノ', $('domain:authInfo.domain:pw').value); - assertEquals('ns1.justine.lol', $('domain:ns.domain:hostObj[0].value').value); - assertEquals('ns2.justine.lol', $('domain:ns.domain:hostObj[1].value').value); -} - - -function testEdit_cancel_restoresOriginalValues() { - testView(); - - registry.testing.click($('reg-app-btn-edit')); - assertFalse('Form should be edible.', $('domain:exDate').readOnly); - $('domain:registrant').value = 'Jonathan Swift'; - $('domain:authInfo.domain:pw').value = '(✿◕‿◕)ノ'; - - registry.testing.click($('reg-app-btn-cancel')); - assertTrue('Form should be read-only.', $('domain:exDate').readOnly); - assertEquals('GK Chesterton', $('domain:registrant').value); - assertEquals('lolcat', $('domain:authInfo.domain:pw').value); -} - - -function testCreate() { - historyMock.$reset(); - historyMock.getToken().$returns('domain').$anyTimes(); - mocks.$replayAll(); - registrarConsole.handleHashChange(); - handleLogin(); - mocks.$verifyAll(); - - assertFalse('Form should be edible.', $('domain:name').readOnly); - $('domain:name').value = 'bog.lol'; - $('domain:period').value = '1'; - $('domain:authInfo.domain:pw').value = 'attorney at lawl'; - $('domain:registrant').value = 'Chris Pohl'; - registry.testing.click($('domain-contact-add-button')); - $('domain:contact[0].value').value = 'BlutEngel'; - $('domain:contact[0].@type').value = 'admin'; - registry.testing.click($('domain-contact-add-button')); - $('domain:contact[1].value').value = 'Ravenous'; - $('domain:contact[1].@type').value = 'tech'; - registry.testing.click($('domain-contact-add-button')); - $('domain:contact[2].value').value = 'Dark Angels'; - $('domain:contact[2].@type').value = 'billing'; - - historyMock.$reset(); - mocks.$replayAll(); - - registry.testing.click($('reg-app-btn-save')); - - let request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' bog.lol' + - ' 1' + - ' Chris Pohl' + - ' BlutEngel' + - ' Ravenous' + - ' Dark Angels' + - ' ' + - ' attorney at lawl' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - let response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' bog.lol' + - ' 2014-07-17T08:19:24Z' + - ' 2015-07-17T08:19:24Z' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' OBPI6JvEQfOUaO8qGf+IKA==-7' + - ' ' + - ' ' + - ''); - let xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - - request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' bog.lol' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' bog.lol' + - ' 1f-roid' + - ' ' + - ' Chris Pohl' + - ' BlutEngel' + - ' Ravenous' + - ' Dark Angels' + - ' justine' + - ' justine' + - ' 2014-07-17T08:19:24Z' + - ' 2015-07-17T08:19:24Z' + - ' ' + - ' attorney at lawl' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' OBPI6JvEQfOUaO8qGf+IKA==-8' + - ' ' + - ' ' + - ''); - xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - assertEquals('We require more vespene gas.', - 0, goog.testing.net.XhrIo.getSendInstances().length); - - mocks.$verifyAll(); - - assertTrue('Form should be read-only.', $('domain:exDate').readOnly); - assertContains('bog.lol', $('reg-content').innerHTML); - assertEquals('2015-07-17T08:19:24Z', $('domain:exDate').value); - assertEquals('Chris Pohl', $('domain:registrant').value); - assertEquals('BlutEngel', $('domain:contact[0].value').value); - assertEquals('Ravenous', $('domain:contact[1].value').value); - assertEquals('Dark Angels', $('domain:contact[2].value').value); - assertEquals('attorney at lawl', $('domain:authInfo.domain:pw').value); - assertNull(goog.dom.getElement('domain:ns.domain:hostObj[0].value')); -} diff --git a/javatests/google/registry/ui/js/registrar/host_test.js b/javatests/google/registry/ui/js/registrar/host_test.js deleted file mode 100644 index b876db1b2..000000000 --- a/javatests/google/registry/ui/js/registrar/host_test.js +++ /dev/null @@ -1,415 +0,0 @@ -// Copyright 2017 The Nomulus 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. - -goog.setTestOnly(); - -goog.require('goog.History'); -goog.require('goog.dispose'); -goog.require('goog.dom'); -goog.require('goog.testing.MockControl'); -goog.require('goog.testing.PropertyReplacer'); -goog.require('goog.testing.asserts'); -goog.require('goog.testing.jsunit'); -goog.require('goog.testing.mockmatchers'); -goog.require('goog.testing.net.XhrIo'); -goog.require('registry.registrar.Console'); -goog.require('registry.registrar.ConsoleTestUtil'); -goog.require('registry.testing'); - - -const $ = goog.dom.getRequiredElement; -const _ = goog.testing.mockmatchers.ignoreArgument; -const stubs = new goog.testing.PropertyReplacer(); -const mocks = new goog.testing.MockControl(); - -let historyMock; -let registrarConsole; - - -function setUp() { - registry.testing.addToDocument('
'); - registry.testing.addToDocument('
'); - registry.registrar.ConsoleTestUtil.renderConsoleMain($('test'), {}); - stubs.setPath('goog.net.XhrIo', goog.testing.net.XhrIo); - - historyMock = mocks.createStrictMock(goog.History); - mocks.createConstructorMock(goog, 'History')().$returns(historyMock); - historyMock.addEventListener(_, _, _); - historyMock.setEnabled(true); - - mocks.$replayAll(); - registrarConsole = new registry.registrar.Console({ - xsrfToken: '☢', - clientId: 'jartine' - }); - mocks.$verifyAll(); -} - - -function tearDown() { - goog.dispose(registrarConsole); - stubs.reset(); - mocks.$tearDown(); - goog.testing.net.XhrIo.cleanup(); -} - - -/** Handles EPP login. */ -function handleLogin() { - const request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' jartine' + - ' undefined' + - ' ' + - ' 1.0' + - ' en' + - ' ' + - ' ' + - ' urn:ietf:params:xml:ns:host-1.0' + - ' urn:ietf:params:xml:ns:domain-1.0' + - ' urn:ietf:params:xml:ns:contact-1.0' + - ' ' + - ' ' + - ' asdf-1235' + - ' ' + - ''); - const response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Registrar is already logged in' + - ' ' + - ' ' + - ' asdf-1235' + - ' ytk1RO+8SmaDQxrTIdulnw==-3' + - ' ' + - ' ' + - ''); - const xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue(xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); -} - - -function testView() { - historyMock.$reset(); - historyMock.getToken().$returns('host/ns1.justine.lol').$anyTimes(); - - mocks.$replayAll(); - - registrarConsole.handleHashChange(); - handleLogin(); - - const request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' ns1.justine.lol' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - const response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' ns1.justine.lol' + - ' 8-roid' + - ' ' + - ' 8.8.8.8' + - ' feed:a:bee::1' + - ' justine' + - ' justine' + - ' 2014-07-10T02:18:34Z' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' EweBEzCZTJirOqRmrtYrAA==-b' + - ' ' + - ' ' + - ''); - const xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('application/epp+xml', - xhr.getLastRequestHeaders()['Content-Type']); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - assertEquals('We require more vespene gas.', - 0, goog.testing.net.XhrIo.getSendInstances().length); - - mocks.$verifyAll(); - - assertTrue('Form should be read-only.', $('host:chgName').readOnly); - assertContains('ns1.justine.lol', $('reg-content').innerHTML); - assertEquals('ns1.justine.lol', $('host:chgName').value); - assertEquals('8.8.8.8', $('host:addr[0].value').value); - assertEquals('feed:a:bee::1', $('host:addr[1].value').value); -} - - -function testEditFirstAddr_ignoreSecond_addThird() { - testView(); - - historyMock.$reset(); - - mocks.$replayAll(); - - registry.testing.click($('reg-app-btn-edit')); - - assertFalse('Form should be edible.', $('host:addr[0].value').readOnly); - $('host:addr[0].value').value = '1.2.3.4'; - registry.testing.click($('domain-host-addr-add-button')); - $('host:addr[2].value').value = 'feed:a:fed::1'; - - registry.testing.click($('reg-app-btn-save')); - - let request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' ns1.justine.lol' + - ' ' + - ' 1.2.3.4' + - ' feed:a:fed::1' + - ' ' + - ' ' + - ' 8.8.8.8' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - let response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' This world is built from a million lies.' + - ' ' + - ' ' + - ' abc-1234' + - ' 214CjbYuTsijoP8sgyFUNg==-e' + - ' ' + - ' ' + - ''); - let xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - - request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' ns1.justine.lol' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' ns1.justine.lol' + - ' 8-roid' + - ' ' + - ' feed:a:bee::1' + - ' 1.2.3.4' + - ' feed:a:fed::1' + - ' justine' + - ' justine' + - ' 2014-07-10T02:18:34Z' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' EweBEzCZTJirOqRmrtYrAA==-b' + - ' ' + - ' ' + - ''); - xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - assertEquals('We require more vespene gas.', - 0, goog.testing.net.XhrIo.getSendInstances().length); - - mocks.$verifyAll(); - - assertTrue('Form should be read-only.', $('host:chgName').readOnly); - assertContains('ns1.justine.lol', $('reg-content').innerHTML); - assertEquals('ns1.justine.lol', $('host:chgName').value); - assertEquals('feed:a:bee::1', $('host:addr[0].value').value); - assertEquals('1.2.3.4', $('host:addr[1].value').value); - assertEquals('feed:a:fed::1', $('host:addr[2].value').value); -} - - -function testCreate() { - historyMock.$reset(); - historyMock.getToken().$returns('host').$anyTimes(); - mocks.$replayAll(); - registrarConsole.handleHashChange(); - handleLogin(); - mocks.$verifyAll(); - - assertFalse('Form should be edible.', $('host:name').readOnly); - $('host:name').value = 'ns1.example.tld'; - registry.testing.click($('domain-host-addr-add-button')); - $('host:addr[0].value').value = '192.0.2.2'; - registry.testing.click($('domain-host-addr-add-button')); - $('host:addr[1].value').value = '192.0.2.29'; - registry.testing.click($('domain-host-addr-add-button')); - $('host:addr[2].value').value = '1080:0:0:0:8:800:200C:417A'; - - historyMock.$reset(); - mocks.$replayAll(); - - registry.testing.click($('reg-app-btn-save')); - - let request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' ns1.example.tld' + - ' 192.0.2.2' + - ' 192.0.2.29' + - ' 1080:0:0:0:8:800:200C:417A' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - let response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' ns1.example.tld' + - ' 1999-04-03T22:00:00.0Z' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' EweBEzCZTJirOqRmrtYrAA==-b' + - ' ' + - ' ' + - ''); - let xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - - request = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' ' + - ' ns1.example.tld' + - ' ' + - ' ' + - ' abc-1234' + - ' ' + - ''); - response = registry.testing.loadXml( - '' + - '' + - ' ' + - ' ' + - ' Command completed successfully' + - ' ' + - ' ' + - ' ' + - ' ns1.example.tld' + - ' NS1_EXAMPLE1-REP' + - ' ' + - ' ' + - ' 192.0.2.2' + - ' 192.0.2.29' + - ' 1080:0:0:0:8:800:200C:417A' + - ' TheRegistrar' + - ' NewRegistrar' + - ' 1999-04-03T22:00:00.0Z' + - ' NewRegistrar' + - ' 1999-12-03T09:00:00.0Z' + - ' 2000-04-08T09:00:00.0Z' + - ' ' + - ' ' + - ' ' + - ' abc-1234' + - ' EweBEzCZTJirOqRmrtYrAA==-b' + - ' ' + - ' ' + - ''); - xhr = goog.testing.net.XhrIo.getSendInstances().pop(); - assertTrue('XHR is inactive.', xhr.isActive()); - assertEquals('/registrar-xhr?clientId=jartine', xhr.getLastUri()); - assertEquals('☢', xhr.getLastRequestHeaders()['X-CSRF-Token']); - registry.testing.assertXmlEquals(request, xhr.getLastContent()); - xhr.simulateResponse(200, response); - assertEquals('We require more vespene gas.', - 0, goog.testing.net.XhrIo.getSendInstances().length); - - mocks.$verifyAll(); - - assertTrue('Form should be read-only.', $('host:chgName').readOnly); - assertEquals('ns1.example.tld', $('host:chgName').value); - assertEquals('192.0.2.2', $('host:addr[0].value').value); - assertEquals('192.0.2.29', $('host:addr[1].value').value); - assertEquals('1080:0:0:0:8:800:200C:417A', $('host:addr[2].value').value); -} diff --git a/javatests/google/registry/ui/js/testing.js b/javatests/google/registry/ui/js/testing.js index 2a77ad8e9..8f0c12ee5 100644 --- a/javatests/google/registry/ui/js/testing.js +++ b/javatests/google/registry/ui/js/testing.js @@ -15,15 +15,12 @@ goog.provide('registry.testing'); goog.setTestOnly('registry.testing'); -goog.require('goog.asserts'); goog.require('goog.dom'); goog.require('goog.dom.classlist'); -goog.require('goog.dom.xml'); goog.require('goog.events.EventType'); goog.require('goog.format.JsonPrettyPrinter'); goog.require('goog.html.testing'); goog.require('goog.json'); -goog.require('goog.testing.asserts'); goog.require('goog.testing.events'); goog.require('goog.testing.events.Event'); goog.require('goog.testing.net.XhrIo'); @@ -40,32 +37,6 @@ registry.testing.addToDocument = function(html) { }; -/** - * Extracts XML document from inside an `