Esempio n. 1
0
        public async Task NoDifferenceInRecordsRecordIsReturned()
        {
            MxRecordTlsSecurityProfile mxRecordTlsSecurityProfile1 = CreateTlsSecurityProfile();

            A.CallTo(() => _tlsSecurityTester.Test(mxRecordTlsSecurityProfile1))
            .Returns(Task.FromResult(mxRecordTlsSecurityProfile1));

            List <DomainTlsSecurityProfile> securityProfiles = await _tlsSecurityProfileUpdater.UpdateSecurityProfiles(
                new List <DomainTlsSecurityProfile>
            {
                new DomainTlsSecurityProfile(new Domain(1, "domain"),
                                             new List <MxRecordTlsSecurityProfile> {
                    mxRecordTlsSecurityProfile1
                })
            });

            Assert.That(securityProfiles[0].Profiles.Count, Is.EqualTo(1));
            Assert.That(securityProfiles[0].Profiles.First(), Is.EqualTo(mxRecordTlsSecurityProfile1));
        }
Esempio n. 2
0
        private async Task <List <MxRecordTlsSecurityProfile> > UpdateMxSecurityProfile(MxRecordTlsSecurityProfile mxRecordTlsSecurityProfile)
        {
            MxRecordTlsSecurityProfile updatedSecurityProfile = await _tlsSecurityTester.Test(mxRecordTlsSecurityProfile);

            bool recordUnchanged = mxRecordTlsSecurityProfile.TlsSecurityProfile.TlsResults.Equals(updatedSecurityProfile.TlsSecurityProfile.TlsResults);
            bool newRecord       = !mxRecordTlsSecurityProfile.TlsSecurityProfile.Id.HasValue;

            _log.Debug($"Updated tls profile (mx record id:{mxRecordTlsSecurityProfile.MxRecord.Id}, " +
                       $"tls profile id:{mxRecordTlsSecurityProfile.TlsSecurityProfile.Id?.ToString() ?? "null"}) " +
                       $"record changed: {!recordUnchanged}, new record: {newRecord}");

            return(recordUnchanged || newRecord
                ? new List <MxRecordTlsSecurityProfile> {
                updatedSecurityProfile
            }
                : new List <MxRecordTlsSecurityProfile> {
                CreateExpiredRecord(mxRecordTlsSecurityProfile), CreateNewRecord(updatedSecurityProfile)
            });
        }