/// <summary> /// Checks if the mechamism matches the current request. /// </summary> /// <returns>Match result</returns> public override async Task <SpfResult> Matches() { string Bak = this.term.domain; this.term.domain = this.Domain; try { KeyValuePair <SpfResult, string> Result = await SpfResolver.CheckHost(this.term, this.spfExpressions); switch (Result.Key) { case SpfResult.Pass: return(SpfResult.Pass); case SpfResult.Fail: case SpfResult.SoftFail: case SpfResult.Neutral: return(SpfResult.Fail); case SpfResult.TemporaryError: return(SpfResult.TemporaryError); case SpfResult.PermanentError: case SpfResult.None: default: return(SpfResult.PermanentError); } } finally { this.term.domain = Bak; } }
public override async Task <SpfResult> Matches() { string originalDomain = SpfStatement.Domain; SpfStatement.Domain = Domain; try { KeyValuePair <SpfResult, string> result = await SpfResolver.CheckHost(SpfStatement, _spfExpressions); switch (result.Key) { case SpfResult.Pass: return(SpfResult.Pass); case SpfResult.Fail: case SpfResult.SoftFail: case SpfResult.Neutral: return(SpfResult.Fail); case SpfResult.TemporaryError: return(SpfResult.TemporaryError); case SpfResult.PermanentError: case SpfResult.None: default: return(SpfResult.PermanentError); } } finally { SpfStatement.Domain = originalDomain; } }
public async Task should_get_correct_spf_result(string ipAddress, string domain, string sender, string heloDomain, string hostDomain, SpfResult expectedResult) { KeyValuePair <SpfResult, string> result = await SpfResolver.CheckHost(IPAddress.Parse(ipAddress), domain, sender, heloDomain, hostDomain); Assert.AreEqual(expectedResult, result.Key, result.Value); }
public async Task Test_01_SPF_Evaluation_1() { KeyValuePair <SpfResult, string> Result = await SpfResolver.CheckHost( IPAddress.Parse("194.9.95.112"), "littlesister.se", "*****@*****.**", "smtp.outgoing.loopia.se", "cybercity.online"); Assert.AreEqual(SpfResult.Pass, Result.Key, Result.Value); }
private async Task TestSpfString(string SpfString, string Domain, string Sender, IPAddress Address, string CallerHost, string Host) { KeyValuePair <SpfResult, string> Result = await SpfResolver.CheckHost( Address, Domain, Sender, CallerHost, Host, new SpfExpression(Domain, false, SpfString)); Assert.AreEqual(SpfResult.Pass, Result.Key, Result.Value); }