Пример #1
0
        public void UpdateZoneRecord(long accountId, string zoneId,
                                     long recordId, string expectedUrl)
        {
            var client = new MockDnsimpleClient(UpdateZoneRecordFixture);
            var data   = new ZoneRecord
            {
                Name     = "",
                Content  = "mxb.example.com",
                Ttl      = 3600,
                Priority = 20
            };

            var record =
                client.Zones.UpdateRecord(accountId, zoneId, recordId, data)
                .Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(recordId, record.Id);
                Assert.AreEqual(zoneId, record.ZoneId);
                Assert.IsNull(record.ParentId);
                Assert.IsEmpty(record.Name);
                Assert.AreEqual("mxb.example.com", record.Content);
                Assert.AreEqual(3600, record.Ttl);
                Assert.AreEqual(20, record.Priority);
                Assert.AreEqual(ZoneRecordType.MX, record.Type);
                Assert.Contains("global", record.Regions);
                Assert.IsFalse(record.SystemRecord);

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.PATCH, client.HttpMethodUsed());
            });
        }
Пример #2
0
        public void PurchaseLetsEncryptCertificateRenewal(long accountId,
                                                          string domainName, long certificateId, string expectedUrl)
        {
            var client =
                new MockDnsimpleClient(
                    PurchaseRenewalLetsEncryptCertificateFixture);
            var certificateAttributes = new LetsencryptCertificateAttributes
            {
                AutoRenew = false
            };
            var renewalPurchased =
                client.Certificates.PurchaseLetsEncryptCertificateRenewal(
                    accountId, domainName, certificateId, certificateAttributes).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(65082, renewalPurchased.Id);
                Assert.AreEqual(101967, renewalPurchased.OldCertificateId);
                Assert.AreEqual(101972, renewalPurchased.NewCertificateId);
                Assert.AreEqual("new", renewalPurchased.State);
                Assert.IsFalse(renewalPurchased.AutoRenew);
                Assert.AreEqual(Convert.ToDateTime("2020-06-18T19:56:20Z"), renewalPurchased.CreatedAt);
                Assert.AreEqual(Convert.ToDateTime("2020-06-18T19:56:20Z"), renewalPurchased.UpdatedAt);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #3
0
        public void CreateZoneRecord(string fixture, long accountId,
                                     string name, string expectedUrl)
        {
            var client = new MockDnsimpleClient(fixture);

            var record = new ZoneRecord
            {
                Name    = name,
                Type    = ZoneRecordType.A,
                Content = "127.0.0.1",
                Ttl     = 600,
            };

            var created = client.Zones
                          .CreateRecord(accountId, "example.com", record)
                          .Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(1, created.Id);
                Assert.AreEqual("example.com", created.ZoneId);
                Assert.AreEqual(name, created.Name);
                Assert.AreEqual("127.0.0.1", created.Content);
                Assert.AreEqual(600, created.Ttl);
                Assert.AreEqual(ZoneRecordType.A, created.Type);
                Assert.Contains("global", created.Regions);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #4
0
        public void GetZoneRecord(long accountId, string zoneId, long recordId,
                                  string expectedUrl)
        {
            var client = new MockDnsimpleClient(GetZoneRecordFixture);
            var record = client.Zones.GetRecord(accountId, zoneId, recordId)
                         .Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(recordId, record.Id);
                Assert.AreEqual(zoneId, record.ZoneId);
                Assert.IsNull(record.ParentId);
                Assert.IsEmpty(record.Name);
                Assert.AreEqual("mxa.example.com", record.Content);
                Assert.AreEqual(600, record.Ttl);
                Assert.AreEqual(10, record.Priority);
                Assert.AreEqual(ZoneRecordType.MX, record.Type);
                Assert.Contains("SV1", record.Regions);
                Assert.Contains("IAD", record.Regions);
                Assert.IsFalse(record.SystemRecord);

                Assert.AreEqual(Method.GET, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
        public void ChangeDomainDelegationToVanity(long accountId, string domain, string expectedUrl)
        {
            var client     = new MockDnsimpleClient(ChangeDomainDelegationToVanityFixture);
            var delegation = new List <string>
            {
                "ns1.dnsimple.com", "ns2.dnsimple.com"
            };

            var vanityDelegation =
                client.Registrar.ChangeDomainDelegationToVanity(accountId,
                                                                domain, delegation).Data.Delegations;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(2, vanityDelegation.Count);

                Assert.AreEqual(1, vanityDelegation.First().Id);
                Assert.AreEqual("ns1.example.com", vanityDelegation.First().Name);
                Assert.AreEqual("127.0.0.1", vanityDelegation.First().Ipv4);
                Assert.AreEqual("::1", vanityDelegation.First().Ipv6);
                Assert.AreEqual(CreatedAt, vanityDelegation.First().CreatedAt);
                Assert.AreEqual(UpdatedAt, vanityDelegation.First().UpdatedAt);

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.PUT, client.HttpMethodUsed());
            });
        }
Пример #6
0
        public void CreateTemplateRecord(long accountId, string template, string expectedUrl)
        {
            var client         = new MockDnsimpleClient(CreateTemplateRecordFixture);
            var templateRecord = new TemplateRecord
            {
                Name     = "",
                Type     = "MX",
                Content  = "mx.example.com",
                Ttl      = 600,
                Priority = 10
            };

            var record =
                client.Templates.CreateTemplateRecord(accountId, template,
                                                      templateRecord).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(300, record.Id);
                Assert.AreEqual(268, record.TemplateId);
                Assert.AreEqual(templateRecord.Name, record.Name);
                Assert.AreEqual(templateRecord.Type, record.Type);
                Assert.AreEqual(templateRecord.Content, record.Content);
                Assert.AreEqual(templateRecord.Ttl, record.Ttl);
                Assert.AreEqual(templateRecord.Priority, record.Priority);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #7
0
        public void PurchaseLetsEncryptCertificate(long accountId,
                                                   string domainName, string expectedUrl)
        {
            var client =
                new MockDnsimpleClient(PurchaseLetsEncryptCertificateFixture);
            var certificatePurchase = new CertificateOrder
            {
                ContactId      = 11,
                AutoRenew      = false,
                Name           = "SuperCertificate",
                AlternateNames = new List <string>
                {
                    "docs.rubycodes.com", "status.rubycodes.com"
                }
            };

            var certificateOrdered =
                client.Certificates.PurchaseLetsEncryptCertificate(accountId,
                                                                   domainName, certificatePurchase).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(300, certificateOrdered.Id);
                Assert.AreEqual(300, certificateOrdered.CertificateId);
                Assert.AreEqual("requesting", certificateOrdered.State);
                Assert.IsFalse(certificateOrdered.AutoRenew);
                Assert.AreEqual(LetsEncryptCreatedAt,
                                certificateOrdered.CreatedAt);
                Assert.AreEqual(LetsEncryptUpdatedAt,
                                certificateOrdered.UpdatedAt);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #8
0
        public void CreateTemplate(long accountId, string expectedUrl)
        {
            var client       = new MockDnsimpleClient(CreateTemplateFixture);
            var templateData = new Template
            {
                Name        = "Beta",
                Sid         = "beta",
                Description = "A beta template."
            };

            var template =
                client.Templates.CreateTemplate(accountId, templateData).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(1, template.Id);
                Assert.AreEqual(accountId, template.AccountId);
                Assert.AreEqual(templateData.Name, template.Name);
                Assert.AreEqual(templateData.Sid, template.Sid);
                Assert.AreEqual(templateData.Description, template.Description);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #9
0
        public void IssueLetsEncryptCertificateRenewal(long accountId,
                                                       string domainName, long certificateId, long certificateRenewalId,
                                                       string expectedUrl)
        {
            var client =
                new MockDnsimpleClient(
                    IssueRenewalLetsEncryptCertificateFixture);
            var renewalIssued =
                client.Certificates.IssueLetsEncryptCertificateRenewal(
                    accountId, domainName, certificateId,
                    certificateRenewalId)
                .Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(101972, renewalIssued.Id);
                Assert.AreEqual(289333, renewalIssued.DomainId);
                Assert.AreEqual(2511, renewalIssued.ContactId);
                Assert.AreEqual("www.bingo.pizza", renewalIssued.CommonName);
                Assert.AreEqual(1, renewalIssued.Years);
                Assert.IsNull(renewalIssued.Csr);
                Assert.AreEqual("requesting", renewalIssued.State);
                Assert.IsFalse(renewalIssued.AutoRenew);
                CollectionAssert.IsEmpty(renewalIssued.AlternateNames);
                Assert.AreEqual("letsencrypt", renewalIssued.AuthorityIdentifier);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #10
0
        public void CreateContact(long accountId, string expectedUrl)
        {
            var client  = new MockDnsimpleClient(CreateContactFixture);
            var contact = new Contact
            {
                FirstName     = "First",
                LastName      = "User",
                Address1      = "Italian Street, 10",
                City          = "Roma",
                StateProvince = "RM",
                PostalCode    = "00100",
                Country       = "IT",
                Email         = "*****@*****.**",
                Phone         = "+18001234567",
                Fax           = "+18011234567"
            };

            var created =
                client.Contacts.CreateContact(accountId, contact).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(1, created.Id);
                Assert.AreEqual(contact.Email, created.Email);

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
            });
        }
Пример #11
0
        public void PurchaseLetsEncryptCertificate(long accountId,
                                                   string domainName, string expectedUrl)
        {
            var client =
                new MockDnsimpleClient(PurchaseLetsEncryptCertificateFixture);
            var certificateAttributes = new LetsencryptCertificateAttributes
            {
                ContactId      = 11,
                AutoRenew      = false,
                Name           = "SuperCertificate",
                AlternateNames = new List <string> {
                    "docs.bingo.pizza", "status.bingo.pizza"
                }
            };

            var certificateOrdered =
                client.Certificates.PurchaseLetsEncryptCertificate(accountId,
                                                                   domainName, certificateAttributes).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(101967, certificateOrdered.Id);
                Assert.AreEqual(101967, certificateOrdered.CertificateId);
                Assert.AreEqual("new", certificateOrdered.State);
                Assert.IsFalse(certificateOrdered.AutoRenew);
                Assert.AreEqual(Convert.ToDateTime("2020-06-18T18:54:17Z"), certificateOrdered.CreatedAt);
                Assert.AreEqual(Convert.ToDateTime("2020-06-18T18:54:17Z"), certificateOrdered.UpdatedAt);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #12
0
        public void DeleteWebhook(long accountId, long webhookId, string expectedUrl)
        {
            var client = new MockDnsimpleClient(DeleteWebhookFixture);

            client.Webhooks.DeleteWebhook(accountId, webhookId);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #13
0
        public void UnapplyService(long accountId, string domain, string service, string expectedUrl)
        {
            var client = new MockDnsimpleClient(UnapplyServiceFixture);

            client.Services.UnapplyService(accountId, domain, service);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #14
0
        public void DeleteTemplate(long accountId, string template, string expectedUrl)
        {
            var client = new MockDnsimpleClient(DeleteTemplateFixture);

            client.Templates.DeleteTemplate(accountId, template);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #15
0
        public void ApplyTemplate(long accountId, string domain, string template, string expectedUrl)
        {
            var client = new MockDnsimpleClient(ApplyTemplateFixture);

            client.Templates.ApplyTemplate(accountId, domain, template);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #16
0
        public void DisableVanityNameServers(long accountId, string domain, string expectedUrl)
        {
            var client = new MockDnsimpleClient(DisableVanityNameServersFixture);

            client.VanityNameServers.DisableVanityNameServers(accountId,
                                                              domain);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
        public void DisableDomainAutoRenewal(long accountId, string domain, string expectedUrl)
        {
            var client = new MockDnsimpleClient(DisableDomainAutoRenewalFixture);

            Assert.Multiple(() =>
            {
                Assert.DoesNotThrow(delegate
                {
                    client.Registrar.DisableDomainAutoRenewal(accountId, domain);
                });
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
            });
        }
        public void EnableWhoisPrivacy(long accountId, string domain, string expectedUrl)
        {
            var client = new MockDnsimpleClient(EnableWhoisPrivacyFixture);

            var privacy =
                client.Registrar.EnableWhoisPrivacy(accountId, domain).Data;

            Assert.Multiple(() =>
            {
                Assert.IsTrue(privacy.Enabled);

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.PUT, client.HttpMethodUsed());
            });
        }
Пример #19
0
        public void DeleteContact(long accountId, long contactId, string expectedUrl)
        {
            var client = new MockDnsimpleClient(DeleteContactFixture);

            Assert.Multiple(() =>
            {
                Assert.DoesNotThrow(delegate
                {
                    client.Contacts.DeleteContact(accountId, contactId);
                });

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
            });
        }
Пример #20
0
        public void DeleteRecord(long accountId, string zoneId, long recordId,
                                 string expectedUrl)
        {
            var client = new MockDnsimpleClient(DeleteZoneRecordFixture);

            Assert.Multiple(() =>
            {
                Assert.DoesNotThrow(delegate
                {
                    client.Zones.DeleteRecord(accountId, zoneId, recordId);
                });

                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #21
0
        public void EnableVanityNameServers(long accountId, string domain,
                                            string expectedUrl)
        {
            var client            = new MockDnsimpleClient(EnableVanityNameServersFixture);
            var vanityNameServers =
                client.VanityNameServers.EnableVanityNameServers(accountId,
                                                                 domain).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(4, vanityNameServers.Count);

                Assert.AreEqual(Method.PUT, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
Пример #22
0
        public void UpdateTemplate(long accountId, string template, string expectedUrl)
        {
            var client = new MockDnsimpleClient(UpdateTemplateFixture);
            var update = new Template
            {
                Description = "An alpha template"
            };

            client.Templates.UpdateTemplate(accountId, template, update);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(Method.PATCH, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
        public void ChangeDomainDelegationFromVanity(long accountId, string domain, string expectedUrl)
        {
            var client = new MockDnsimpleClient(ChangeDomainDelegationFromVanityFixture);

            Assert.Multiple(() =>
            {
                Assert.DoesNotThrow(delegate
                {
                    client.Registrar.ChangeDomainDelegationFromVanity(
                        accountId, domain);
                });

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.DELETE, client.HttpMethodUsed());
            });
        }
Пример #24
0
        public void CreateWebhook(long accountId, string expectedUrl)
        {
            var client = new MockDnsimpleClient(CreateWebhookFixture);
            var hook   = new Webhook {
                Url = "https://webhook.test"
            };
            var created = client.Webhooks.CreateWebhook(accountId, hook).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(hook.Url, created.Url);

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
                Assert.AreEqual(expectedUrl, client.RequestSentTo());
            });
        }
        public void RenewWhoisPrivacyDuplicatedOrder(long accountId,
                                                     string domain)
        {
            var client = new MockDnsimpleClient(WhoisPrivacyNotFoundFixture);

            client.StatusCode(HttpStatusCode.BadRequest);

            Assert.Multiple(() =>
            {
                Assert.Throws(
                    Is.TypeOf <DnsimpleValidationException>().And.Message.EqualTo("WHOIS privacy not found for example.com"),
                    delegate
                {
                    client.Registrar.RenewWhoisPrivacy(accountId, domain);
                });

                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
            });
        }
Пример #26
0
        public void UpdateContact(long accountId, long contactId, string expectedUrl)
        {
            var client  = new MockDnsimpleClient(UpdateContactFixture);
            var contact = new Contact
            {
                Email = "*****@*****.**"
            };

            var updated = client.Contacts.UpdateContact(accountId, contactId, contact).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(contactId, updated.Id);
                Assert.AreEqual(accountId, updated.AccountId);

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.PATCH, client.HttpMethodUsed());
            });
        }
        public void RenewWhoisPrivacyDuplicatedOrder(long accountId,
                                                     string domain, string expectedUrl)
        {
            var client = new MockDnsimpleClient(WhoisPrivacyDuplicatedOrderFixture);

            client.StatusCode(HttpStatusCode.BadRequest);

            Assert.Multiple(() =>
            {
                Assert.Throws(
                    Is.TypeOf <DnsimpleValidationException>().And.Message.EqualTo("The whois privacy for example.com has just been renewed, a new renewal cannot be started at this time"),
                    delegate
                {
                    client.Registrar.RenewWhoisPrivacy(accountId, domain);
                });

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
            });
        }
        public void RenewWhoisPrivacy(long accountId, string domain, string expectedUrl)
        {
            var client = new MockDnsimpleClient(RenewWhoisPrivacyFixture);

            var renewedDomain =
                client.Registrar.RenewWhoisPrivacy(accountId, domain).Data;

            Assert.Multiple(() =>
            {
                Assert.AreEqual(1, renewedDomain.Id);
                Assert.AreEqual(100, renewedDomain.DomainId);
                Assert.AreEqual(999, renewedDomain.WhoisPrivacyId);
                Assert.AreEqual("new", renewedDomain.State);
                Assert.AreEqual(RenewalExpiresOn, renewedDomain.ExpiresOn);
                Assert.IsTrue(renewedDomain.Enabled);
                Assert.AreEqual(RenewalCreatedAt, renewedDomain.CreatedAt);
                Assert.AreEqual(RenewalUpdatedAt, renewedDomain.UpdatedAt);

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.POST, client.HttpMethodUsed());
            });
        }
        public void ChangeDomainDelegation(long accountId, string domain,
                                           string expectedUrl)
        {
            var client = new MockDnsimpleClient(ChangeDomainDelegationFixture);

            var delegation = new List <string>
            {
                "ns1.dnsimple.com", "ns2.dnsimple.com", "ns3.dnsimple.com",
                "ns4.dnsimple.com"
            };

            var newDelegation = client.Registrar.ChangeDomainDelegation(
                accountId, domain,
                delegation);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(delegation, newDelegation.Data);

                Assert.AreEqual(expectedUrl, client.RequestSentTo());
                Assert.AreEqual(Method.PUT, client.HttpMethodUsed());
            });
        }