public async Task Returns_Success_With_DNS_Records_When_Successfully_Retrieved()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            List <GoDaddyGetDNSRecordResponse> records = new List <GoDaddyGetDNSRecordResponse>()
            {
                CreateValidGoDaddyGetDNSRecordResponse(1),
                CreateValidGoDaddyGetDNSRecordResponse(2),
                CreateValidGoDaddyGetDNSRecordResponse(3)
            };

            GoDaddyGetDNSRecordsResponse clientResponse = new GoDaddyGetDNSRecordsResponse(records);

            A.CallTo(() => fakeClient.GetDNSRecordsAsync(A <GoDaddyGetDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok(clientResponse));
            GoDaddyDNSRecordReader       reader             = new GoDaddyDNSRecordReader(fakeClient, _mapper);
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result <DNSRecordCollection> result = await reader.ReadAsync(string.Empty, authicationDetails, CancellationToken.None);

            DNSRecord firstRecord = result.Value.First();

            Assert.True(result.IsSuccess);
            Assert.Equal(3, result.Value.Count);

            Assert.Equal("Data-1", firstRecord.Data);
            Assert.Equal("Name-1", firstRecord.Name);
            Assert.Equal(1, firstRecord.Port);
        }
        public async Task Returns_Failure_When_Getting_Record_Fails()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            A.CallTo(() => fakeClient.GetDNSRecordsAsync(A <GoDaddyGetDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("failed"));

            GoDaddyDNSRecordReader       reader             = new GoDaddyDNSRecordReader(fakeClient, _mapper);
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result <DNSRecordCollection> result = await reader.ReadAsync(string.Empty, authicationDetails, CancellationToken.None);

            Assert.True(result.IsFailed);
        }
Exemple #3
0
        public async Task Returns_Success_When_All_Records_Update()
        {
            IGoDaddyClient client = A.Fake <IGoDaddyClient>();

            A.CallTo(() => client.UpdateDNSRecordAsync(A <GoDaddyUpdateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok());

            GoDaddyDNSRecordUpdater      updater            = new GoDaddyDNSRecordUpdater(client, _mapper);
            DNSRecordCollection          records            = new DNSRecordCollection(CreateValidDNSRecord(1), CreateValidDNSRecord(2));
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result result = await updater.UpdateAsync("aDomain.com", records, authicationDetails, CancellationToken.None);

            Assert.True(result.IsSuccess);
        }
Exemple #4
0
        public async Task No_Records_Are_Successfully_Created_If_Client_Fails()
        {
            IGoDaddyClient client = A.Fake <IGoDaddyClient>();

            A.CallTo(() => client.UpdateDNSRecordAsync(A <GoDaddyUpdateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("Error"));

            GoDaddyDNSRecordUpdater      updater            = new GoDaddyDNSRecordUpdater(client, _mapper);
            DNSRecordCollection          records            = new DNSRecordCollection(CreateValidDNSRecord(1), CreateValidDNSRecord(2));
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails("apiKey", "apiSecret");

            Result result = await updater.UpdateAsync("aDomain.com", records, authicationDetails, CancellationToken.None);

            Assert.True(result.IsFailed);
            Assert.Equal(2, result.Errors.Count);
        }
Exemple #5
0
        public async Task No_Records_Are_Successfully_Created_Returns_Failure()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            A.CallTo(() => fakeClient.CreateDNSRecordsAsync(A <GoDaddyCreateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Fail("oops"));

            GoDaddyDNSRecordCreator creator    = new GoDaddyDNSRecordCreator(fakeClient, _mapper);
            DNSRecordCollection     dnsRecords = new DNSRecordCollection(
                new DNSRecord
            {
                Type = DNSRecordType.A
            },
                new DNSRecord
            {
                Type = DNSRecordType.A
            });
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails(string.Empty, string.Empty);

            Result result = await creator.CreateAsync(string.Empty, dnsRecords, authicationDetails, CancellationToken.None);

            Assert.True(result.IsFailed);
        }
Exemple #6
0
        public async Task Records_Are_Created_And_Successful_Result_Returned()
        {
            IGoDaddyClient fakeClient = A.Fake <IGoDaddyClient>();

            A.CallTo(() => fakeClient.CreateDNSRecordsAsync(A <GoDaddyCreateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).Returns(Result.Ok());

            GoDaddyDNSRecordCreator creator    = new GoDaddyDNSRecordCreator(fakeClient, _mapper);
            DNSRecordCollection     dnsRecords = new DNSRecordCollection(
                new DNSRecord
            {
                Type = DNSRecordType.A
            },
                new DNSRecord
            {
                Type = DNSRecordType.A
            });
            GoDaddyAuthenticationDetails authicationDetails = new GoDaddyAuthenticationDetails(string.Empty, string.Empty);

            Result result = await creator.CreateAsync(string.Empty, dnsRecords, authicationDetails, CancellationToken.None);

            Assert.True(result.IsSuccess);
            A.CallTo(() => fakeClient.CreateDNSRecordsAsync(A <GoDaddyCreateDNSRecordsRequest> .Ignored, A <CancellationToken> .Ignored)).MustHaveHappenedOnceExactly();
        }
 public GoDaddyDNSRecordReader(IGoDaddyClient client, IMapper mapper)
 {
     _client = client;
     _mapper = mapper;
 }
 public UpdateRecordCommand(string shopperId, string key, string secret)
 {
     _goDaddyClient = ClientFactory.CreateGoDaddyClient(shopperId, key, secret);
 }