From 8a820b3f75e7049fd9316b1a8480d6cae73c6a1b Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Tue, 12 Feb 2019 10:58:59 -0500 Subject: [PATCH 01/12] HostUpdate initialize ToAdd & ToRemove fields --- EppLib/Entities/Host/HostUpdate.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EppLib/Entities/Host/HostUpdate.cs b/EppLib/Entities/Host/HostUpdate.cs index d540c0a..e54f414 100755 --- a/EppLib/Entities/Host/HostUpdate.cs +++ b/EppLib/Entities/Host/HostUpdate.cs @@ -19,8 +19,8 @@ public class HostUpdate : HostBase { private readonly string HostName; - public EppHostUpdateAddRemove ToAdd; - public EppHostUpdateAddRemove ToRemove; + public EppHostUpdateAddRemove ToAdd = new EppHostUpdateAddRemove(); + public EppHostUpdateAddRemove ToRemove = new EppHostUpdateAddRemove(); public HostChange HostChange; From 36a50721d8acbbda77d46f8f1082fab515f5dac8 Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Tue, 12 Feb 2019 11:03:01 -0500 Subject: [PATCH 02/12] EppHostUpdateaddRemove initialize fields --- EppLib/Entities/Host/EppHostUpdateAddRemove.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/EppLib/Entities/Host/EppHostUpdateAddRemove.cs b/EppLib/Entities/Host/EppHostUpdateAddRemove.cs index b35289b..fab5392 100755 --- a/EppLib/Entities/Host/EppHostUpdateAddRemove.cs +++ b/EppLib/Entities/Host/EppHostUpdateAddRemove.cs @@ -19,5 +19,11 @@ public class EppHostUpdateAddRemove { public IList Adresses { get; set; } public IList Status; + + public EppHostUpdateAddRemove() + { + Adresses = new List(); + Status = new List(); + } } } \ No newline at end of file From cabadb71aa78872edfc0de125b43696c475fa522 Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Tue, 12 Feb 2019 11:55:41 -0500 Subject: [PATCH 03/12] IDN extension + test --- EppLib.UnitTests/EppLib.UnitTests.csproj | 4 +++ EppLib.UnitTests/IdnExtensionLocalTest.cs | 31 ++++++++++++++++++++ EppLib/EppLib.csproj | 1 + EppLib/Extensions/Idn/IdnExtension.cs | 35 +++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 EppLib.UnitTests/IdnExtensionLocalTest.cs create mode 100644 EppLib/Extensions/Idn/IdnExtension.cs diff --git a/EppLib.UnitTests/EppLib.UnitTests.csproj b/EppLib.UnitTests/EppLib.UnitTests.csproj index a30bd06..4cce5b6 100644 --- a/EppLib.UnitTests/EppLib.UnitTests.csproj +++ b/EppLib.UnitTests/EppLib.UnitTests.csproj @@ -52,6 +52,7 @@ + @@ -118,6 +119,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/EppLib.UnitTests/IdnExtensionLocalTest.cs b/EppLib.UnitTests/IdnExtensionLocalTest.cs new file mode 100644 index 0000000..4756ec5 --- /dev/null +++ b/EppLib.UnitTests/IdnExtensionLocalTest.cs @@ -0,0 +1,31 @@ +using EppLib.Entities; +using EppLib.Extensions.Idn; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.IO; + +namespace EppLib.Tests +{ + [TestClass] + public class IdnExtensionLocalTest + { + [TestMethod] + [TestCategory("FuryExtension")] + [DeploymentItem("TestData/IdnDomainCreateCommand.xml")] + public void Test() + { + string expected = File.ReadAllText("IdnDomainCreateCommand.xml"); + + var command = new DomainCreate("xn--espaol-zwa.example.com", "jd1234"); + command.Password = "2fooBAR"; + command.DomainContacts.Add(new DomainContact("sh8013", "admin")); + command.DomainContacts.Add(new DomainContact("sh8013", "tech")); + + command.Extensions.Add(new IdnExtension("es", "español.example.com")); + + var xml = command.ToXml().InnerXml; + + Assert.AreEqual(expected, xml); + } + + } +} diff --git a/EppLib/EppLib.csproj b/EppLib/EppLib.csproj index eb9c60e..0fc27af 100644 --- a/EppLib/EppLib.csproj +++ b/EppLib/EppLib.csproj @@ -57,6 +57,7 @@ + diff --git a/EppLib/Extensions/Idn/IdnExtension.cs b/EppLib/Extensions/Idn/IdnExtension.cs new file mode 100644 index 0000000..67bfe0e --- /dev/null +++ b/EppLib/Extensions/Idn/IdnExtension.cs @@ -0,0 +1,35 @@ +using EppLib.Entities; +using System.Xml; + +namespace EppLib.Extensions.Idn +{ + public class IdnExtension : EppExtension + { + private string _ns = "urn:ietf:params:xml:ns:idn-1.0"; + + private string table; + private string uname; + + public IdnExtension(string table, string uname) + { + this.table = table; + this.uname = uname; + } + + protected override string Namespace + { + get { return _ns; } + set { _ns = value; } + } + + public override XmlNode ToXml(XmlDocument doc) + { + var root = CreateElement(doc, "idn:data"); + + AddXmlElement(doc, root, "idn:table", table); + AddXmlElement(doc, root, "idn:uname", uname); + + return root; + } + } +} From 22dab0f539bf8961bf98127a5acea302b16f7f65 Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Tue, 12 Feb 2019 12:02:53 -0500 Subject: [PATCH 04/12] idn test file --- EppLib.UnitTests/TestData/IdnDomainCreateCommand.xml | 1 + 1 file changed, 1 insertion(+) create mode 100644 EppLib.UnitTests/TestData/IdnDomainCreateCommand.xml diff --git a/EppLib.UnitTests/TestData/IdnDomainCreateCommand.xml b/EppLib.UnitTests/TestData/IdnDomainCreateCommand.xml new file mode 100644 index 0000000..81e38bd --- /dev/null +++ b/EppLib.UnitTests/TestData/IdnDomainCreateCommand.xml @@ -0,0 +1 @@ +xn--espaol-zwa.example.comjd1234sh8013sh80132fooBAResespañol.example.com \ No newline at end of file From 689868f7da1869f240b4f161ad5bcaf0b3b0bdbe Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Tue, 12 Feb 2019 12:29:39 -0500 Subject: [PATCH 05/12] allows to set an empty password (fix #35) --- EppLib/Entities/Contact/ContactCreate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EppLib/Entities/Contact/ContactCreate.cs b/EppLib/Entities/Contact/ContactCreate.cs index dc3e38b..2cadb03 100755 --- a/EppLib/Entities/Contact/ContactCreate.cs +++ b/EppLib/Entities/Contact/ContactCreate.cs @@ -64,7 +64,7 @@ protected override XmlElement BuildCommandElement(XmlDocument doc, XmlElement co AddXmlElement(doc, contact_create, "contact:email", contact.Email, namespaceUri); } - if (!String.IsNullOrWhiteSpace(Password)) + if (Password!=null) { var authInfo = AddXmlElement(doc, contact_create, nspace + ":authInfo", null, namespaceUri); AddXmlElement(doc, authInfo, nspace + ":pw", Password, namespaceUri); From a3c4266f48849a4660f8ec3bcd75b0a299145946 Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Thu, 14 Feb 2019 13:14:09 -0500 Subject: [PATCH 06/12] ported to netstandard 2.0 --- EppLib.Tests/EppLib.Tests.csproj | 49 ++----------- EppLib.UnitTests/DeploymentUtility.cs | 28 ++++++++ EppLib.UnitTests/EppLib.UnitTests.csproj | 67 +++-------------- EppLib.UnitTests/FuryExtensionLocalTest.cs | 13 +++- EppLib.UnitTests/IdnExtensionLocalTest.cs | 12 ++++ EppLib.UnitTests/IisExtensionLocalTest.cs | 20 +++--- .../LaunchPhaseExtensionLocalTest.cs | 14 ++++ EppLib.UnitTests/LocalTest.cs | 19 ++--- EppLib.UnitTests/NominetExtensionLocalTest.cs | 21 +++--- EppLib.UnitTests/SecDNSExtensionLocalTest.cs | 16 +++-- EppLib/EppLib.csproj | 71 ++----------------- EppLib/Properties/AssemblyInfo.cs | 5 +- 12 files changed, 130 insertions(+), 205 deletions(-) create mode 100644 EppLib.UnitTests/DeploymentUtility.cs diff --git a/EppLib.Tests/EppLib.Tests.csproj b/EppLib.Tests/EppLib.Tests.csproj index 3c0b7c8..6124545 100755 --- a/EppLib.Tests/EppLib.Tests.csproj +++ b/EppLib.Tests/EppLib.Tests.csproj @@ -1,40 +1,11 @@  - - - Debug - x86 - 8.0.30703 - 2.0 - {B037131A-F558-4C96-8781-9E0CB1BBEF2E} - Exe - Properties - EppLib.Tests + + + net461 EppLib.Tests - v4.0 - - - 512 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false + true + false + false @@ -72,12 +43,4 @@ - - \ No newline at end of file diff --git a/EppLib.UnitTests/DeploymentUtility.cs b/EppLib.UnitTests/DeploymentUtility.cs new file mode 100644 index 0000000..d6ea080 --- /dev/null +++ b/EppLib.UnitTests/DeploymentUtility.cs @@ -0,0 +1,28 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.IO; +using System.Reflection; + +namespace EppLib.Tests +{ + class DeploymentUtility + { + public static void CopyDeploymentItems(object[] attributes) + { + foreach (DeploymentItemAttribute att in attributes) + { + var origin = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), att.Path); + var targetDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), att.OutputDirectory); + Directory.CreateDirectory(targetDir); + try + { + File.Copy(origin, Path.Combine(targetDir, Path.GetFileName(origin))); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine("Error copying deployment item {0} to {1} message {2}", origin, targetDir, ex.Message); + } + } + } + } +} diff --git a/EppLib.UnitTests/EppLib.UnitTests.csproj b/EppLib.UnitTests/EppLib.UnitTests.csproj index 4cce5b6..99c455b 100644 --- a/EppLib.UnitTests/EppLib.UnitTests.csproj +++ b/EppLib.UnitTests/EppLib.UnitTests.csproj @@ -1,57 +1,20 @@  - + - Debug - AnyCPU - - - 2.0 - {31A88640-FDF7-46E1-83D7-C65000720EA4} - Library - Properties - EppLib.Tests - EppLib.Tests - v4.0 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - + netcoreapp2.1 + EppLib.UnitTests + true + false + false + true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - - - 3.5 - - - - - - - - False - + + + + @@ -342,12 +305,4 @@ Designer - - \ No newline at end of file diff --git a/EppLib.UnitTests/FuryExtensionLocalTest.cs b/EppLib.UnitTests/FuryExtensionLocalTest.cs index 292e95a..454df07 100644 --- a/EppLib.UnitTests/FuryExtensionLocalTest.cs +++ b/EppLib.UnitTests/FuryExtensionLocalTest.cs @@ -1,15 +1,26 @@ using EppLib.Entities; using EppLib.Extensions.Fury; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Diagnostics; using System.IO; using System.Text; -using System.Xml; namespace EppLib.Tests { [TestClass] public class FuryExtensionLocalTest { + public TestContext TestContext { get; set; } + + [TestInitialize] + public void TestSetup() + { + var testName = TestContext.TestName; + var method = new StackFrame().GetMethod().DeclaringType.GetMethod(testName); + var attributes = method.GetCustomAttributes(typeof(DeploymentItemAttribute), false); + DeploymentUtility.CopyDeploymentItems(attributes); + } + [TestMethod] [TestCategory("FuryExtension")] [DeploymentItem("TestData/FuryLoginCommand.xml")] diff --git a/EppLib.UnitTests/IdnExtensionLocalTest.cs b/EppLib.UnitTests/IdnExtensionLocalTest.cs index 4756ec5..75d5c4c 100644 --- a/EppLib.UnitTests/IdnExtensionLocalTest.cs +++ b/EppLib.UnitTests/IdnExtensionLocalTest.cs @@ -1,6 +1,7 @@ using EppLib.Entities; using EppLib.Extensions.Idn; using Microsoft.VisualStudio.TestTools.UnitTesting; +using System.Diagnostics; using System.IO; namespace EppLib.Tests @@ -8,6 +9,17 @@ namespace EppLib.Tests [TestClass] public class IdnExtensionLocalTest { + public TestContext TestContext { get; set; } + + [TestInitialize] + public void TestSetup() + { + var testName = TestContext.TestName; + var method = new StackFrame().GetMethod().DeclaringType.GetMethod(testName); + var attributes = method.GetCustomAttributes(typeof(DeploymentItemAttribute), false); + DeploymentUtility.CopyDeploymentItems(attributes); + } + [TestMethod] [TestCategory("FuryExtension")] [DeploymentItem("TestData/IdnDomainCreateCommand.xml")] diff --git a/EppLib.UnitTests/IisExtensionLocalTest.cs b/EppLib.UnitTests/IisExtensionLocalTest.cs index 4ae26e8..73c4176 100644 --- a/EppLib.UnitTests/IisExtensionLocalTest.cs +++ b/EppLib.UnitTests/IisExtensionLocalTest.cs @@ -3,22 +3,22 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using EppLib.Entities; using EppLib.Extensions.Iis; +using System.Diagnostics; namespace EppLib.Tests { [TestClass] public class IisExtensionLocalTest { - private TestContext _context; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get { return _context; } - set { _context = value; } + public TestContext TestContext { get; set; } + + [TestInitialize] + public void TestSetup() + { + var testName = TestContext.TestName; + var method = new StackFrame().GetMethod().DeclaringType.GetMethod(testName); + var attributes = method.GetCustomAttributes(typeof(DeploymentItemAttribute), false); + DeploymentUtility.CopyDeploymentItems(attributes); } public IisExtensionLocalTest() diff --git a/EppLib.UnitTests/LaunchPhaseExtensionLocalTest.cs b/EppLib.UnitTests/LaunchPhaseExtensionLocalTest.cs index cb352b2..1f4c8ea 100644 --- a/EppLib.UnitTests/LaunchPhaseExtensionLocalTest.cs +++ b/EppLib.UnitTests/LaunchPhaseExtensionLocalTest.cs @@ -2,6 +2,7 @@ using EppLib.Extensions.LaunchPhase.ClaimCreate; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using System.Diagnostics; using System.IO; namespace EppLib.Tests @@ -9,6 +10,19 @@ namespace EppLib.Tests [TestClass] public class LaunchPhaseExtensionLocalTest { + + public TestContext TestContext { get; set; } + + [TestInitialize] + public void TestSetup() + { + var testName = TestContext.TestName; + var method = new StackFrame().GetMethod().DeclaringType.GetMethod(testName); + var attributes = method.GetCustomAttributes(typeof(DeploymentItemAttribute), false); + DeploymentUtility.CopyDeploymentItems(attributes); + } + + #region Claim Check /// diff --git a/EppLib.UnitTests/LocalTest.cs b/EppLib.UnitTests/LocalTest.cs index 79743b9..be05c14 100644 --- a/EppLib.UnitTests/LocalTest.cs +++ b/EppLib.UnitTests/LocalTest.cs @@ -7,22 +7,23 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using EppLib.Entities; +using System.Diagnostics; namespace EppLib.Tests { [TestClass] public class LocalTest { - private TestContext _context; - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext - { - get { return _context; } - set { _context = value; } + public TestContext TestContext { get; set; } + + [TestInitialize] + public void TestSetup() + { + var testName = TestContext.TestName; + var method = new StackFrame().GetMethod().DeclaringType.GetMethod(testName); + var attributes = method.GetCustomAttributes(typeof(DeploymentItemAttribute), false); + DeploymentUtility.CopyDeploymentItems(attributes); } public LocalTest() diff --git a/EppLib.UnitTests/NominetExtensionLocalTest.cs b/EppLib.UnitTests/NominetExtensionLocalTest.cs index 984755a..e9345eb 100644 --- a/EppLib.UnitTests/NominetExtensionLocalTest.cs +++ b/EppLib.UnitTests/NominetExtensionLocalTest.cs @@ -1,9 +1,7 @@ using System; -using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; -using System.Text; -using System.Windows.Forms; using EppLib.Entities; using EppLib.Extensions.Nominet; using EppLib.Extensions.Nominet.ContactInfo; @@ -19,16 +17,15 @@ namespace EppLib.Tests [TestClass] public class NominetExtensionLocalTest { - private TestContext _context; - - /// - ///Gets or sets the test context which provides - ///information about and functionality for the current test run. - /// - public TestContext TestContext + public TestContext TestContext { get; set; } + + [TestInitialize] + public void TestSetup() { - get { return _context; } - set { _context = value; } + var testName = TestContext.TestName; + var method = new StackFrame().GetMethod().DeclaringType.GetMethod(testName); + var attributes = method.GetCustomAttributes(typeof(DeploymentItemAttribute), false); + DeploymentUtility.CopyDeploymentItems(attributes); } public NominetExtensionLocalTest(){} diff --git a/EppLib.UnitTests/SecDNSExtensionLocalTest.cs b/EppLib.UnitTests/SecDNSExtensionLocalTest.cs index b623932..ee51048 100644 --- a/EppLib.UnitTests/SecDNSExtensionLocalTest.cs +++ b/EppLib.UnitTests/SecDNSExtensionLocalTest.cs @@ -1,17 +1,25 @@ using EppLib.Entities; using EppLib.Extensions.SecDNS; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; +using System.Diagnostics; using System.IO; -using System.Linq; -using System.Text; namespace EppLib.Tests { [TestClass] public class SecDNSExtensionLocalTest { + public TestContext TestContext { get; set; } + + [TestInitialize] + public void TestSetup() + { + var testName = TestContext.TestName; + var method = new StackFrame().GetMethod().DeclaringType.GetMethod(testName); + var attributes = method.GetCustomAttributes(typeof(DeploymentItemAttribute), false); + DeploymentUtility.CopyDeploymentItems(attributes); + } + [TestMethod] [TestCategory("SecDNSExtension")] [DeploymentItem("TestData/SecDNSCreateExtension.xml")] diff --git a/EppLib/EppLib.csproj b/EppLib/EppLib.csproj index 0fc27af..259f616 100644 --- a/EppLib/EppLib.csproj +++ b/EppLib/EppLib.csproj @@ -1,49 +1,12 @@  - + - Debug - AnyCPU - {24067FC1-33F6-428B-8E0E-74601A5354EA} - Library - Properties - EppLib + netstandard2.0 EppLib - v4.0 - 512 - OnOutputUpdated - + true + false + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - epplib.pfx - - - - - - - - - - @@ -199,34 +162,10 @@ - - True - True - Settings.settings - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - if /I "$(ConfigurationName)" == "Release" Eazfuscator.NET.exe "$(TargetPath)" --msbuild-project-path "$(ProjectPath)" --msbuild-project-configuration "$(ConfigurationName)" --msbuild-project-platform "$(PlatformName)" --msbuild-solution-path "$(SolutionPath)" -n --newline-flush -v 3.2 - \ No newline at end of file diff --git a/EppLib/Properties/AssemblyInfo.cs b/EppLib/Properties/AssemblyInfo.cs index 6f40128..33848da 100755 --- a/EppLib/Properties/AssemblyInfo.cs +++ b/EppLib/Properties/AssemblyInfo.cs @@ -13,7 +13,6 @@ // limitations under the License. using System; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -45,8 +44,6 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.*")] -//[assembly: AssemblyVersion("1.0.0.0")] -//[assembly: AssemblyFileVersion("1.0.0.0")] + [assembly: CLSCompliant(true)] \ No newline at end of file From fb5cec45db0529b47fbddbb35c1c7eaa8da4a13f Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Thu, 14 Feb 2019 21:18:47 -0500 Subject: [PATCH 07/12] update nuspec --- EppLib/EppLib.nuspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EppLib/EppLib.nuspec b/EppLib/EppLib.nuspec index df8e71b..a0b8c3b 100644 --- a/EppLib/EppLib.nuspec +++ b/EppLib/EppLib.nuspec @@ -15,6 +15,6 @@ Our library is a complete implementation of the EPP specification. Have a look a EppLib.NET is a .NET library implementing the Extensible Provisioning Protocol (EPP) - + \ No newline at end of file From 3a26b79d20390cec2cd0b95045580b1c4648b146 Mon Sep 17 00:00:00 2001 From: Nerzool Date: Sat, 3 Aug 2019 01:40:25 +0200 Subject: [PATCH 08/12] Namestore extension (.com/.net/.cc/...) --- EppLib/EppLib.csproj | 2 ++ .../Namestore/NamestoreCreateExtension.cs | 29 +++++++++++++++++++ .../Namestore/NamestoreExtension.cs | 18 ++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 EppLib/Extensions/Namestore/NamestoreCreateExtension.cs create mode 100644 EppLib/Extensions/Namestore/NamestoreExtension.cs diff --git a/EppLib/EppLib.csproj b/EppLib/EppLib.csproj index 259f616..fa9170b 100644 --- a/EppLib/EppLib.csproj +++ b/EppLib/EppLib.csproj @@ -42,6 +42,8 @@ + + diff --git a/EppLib/Extensions/Namestore/NamestoreCreateExtension.cs b/EppLib/Extensions/Namestore/NamestoreCreateExtension.cs new file mode 100644 index 0000000..740ae17 --- /dev/null +++ b/EppLib/Extensions/Namestore/NamestoreCreateExtension.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace EppLib.Extensions.Namestore +{ + public class NamestoreCreateExtension : NamestoreExtension + { + public NamestoreCreateExtension(string subproduct) + { + SubProduct = subproduct; + } + + public string SubProduct; + + public override XmlNode ToXml(XmlDocument doc) + { + var root = CreateElement(doc, "namestoreExt"); + + if (SubProduct != null) + { + AddXmlElement(doc, root, "namestoreExt:subProduct", $"dot{SubProduct}"); + } + + return root; + } + } +} diff --git a/EppLib/Extensions/Namestore/NamestoreExtension.cs b/EppLib/Extensions/Namestore/NamestoreExtension.cs new file mode 100644 index 0000000..d7010a8 --- /dev/null +++ b/EppLib/Extensions/Namestore/NamestoreExtension.cs @@ -0,0 +1,18 @@ +using EppLib.Entities; +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; + +namespace EppLib.Extensions.Namestore +{ + public abstract class NamestoreExtension : EppExtension + { + private string _ns = "http://www.verisign-grs.com/epp/namestoreExt-1.1"; + protected override string Namespace + { + get { return _ns; } + set { _ns = value; } + } + } +} From b22e56fbd8584da2196465bb9adc81d0a10d773e Mon Sep 17 00:00:00 2001 From: Nerzool Date: Sat, 3 Aug 2019 01:47:08 +0200 Subject: [PATCH 09/12] remove useless using statements --- EppLib/Extensions/Namestore/NamestoreCreateExtension.cs | 5 +---- EppLib/Extensions/Namestore/NamestoreExtension.cs | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/EppLib/Extensions/Namestore/NamestoreCreateExtension.cs b/EppLib/Extensions/Namestore/NamestoreCreateExtension.cs index 740ae17..b668dfd 100644 --- a/EppLib/Extensions/Namestore/NamestoreCreateExtension.cs +++ b/EppLib/Extensions/Namestore/NamestoreCreateExtension.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; +using System.Xml; namespace EppLib.Extensions.Namestore { diff --git a/EppLib/Extensions/Namestore/NamestoreExtension.cs b/EppLib/Extensions/Namestore/NamestoreExtension.cs index d7010a8..e09decf 100644 --- a/EppLib/Extensions/Namestore/NamestoreExtension.cs +++ b/EppLib/Extensions/Namestore/NamestoreExtension.cs @@ -1,8 +1,4 @@ using EppLib.Entities; -using System; -using System.Collections.Generic; -using System.Text; -using System.Xml; namespace EppLib.Extensions.Namestore { From bd2b9a039ef6f6c3b6c6be24a4b6489cf74387c9 Mon Sep 17 00:00:00 2001 From: Nerzool Date: Sat, 3 Aug 2019 03:05:37 +0200 Subject: [PATCH 10/12] Smallregistry extension --- EppLib/EppLib.csproj | 4 ++ .../SmallregistryContactCreate.cs | 43 +++++++++++++++++++ .../SmallregistryContactPMCreateExtension.cs | 26 +++++++++++ .../SmallregistryContactPPCreateExtension.cs | 33 ++++++++++++++ .../SmallregistryExtensionBase.cs | 17 ++++++++ 5 files changed, 123 insertions(+) create mode 100644 EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactCreate.cs create mode 100644 EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPMCreateExtension.cs create mode 100644 EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPPCreateExtension.cs create mode 100644 EppLib/Extensions/Smallregistry/SmallregistryExtensionBase.cs diff --git a/EppLib/EppLib.csproj b/EppLib/EppLib.csproj index fa9170b..0adb488 100644 --- a/EppLib/EppLib.csproj +++ b/EppLib/EppLib.csproj @@ -164,6 +164,10 @@ + + + + diff --git a/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactCreate.cs b/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactCreate.cs new file mode 100644 index 0000000..3cc7ff6 --- /dev/null +++ b/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactCreate.cs @@ -0,0 +1,43 @@ +using EppLib.Entities; +using System; +using System.Xml; + +namespace EppLib.Extensions.Smallregistry.ContactCreate +{ + public class SmallregistryContactCreate : Entities.ContactCreate + { + public string CompanySerial { get; set; } + public DateTime BirthDate { get; set; } + public string BirthPlace { get; set; } + public SmallregistryContactCreate(Contact contact) : base(contact) + { + + } + + public override XmlDocument ToXml() + { + if (CompanySerial != null) + { + var createExt = new SmallregistryContactPMCreateExtension + { + CompanySerial = CompanySerial + }; + + Extensions.Clear(); + Extensions.Add(createExt); + } + else + { + var createExt = new SmallregistryContactPPCreateExtension + { + BirthDate = BirthDate, + BirthPlace = BirthPlace + }; + + Extensions.Clear(); + Extensions.Add(createExt); + } + return base.ToXml(); + } + } +} diff --git a/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPMCreateExtension.cs b/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPMCreateExtension.cs new file mode 100644 index 0000000..c7e0a37 --- /dev/null +++ b/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPMCreateExtension.cs @@ -0,0 +1,26 @@ +using System.Xml; + +namespace EppLib.Extensions.Smallregistry.ContactCreate +{ + public class SmallregistryContactPMCreateExtension : SmallregistryExtensionBase + { + public string CompanySerial { get; set; } + public override XmlNode ToXml(XmlDocument doc) + { + var root = CreateElement(doc, "ext"); + + var create = AddXmlElement(doc, root, "create", null); + + var contact = AddXmlElement(doc, create, "contact", null); + + var org = AddXmlElement(doc, contact, "org", null); + + if (CompanySerial != null) + { + AddXmlElement(doc, org, "companySerial", CompanySerial); + } + + return root; + } + } +} diff --git a/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPPCreateExtension.cs b/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPPCreateExtension.cs new file mode 100644 index 0000000..990090e --- /dev/null +++ b/EppLib/Extensions/Smallregistry/ContactCreate/SmallregistryContactPPCreateExtension.cs @@ -0,0 +1,33 @@ +using System; +using System.Xml; + +namespace EppLib.Extensions.Smallregistry +{ + public class SmallregistryContactPPCreateExtension : SmallregistryExtensionBase + { + public DateTime BirthDate { get; set; } + public string BirthPlace { get; set; } + public override XmlNode ToXml(XmlDocument doc) + { + var root = CreateElement(doc, "ext"); + + var create = AddXmlElement(doc, root, "create", null); + + var contact = AddXmlElement(doc, create, "contact", null); + + var person = AddXmlElement(doc, contact, "person", null); + + if (BirthDate != null) + { + AddXmlElement(doc, person, "birthDate", BirthDate.ToString("yyyy-MM-dd")); + } + + if (BirthPlace != null) + { + AddXmlElement(doc, person, "birthPlace", BirthPlace); + } + + return root; + } + } +} diff --git a/EppLib/Extensions/Smallregistry/SmallregistryExtensionBase.cs b/EppLib/Extensions/Smallregistry/SmallregistryExtensionBase.cs new file mode 100644 index 0000000..e9c21d2 --- /dev/null +++ b/EppLib/Extensions/Smallregistry/SmallregistryExtensionBase.cs @@ -0,0 +1,17 @@ +using EppLib.Entities; + +namespace EppLib.Extensions.Smallregistry +{ + /// + /// Base class for registry : smallregistry + /// + public abstract class SmallregistryExtensionBase : EppExtension + { + private string _ns = "https://www.smallregistry.net/schemas/sr-1.0.xsd"; + protected override string Namespace + { + get { return _ns; } + set { _ns = value; } + } + } +} From 5826f631e37fcc010ab89add72c5d9add43d9814 Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Sat, 3 Aug 2019 11:27:56 -0400 Subject: [PATCH 11/12] Update CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ca61e27..dcd1562 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -8,3 +8,4 @@ Elizabeth Young Paul Woodland Ross Pace Hogne Vevle +Laurent Signorel From dea6e0a5ad980bf4e8ec63ceedeed5b6718d9da2 Mon Sep 17 00:00:00 2001 From: vdm Date: Thu, 3 Oct 2019 12:33:54 +0200 Subject: [PATCH 12/12] Abstracted away connection & read/write implementation --- EppLib/EppLib.csproj | 1 + EppLib/ITransport.cs | 35 +++++++++++++++++++++++++++++++++++ EppLib/Service.cs | 4 ++-- EppLib/TcpTransport.cs | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 EppLib/ITransport.cs diff --git a/EppLib/EppLib.csproj b/EppLib/EppLib.csproj index 0adb488..95cfc48 100644 --- a/EppLib/EppLib.csproj +++ b/EppLib/EppLib.csproj @@ -168,6 +168,7 @@ + diff --git a/EppLib/ITransport.cs b/EppLib/ITransport.cs new file mode 100644 index 0000000..098cd27 --- /dev/null +++ b/EppLib/ITransport.cs @@ -0,0 +1,35 @@ +// Copyright 2012 Code Maker Inc. (http://codemaker.net) +// +// 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. +using System; +using System.Xml; +/**/ +using System.Security.Authentication; + + +/* +using OpenSSL; +using OpenSSL.Core; +using OpenSSL.X509;*/ + + +namespace EppLib +{ + public interface ITransport : IDisposable + { + void Connect(SslProtocols sslProtocols = SslProtocols.Tls); + void Disconnect(); + void Write(XmlDocument xmlDocument); + byte[] Read(); + } +} diff --git a/EppLib/Service.cs b/EppLib/Service.cs index 639fa86..45e980c 100755 --- a/EppLib/Service.cs +++ b/EppLib/Service.cs @@ -23,9 +23,9 @@ namespace EppLib /// public class Service { - private readonly TcpTransport transport; + private readonly ITransport transport; - public Service(TcpTransport transport) + public Service(ITransport transport) { this.transport = transport; } diff --git a/EppLib/TcpTransport.cs b/EppLib/TcpTransport.cs index 2e65f2e..1cf0efa 100755 --- a/EppLib/TcpTransport.cs +++ b/EppLib/TcpTransport.cs @@ -34,7 +34,7 @@ namespace EppLib /// /// Encapsulates the TCP transport /// - public class TcpTransport : IDisposable + public class TcpTransport : ITransport { private SslStream stream;