diff --git a/Vonage.Test/RedactTests.cs b/Vonage.Test/RedactTests.cs index adf506f1f..b947cc779 100644 --- a/Vonage.Test/RedactTests.cs +++ b/Vonage.Test/RedactTests.cs @@ -10,42 +10,6 @@ namespace Vonage.Test; [Trait("Category", "Legacy")] public class RedactTests : TestBase { - [Theory] - [InlineData(true, RedactionProduct.Sms, RedactionType.Inbound)] - [InlineData(false, RedactionProduct.Sms, RedactionType.Inbound)] - [InlineData(false, RedactionProduct.Sms, RedactionType.Outbound)] - [InlineData(false, RedactionProduct.Messages, RedactionType.Inbound)] - [InlineData(false, RedactionProduct.Messages, RedactionType.Outbound)] - [InlineData(false, RedactionProduct.NumberInsight, RedactionType.Inbound)] - [InlineData(false, RedactionProduct.NumberInsight, RedactionType.Outbound)] - [InlineData(false, RedactionProduct.Verify, RedactionType.Inbound)] - [InlineData(false, RedactionProduct.Verify, RedactionType.Outbound)] - [InlineData(false, RedactionProduct.VerifySdk, RedactionType.Inbound)] - [InlineData(false, RedactionProduct.VerifySdk, RedactionType.Outbound)] - [InlineData(false, RedactionProduct.Voice, RedactionType.Inbound)] - [InlineData(false, RedactionProduct.Voice, RedactionType.Outbound)] - public void Redact(bool passCredentials, RedactionProduct product, RedactionType type) - { - //ARRANGE - var request = new RedactRequest - { - Id = "test", - Product = product, - Type = type, - }; - var expectedResponseContent = this.GetResponseJson(); - var expectedUri = $"{this.ApiUrl}/v1/redact/transaction"; - this.Setup(expectedUri, expectedResponseContent); - - //ACT - var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); - var client = this.BuildVonageClient(creds); - var response = client.RedactClient.Redact(request, passCredentials ? creds : null); - - //ASSERT - Assert.True(response); - } - [Theory] [InlineData(true, RedactionProduct.Sms, RedactionType.Inbound)] [InlineData(false, RedactionProduct.Sms, RedactionType.Inbound)] @@ -83,7 +47,7 @@ public async Task RedactAsync(bool passCredentials, RedactionProduct product, Re } [Fact] - public void RedactReturns401() + public async Task RedactReturns401() { //ARRANGE var request = new RedactRequest @@ -99,7 +63,8 @@ public void RedactReturns401() //ACT var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); var client = this.BuildVonageClient(creds); - var exception = Assert.Throws(() => client.RedactClient.Redact(request)); + var exception = + await Assert.ThrowsAsync(() => client.RedactClient.RedactAsync(request)); //ASSERT Assert.NotNull(exception); @@ -107,7 +72,7 @@ public void RedactReturns401() } [Fact] - public void RedactReturns403() + public async Task RedactReturns403() { //ARRANGE var request = new RedactRequest @@ -123,7 +88,8 @@ public void RedactReturns403() //ACT var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); var client = this.BuildVonageClient(creds); - var exception = Assert.Throws(() => client.RedactClient.Redact(request)); + var exception = + await Assert.ThrowsAsync(() => client.RedactClient.RedactAsync(request)); //ASSERT Assert.NotNull(exception); @@ -131,7 +97,7 @@ public void RedactReturns403() } [Fact] - public void RedactReturns404() + public async Task RedactReturns404() { //ARRANGE var request = new RedactRequest @@ -147,16 +113,16 @@ public void RedactReturns404() //ACT var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); var client = this.BuildVonageClient(creds); - var exception = Assert.Throws(() => client.RedactClient.Redact(request)); + var exception = + await Assert.ThrowsAsync(() => client.RedactClient.RedactAsync(request)); //ASSERT Assert.NotNull(exception); Assert.Equal(expectedResponseContent, exception.Json); } -#if (NETCOREAPP2_1_OR_GREATER) [Fact] - public void RedactReturns422() + public async Task RedactReturns422() { //ARRANGE var request = new RedactRequest @@ -172,7 +138,8 @@ public void RedactReturns422() //ACT var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); var client = this.BuildVonageClient(creds); - var exception = Assert.Throws(() => client.RedactClient.Redact(request)); + var exception = + await Assert.ThrowsAsync(() => client.RedactClient.RedactAsync(request)); //ASSERT Assert.NotNull(exception); @@ -180,7 +147,7 @@ public void RedactReturns422() } [Fact] - public void RedactReturns429() + public async Task RedactReturns429() { //ARRANGE var request = new RedactRequest @@ -196,11 +163,11 @@ public void RedactReturns429() //ACT var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); var client = this.BuildVonageClient(creds); - var exception = Assert.Throws(() => client.RedactClient.Redact(request)); + var exception = + await Assert.ThrowsAsync(() => client.RedactClient.RedactAsync(request)); //ASSERT Assert.NotNull(exception); Assert.Equal(expectedResponseContent, exception.Json); } -#endif } \ No newline at end of file diff --git a/Vonage/Redaction/IRedactClient.cs b/Vonage/Redaction/IRedactClient.cs index 04ca7f17e..f8c0028f1 100644 --- a/Vonage/Redaction/IRedactClient.cs +++ b/Vonage/Redaction/IRedactClient.cs @@ -12,12 +12,4 @@ public interface IRedactClient /// /// Task RedactAsync(RedactRequest request, Credentials creds = null); - - /// - /// Redact a specific message - /// - /// - /// - /// - bool Redact(RedactRequest request, Credentials creds = null); } \ No newline at end of file diff --git a/Vonage/Redaction/RedactClient.cs b/Vonage/Redaction/RedactClient.cs index ebdc7cae3..af19f4212 100644 --- a/Vonage/Redaction/RedactClient.cs +++ b/Vonage/Redaction/RedactClient.cs @@ -1,4 +1,3 @@ -using System; using System.Net.Http; using System.Threading.Tasks; using Vonage.Common; @@ -26,21 +25,6 @@ internal RedactClient(Credentials credentials, Configuration configuration, ITim public Credentials Credentials { get; set; } - /// - [Obsolete("Favor asynchronous version instead.")] - public bool Redact(RedactRequest request, Credentials creds = null) - { - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) - .DoRequestWithJsonContent - ( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, this.configuration, "/v1/redact/transaction"), - request, - AuthType.Basic - ); - return true; - } - /// public async Task RedactAsync(RedactRequest request, Credentials creds = null) {