/// <summary> /// Create an class wrapping a DNS record /// </summary> /// <param name="domain"></param> /// <param name="recordType"></param> /// <param name="target"></param> /// <param name="ttl"></param> public DNSRecord(string domain, DNSRecordType recordType, string target, TimeSpan ttl) { _host = domain; _ttl = ttl; _target = target; _recordType = recordType; }
public GoDaddyGetDNSRecordsRequest(string apiKey, string apiSecret, DNSRecordType dnsRecordType, string domainName) { ApiKey = apiKey; ApiSecret = apiSecret; DNSRecordType = dnsRecordType; DomainName = domainName; }
public void Mutate_WhenRecordTypeMutation_ReturnsOnlyRecordType(DNSRecordType dnsRecordType) { DNSRecordCollection dnsRecords = GetDNSRecords(); IDNSRecordCollectionMutator mutator = new DNSRecordCollectionMutator(); DNSRecordCollection mudatedDnsRecords = mutator.Mutate(dnsRecords, new WithRecordType(dnsRecordType)); Assert.DoesNotContain(mudatedDnsRecords, d => d.Type != dnsRecordType); }
/// <summary> /// Create an class wrapping a DNS record /// </summary> /// <param name="wmiObject"></param> public DNSRecord(ManagementObject wmiObject) { _wmiObject = wmiObject; _host = wmiObject["OwnerName"].ToString(); _target = wmiObject["RecordData"].ToString(); string[] recordParts = wmiObject["TextRepresentation"].ToString().Split(' ', '\t'); if (recordParts.Length > 2) { //the third offset is the location in the textual version of the data where the record type is. //counting from zero that is location 2 in the array. _recordType = new DNSRecordType(recordParts[2]); } _ttl = new TimeSpan(0, 0, Convert.ToInt32(wmiObject["TTL"])); }
public DNSRecord Convert(GoDaddyGetDNSRecordResponse source, DNSRecord?dnsRecord, ResolutionContext context) { dnsRecord ??= new DNSRecord(); dnsRecord.Data = source.Data; dnsRecord.Name = source.Name; dnsRecord.Port = source.Port; dnsRecord.Priority = source.Priority; dnsRecord.TTL = source.Ttl; dnsRecord.Type = DNSRecordType.FromValue(source.Type); dnsRecord.Weight = source.Weight; return(dnsRecord); }
public GoDaddyUpdateDNSRecordsRequest( string apiKey, string apiSecret, string domainName, DNSRecordType recordType, string recordName, GoDaddyUpdateDNSRecord record) { ApiKey = apiKey; ApiSecret = apiSecret; DomainName = domainName; Record = record; RecordName = recordName; RecordType = recordType; }
public DNSRecord Convert(DigitalOceanGetDomainRecordResponse response, DNSRecord?record, ResolutionContext context) { record ??= new DNSRecord(); record.Data = response.Data; record.Flags = response.Flags; record.Id = response.Id.ToString(); record.Name = response.Name; record.Port = response.Port; record.Priority = response.Priority; record.Tag = response.Tag; record.TTL = response.Ttl; record.Type = DNSRecordType.FromValue(response.Type); record.Weight = response.Weight; return(record); }
public async Task Record_Is_Successfully_Retrieved() { string ipAddress = "100.100.100.100"; string name = "test"; int TTL = 1800; DNSRecordType type = DNSRecordType.A; DigitalOceanDomain domain = new DigitalOceanDomain(); DigitalOceanGetDomainRecordsResponse clientResponse = new DigitalOceanGetDomainRecordsResponse { DomainRecords = new List <DigitalOceanGetDomainRecordResponse> { new DigitalOceanGetDomainRecordResponse { Data = ipAddress, Name = name, Ttl = TTL, Type = type } } }; Result <DigitalOceanGetDomainRecordsResponse> clientResponeResult = Result.Ok(clientResponse); IDigitalOceanClient client = A.Fake <IDigitalOceanClient>(); IDigitalOceanDNSRecordReader reader = new DigitalOceanDNSRecordReader(client, _mappingHelper.Mapper); A.CallTo(() => client.GetDNSRecordsAsync(A <DigitalOceanDomain> .Ignored, A <string> .Ignored, A <CancellationToken> .Ignored)).Returns(clientResponeResult); Result <DNSRecordCollection> result = await reader.ReadAsync(domain, string.Empty, CancellationToken.None); Assert.True(result.IsSuccess); DNSRecordCollection dnsRecords = result.Value; Assert.True(dnsRecords.Count == 1); DNSRecord dnsRecord = result.Value.First(); Assert.Equal(dnsRecord.Data, ipAddress); Assert.Equal(dnsRecord.Name, name); Assert.Equal(dnsRecord.TTL, TTL); Assert.Equal(dnsRecord.Type, type); }
/// <summary> /// Create an class wrapping a DNS record /// Defaults to 1 hour TTL /// </summary> /// <param name="domain"></param> /// <param name="recordType"></param> /// <param name="target"></param> public DNSRecord(string domain, DNSRecordType recordType, string target) : this(domain, recordType, target, new TimeSpan(1, 0, 0)) { }
/// <summary> /// Create an class wrapping a DNS record /// </summary> /// <param name="wmiObject"></param> public DNSRecord(ManagementObject wmiObject) { _wmiObject = wmiObject; _host = wmiObject["OwnerName"].ToString(); _target = wmiObject["RecordData"].ToString(); string[] recordParts = wmiObject["TextRepresentation"].ToString().Split(' ', '\t'); if (recordParts.Length > 2) { //the third offset is the location in the textual version of the data where the record type is. //counting from zero that is location 2 in the array. _recordType = new DNSRecordType(recordParts[2]); } _ttl = new TimeSpan(0, 0, Convert.ToInt32(wmiObject["TTL"])); }
/// <summary> /// Create an class wrapping a DNS record /// </summary> /// <param name="domain"></param> /// <param name="recordType"></param> /// <param name="target"></param> /// <param name="ttl"></param> public DNSRecord(string domain, DNSRecordType recordType, string target, TimeSpan ttl) { _host = domain; _ttl = ttl; _target = target; _recordType = recordType; }
/// <summary> /// Create an class wrapping a DNS record /// Defaults to 1 hour TTL /// </summary> /// <param name="domain"></param> /// <param name="recordType"></param> /// <param name="target"></param> public DNSRecord(string domain, DNSRecordType recordType, string target) : this(domain, recordType, target, new TimeSpan(1, 0, 0)) { }
public WithRecordType(DNSRecordType dnsRecordType) { _dnsRecordType = dnsRecordType; }