Skip to content

Commit

Permalink
Updated Coretools to 4.30.0 (#3608)
Browse files Browse the repository at this point in the history
* Updated Coretools to 4.30.0

* fixed  the issue.

* Added timeouts for the tests.

* Fix for localhost auth.

---------

Co-authored-by: v-smanchem <[email protected]>
  • Loading branch information
khkh-ms and v-smanchem authored Mar 6, 2024
1 parent fc93cca commit 9a5b604
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/Azure.Functions.Cli/Actions/HostActions/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Azure.Functions.Cli.Diagnostics;
using Azure.Functions.Cli.ExtensionBundle;
using Azure.Functions.Cli.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Azure.WebJobs.Script;
Expand Down Expand Up @@ -73,6 +74,8 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
.AddScheme<ArmAuthenticationOptions, CliAuthenticationHandler<ArmAuthenticationOptions>>(ArmAuthenticationDefaults.AuthenticationScheme, _ => { });
}

services.AddSingleton<IAuthorizationHandler, CoreToolsAuthorizationHandler>();

services.AddWebJobsScriptHostAuthorization();

services.AddMvc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
using System.Security.Claims;
using Microsoft.Azure.WebJobs.Script.WebHost.Security.Authentication;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Azure.WebJobs.Script.WebHost.Security.Authorization;
using Microsoft.Azure.WebJobs.Script.Description;

namespace Azure.Functions.Cli.Actions.HostActions.WebHost.Security
{
Expand All @@ -33,4 +36,14 @@ protected override Task<AuthenticateResult> HandleAuthenticateAsync()
return Task.FromResult(result);
}
}

public class CoreToolsAuthorizationHandler : AuthorizationHandler<FunctionAuthorizationRequirement, FunctionDescriptor>
{
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FunctionAuthorizationRequirement requirement, FunctionDescriptor resource)
{
context.Succeed(requirement);

return Task.CompletedTask;
}
}
}
4 changes: 2 additions & 2 deletions src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.DurableTask.AzureStorage.Internal" Version="1.4.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="4.28.5" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="4.30.0" />
<PackageReference Include="Microsoft.Build" Version="17.0.0" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.35.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
Expand All @@ -291,7 +291,7 @@
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.0" Version="4.0.2973" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.2" Version="4.0.3070" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker.PS7.4" Version="4.0.3085" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorker" Version="4.23.0" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorker" Version="4.24.0" />
</ItemGroup>
<Target Name="ExcludeWorkersFromReadyToRun">
<CreateItem Include="%(None.Filename)%(None.Extension)" Condition="$([System.String]::new('%(None.TargetPath)').StartsWith('workers'))" PreserveExistingMetadata="false">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Azure.Functions.Cli.Common;
using Microsoft.Azure.WebJobs.Script;
using Microsoft.Azure.WebJobs.Script.Config;
using Microsoft.Azure.WebJobs.Script.Configuration;
using Microsoft.Azure.WebJobs.Script.Diagnostics;
using Microsoft.Azure.WebJobs.Script.ExtensionBundle;
Expand Down Expand Up @@ -32,7 +33,9 @@ public static ExtensionBundleManager GetExtensionBundleManager()
extensionBundleOption.DownloadPath = GetBundleDownloadPath(extensionBundleOption.Id);
extensionBundleOption.EnsureLatest = true;
}
return new ExtensionBundleManager(extensionBundleOption, SystemEnvironment.Instance, NullLoggerFactory.Instance);

var configOptions = new FunctionsHostingConfigOptions();
return new ExtensionBundleManager(extensionBundleOption, SystemEnvironment.Instance, NullLoggerFactory.Instance, configOptions);
}

public static ExtensionBundleContentProvider GetExtensionBundleContentProvider()
Expand Down
7 changes: 6 additions & 1 deletion test/Azure.Functions.Cli.Tests/E2E/StartTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ await CliTester.Run(new RunConfiguration
result.Should().Be("Hello, Test. This HTTP triggered function executed successfully.", because: "response from default function should be 'Hello, {name}. This HTTP triggered function executed successfully.'");
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
}, _output);
}

Expand Down Expand Up @@ -306,6 +307,7 @@ await CliTester.Run(new RunConfiguration
result.Should().Be("Hello, Test. This HTTP triggered function executed successfully.", because: "response from default function should be 'Hello, {name}. This HTTP triggered function executed successfully.'");
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
}, _output);
}

Expand Down Expand Up @@ -502,7 +504,8 @@ await CliTester.Run(new RunConfiguration[]
OutputDoesntContain = new string[]
{
"Skipping 'emptySetting' from local settings as it's already defined in current environment variables."
}
},
CommandTimeout = TimeSpan.FromSeconds(120),
}
}, _output);
}
Expand Down Expand Up @@ -632,6 +635,7 @@ await CliTester.Run(new RunConfiguration[]
{
"Using for user secrets file configuration."
},
CommandTimeout = TimeSpan.FromSeconds(120),
Test = async (workingDir, p) =>
{
using (var client = new HttpClient() { BaseAddress = new Uri("http://localhost:7071/") })
Expand Down Expand Up @@ -705,6 +709,7 @@ await CliTester.Run(new RunConfiguration[]
{
"start --functions http1 --csharp",
},
CommandTimeout = TimeSpan.FromSeconds(120),
ExpectExit = true,
ExitInError = true,
ErrorContains = new[] { "Missing value for AzureWebJobsStorage in local.settings.json and User Secrets. This is required for all triggers other than httptrigger, kafkatrigger. You can run 'func azure functionapp fetch-app-settings <functionAppName>' or specify a connection string in local.settings.json or User Secrets." },
Expand Down

0 comments on commit 9a5b604

Please sign in to comment.