* Update Twilio package, remove properties that have been removed from Twilio API

* Update `<TwilioVersion>` to a major version because of breaking changes (2 properties removed from Twilio SDK)

* Update Twilio dependency to 6.*

* Update test from netcoreapp2.0 to net6.0, fix issue where DocumentationFile was written to root of disk instead of output dir.

* Add missing properties from CreateMessageOptions

* Pin Twilio dependency to 6.2.0

* Update Twilio package, add missing property to Twilio test
This commit is contained in:
Niels Swimberghe 2023-03-13 18:45:29 -04:00 коммит произвёл GitHub
Родитель 6931a94202
Коммит 7478216218
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 93 добавлений и 86 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -13,3 +13,4 @@ csx
/buildoutput
/tools/NuGet.exe
.idea

Просмотреть файл

@ -7,7 +7,7 @@
<HttpVersion>3.2.0$(VersionSuffix)</HttpVersion>
<MobileAppsVersion>3.0.0$(VersionSuffix)</MobileAppsVersion>
<SendGridVersion>3.0.3$(VersionSuffix)</SendGridVersion>
<TwilioVersion>3.0.3$(VersionSuffix)</TwilioVersion>
<TwilioVersion>4.0.0$(VersionSuffix)</TwilioVersion>
<TimersStorageVersion>1.0.0-beta.1$(VersionSuffix)</TimersStorageVersion>
<DebugType>embedded</DebugType>
<LatestCommit Condition="$(LatestCommit) == ''">$(CommitHash)</LatestCommit>
@ -29,7 +29,7 @@
<SignAssembly>true</SignAssembly>
<DelaySign>true</DelaySign>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)PublicKey.snk</AssemblyOriginatorKeyFile>
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<DocumentationFile>$(BaseIntermediateOutputPath)\$(AssemblyName).xml</DocumentationFile>
<NoWarn>SA1629;SA1623;1591;1573;1591</NoWarn>
</PropertyGroup>

Просмотреть файл

@ -22,7 +22,9 @@ namespace Microsoft.Azure.WebJobs.Extensions.Twilio
internal const string AzureWebJobsTwilioAccountAuthTokenName = "AzureWebJobsTwilioAuthToken";
private readonly IOptions<TwilioSmsOptions> _options;
private readonly ConcurrentDictionary<Tuple<string, string>, TwilioRestClient> _twilioClientCache = new ConcurrentDictionary<Tuple<string, string>, TwilioRestClient>();
private readonly ConcurrentDictionary<Tuple<string, string>, TwilioRestClient> _twilioClientCache =
new ConcurrentDictionary<Tuple<string, string>, TwilioRestClient>();
public TwilioExtensionConfigProvider(IOptions<TwilioSmsOptions> options)
{
@ -66,7 +68,8 @@ namespace Microsoft.Azure.WebJobs.Extensions.Twilio
string accountSid = Utility.FirstOrDefault(attribute.AccountSidSetting, _options.Value.AccountSid);
string authToken = Utility.FirstOrDefault(attribute.AuthTokenSetting, _options.Value.AuthToken);
TwilioRestClient client = _twilioClientCache.GetOrAdd(new Tuple<string, string>(accountSid, authToken), t => new TwilioRestClient(t.Item1, t.Item2));
TwilioRestClient client = _twilioClientCache.GetOrAdd(new Tuple<string, string>(accountSid, authToken),
t => new TwilioRestClient(t.Item1, t.Item2));
var context = new TwilioSmsContext
{
@ -83,16 +86,21 @@ namespace Microsoft.Azure.WebJobs.Extensions.Twilio
{
var options = new CreateMessageOptions(new PhoneNumber(GetValueOrDefault<string>(messageOptions, "to")))
{
ProviderSid = GetValueOrDefault<string>(messageOptions, "providerSid"),
Body = GetValueOrDefault<string>(messageOptions, "body"),
ForceDelivery = GetValueOrDefault<bool?>(messageOptions, "forceDelivery"),
MaxRate = GetValueOrDefault<string>(messageOptions, "maxRate"),
ValidityPeriod = GetValueOrDefault<int?>(messageOptions, "validityPeriod"),
ProvideFeedback = GetValueOrDefault<bool?>(messageOptions, "provideFeedback"),
MaxPrice = GetValueOrDefault<decimal?>(messageOptions, "maxPrice"),
ApplicationSid = GetValueOrDefault<string>(messageOptions, "applicationSid"),
MessagingServiceSid = GetValueOrDefault<string>(messageOptions, "messagingServiceSid"),
PathAccountSid = GetValueOrDefault<string>(messageOptions, "pathAccountSid")
PathAccountSid = GetValueOrDefault<string>(messageOptions, "pathAccountSid"),
Attempt = GetValueOrDefault<int?>(messageOptions, "attempt"),
SmartEncoded = GetValueOrDefault<bool?>(messageOptions, "smartEncoded"),
ShortenUrls = GetValueOrDefault<bool?>(messageOptions, "shortenUrls"),
SendAt = GetValueOrDefault<DateTime?>(messageOptions, "sendAt"),
SendAsMms = GetValueOrDefault<bool?>(messageOptions, "sendAsMms"),
ContentSid = GetValueOrDefault<string>(messageOptions, "contentSid"),
ContentVariables = GetValueOrDefault<string>(messageOptions, "contentVariables")
};
string value = GetValueOrDefault<string>(messageOptions, "from");
@ -115,9 +123,40 @@ namespace Microsoft.Azure.WebJobs.Extensions.Twilio
{
uris.Add(new Uri((string)url));
}
options.MediaUrl = uris;
}
var contentRetention = GetValueOrDefault<string>(messageOptions, "ContentRetention");
if (!string.IsNullOrEmpty(contentRetention))
{
options.ContentRetention = contentRetention;
}
var addressRetention = GetValueOrDefault<string>(messageOptions, "addressRetention");
if (!string.IsNullOrEmpty(addressRetention))
{
options.AddressRetention = addressRetention;
}
var persistentActions = GetValueOrDefault<JArray>(messageOptions, "persistentAction");
if (persistentActions != null)
{
var actions = new List<string>();
foreach (var action in persistentActions)
{
actions.Add((string)action);
}
options.PersistentAction = actions;
}
var scheduleType = GetValueOrDefault<string>(messageOptions, "scheduleType");
if (!string.IsNullOrEmpty(scheduleType))
{
options.ScheduleType = scheduleType;
}
return options;
}
@ -131,12 +170,14 @@ namespace Microsoft.Azure.WebJobs.Extensions.Twilio
return default(TValue);
}
private static string ThrowMissingSettingException(string settingDisplayName, string settingName, string configPropertyName)
private static string ThrowMissingSettingException(string settingDisplayName, string settingName,
string configPropertyName)
{
string message = string.Format("The Twilio {0} must be set either via a '{1}' app setting, via a '{1}' environment variable, or directly in code via TwilioSmsConfiguration.{2}.",
string message = string.Format(
"The Twilio {0} must be set either via a '{1}' app setting, via a '{1}' environment variable, or directly in code via TwilioSmsConfiguration.{2}.",
settingDisplayName, settingName, configPropertyName);
throw new InvalidOperationException(message);
}
}
}
}

Просмотреть файл

@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.32" />
<PackageReference Include="Twilio" Version="5.6.3" />
<PackageReference Include="Twilio" Version="6.2.5" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.7.145" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />

Просмотреть файл

@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.7.145" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />

Просмотреть файл

@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.7.145" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />

Просмотреть файл

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.7.145" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />

Просмотреть файл

@ -6,12 +6,12 @@
<AssemblyName>Microsoft.Azure.WebJobs.Extensions.Tests.Common</AssemblyName>
<RootNamespace>Microsoft.Azure.WebJobs.Extensions.Tests.Common</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.7.145" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />

Просмотреть файл

@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.7.145" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />

Просмотреть файл

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using Microsoft.Azure.WebJobs.Extensions.Twilio;
using Newtonsoft.Json.Linq;
using Twilio.Rest.Api.V2010.Account;
using Xunit;
namespace Microsoft.Azure.WebJobs.Extensions.Tests.Extensions.Twilio
@ -35,7 +36,6 @@ namespace Microsoft.Azure.WebJobs.Extensions.Tests.Extensions.Twilio
{ "from", "+14254570422" },
{ "body", "Knock knock." },
{ "forceDelivery", true },
{ "maxRate", 123 },
{ "validityPeriod", 123 },
{ "provideFeedback", true },
{ "maxPrice", 0.55 },
@ -43,7 +43,18 @@ namespace Microsoft.Azure.WebJobs.Extensions.Tests.Extensions.Twilio
{ "statusCallback", "http://aaa" },
{ "messagingServiceSid", "bbbb" },
{ "pathAccountSid", "ccc" },
{ "mediaUrl", new JArray { "http://aaa", "http://bbb" } }
{ "mediaUrl", new JArray { "http://aaa", "http://bbb" } },
{ "attempt", 1 },
{ "smartEncoded", true },
{ "shortenUrls", true },
{ "sendAt", DateTime.UtcNow.AddHours(1) },
{ "sendAsMms", true },
{ "contentSid", "ddd" },
{ "contentVariables", "eee" },
{ "contentRetention", MessageResource.ContentRetentionEnum.Retain.ToString() },
{ "addressRetention", MessageResource.AddressRetentionEnum.Retain.ToString() },
{ "persistentAction", new JArray { "aaa", "bbb" } },
{ "scheduleType", MessageResource.ScheduleTypeEnum.Fixed.ToString() },
};
var result = TwilioExtensionConfigProvider.CreateMessageOptions(options);
@ -51,17 +62,27 @@ namespace Microsoft.Azure.WebJobs.Extensions.Tests.Extensions.Twilio
Assert.Equal(options["from"], result.From.ToString());
Assert.Equal(options["body"], result.Body.ToString());
Assert.Equal(options["forceDelivery"], result.ForceDelivery);
Assert.Equal(options["maxRate"], result.MaxRate);
Assert.Equal(options["validityPeriod"], result.ValidityPeriod);
Assert.Equal(options["provideFeedback"], result.ProvideFeedback);
Assert.Equal(options["maxPrice"], result.MaxPrice);
Assert.Equal(options["applicationSid"], result.ApplicationSid);
Assert.Equal(new Uri((string)options["statusCallback"]), result.StatusCallback);
Assert.Equal(new Uri((string)options["statusCallback"]), result.StatusCallback);
Assert.Equal(options["messagingServiceSid"], result.MessagingServiceSid);
Assert.Equal(options["pathAccountSid"], result.PathAccountSid);
Assert.Equal(new Uri((string)options["mediaUrl"][0]), result.MediaUrl[0]);
Assert.Equal(new Uri((string)options["mediaUrl"][1]), result.MediaUrl[1]);
Assert.Equal(options["attempt"], result.Attempt);
Assert.Equal(options["smartEncoded"], result.SmartEncoded);
Assert.Equal(options["shortenUrls"], result.ShortenUrls);
Assert.Equal(options["sendAt"], result.SendAt);
Assert.Equal(options["sendAsMms"], result.SendAsMms);
Assert.Equal(options["contentSid"], result.ContentSid);
Assert.Equal(options["contentVariables"], result.ContentVariables);
Assert.Equal(options["contentRetention"], result.ContentRetention.ToString());
Assert.Equal(options["addressRetention"], result.AddressRetention.ToString());
Assert.Equal(options["persistentAction"][0], result.PersistentAction[0]);
Assert.Equal(options["persistentAction"][1], result.PersistentAction[1]);
Assert.Equal(options["scheduleType"], result.ScheduleType.ToString());
}
}
}

Просмотреть файл

@ -8,13 +8,15 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.2" />
<PackageReference Include="Moq" Version="4.7.145" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="NotificationHubsConnectionString" value="ConnectionString_FromAppSettings" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.2.0.0" newVersion="7.2.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.8.1.0" newVersion="5.8.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.8.1.0" newVersion="5.8.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.8.1.0" newVersion="5.8.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.29.0" newVersion="4.2.29.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Azure.Documents.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.13.0.0" newVersion="1.13.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup></configuration>