Skip to content

Commit c04e0f9

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feature/add-delayed-response
2 parents 6bed92f + 76afc9b commit c04e0f9

29 files changed

Lines changed: 708 additions & 327 deletions

File tree

eng/common/scripts/Cadl-Project-Sync.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ function GetGitRemoteValue([string]$repo) {
4444
$gitRemotes = (git remote -v)
4545
foreach ($remote in $gitRemotes) {
4646
if ($remote.StartsWith("origin")) {
47-
if ($remote -match 'https://github.com/\S+[\.git]') {
47+
if ($remote -match 'https://github.com/\S+') {
4848
$result = "https://github.com/$repo.git"
4949
break
50-
} elseif ($remote -match "git@github.com:\S+[\.git]"){
50+
} elseif ($remote -match "git@github.com:\S+"){
5151
$result = "git@github.com:$repo.git"
5252
break
5353
} else {

eng/common/scripts/get-codeowners.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,18 @@ function TestGetCodeOwner([string]$targetDirectory, [string]$codeOwnerFileLocati
8181
}
8282

8383
if($Test) {
84-
$testFile = (Resolve-Path $PSScriptRoot/../../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/simple_path_CODEOWNERS)
85-
TestGetCodeOwner -targetDirectory "sdk" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
86-
TestGetCodeOwner -targetDirectory "sdk/noPath" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
87-
TestGetCodeOwner -targetDirectory "/sdk/azconfig" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person3", "person4")
88-
TestGetCodeOwner -targetDirectory "/sdk/azconfig/package" -codeOwnerFileLocation $testFile -includeNonUserAliases $true $testFile -expectReturn @("person3", "person4")
89-
TestGetCodeOwner -targetDirectory "/sd" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @()
90-
TestGetCodeOwner -targetDirectory "/sdk/testUser/" -codeOwnerFileLocation $testFile -expectReturn @("azure-sdk")
84+
# These tests have been removed; now instead we should run tests from RetrieveCodeOwnersProgramTests, and in a way as explained in:
85+
# https://github.com/Azure/azure-sdk-tools/issues/5434
86+
# https://github.com/Azure/azure-sdk-tools/pull/5103#discussion_r1068680818
87+
Write-Host "These tests have been removed. Please see https://github.com/Azure/azure-sdk-tools/issues/5434 for more."
88+
#
89+
# $testFile = (Resolve-Path $PSScriptRoot/../../../tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/TestData/simple_path_CODEOWNERS)
90+
# TestGetCodeOwner -targetDirectory "sdk" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
91+
# TestGetCodeOwner -targetDirectory "sdk/noPath" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person1", "person2")
92+
# TestGetCodeOwner -targetDirectory "/sdk/azconfig" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @("person3", "person4")
93+
# TestGetCodeOwner -targetDirectory "/sdk/azconfig/package" -codeOwnerFileLocation $testFile -includeNonUserAliases $true $testFile -expectReturn @("person3", "person4")
94+
# TestGetCodeOwner -targetDirectory "/sd" -codeOwnerFileLocation $testFile -includeNonUserAliases $true -expectReturn @()
95+
# TestGetCodeOwner -targetDirectory "/sdk/testUser/" -codeOwnerFileLocation $testFile -expectReturn @("azure-sdk")
9196
exit 0
9297
}
9398
else {

eng/pipelines/templates/steps/install-dotnet.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ steps:
1616
retryCountOnTaskFailure: 3
1717
inputs:
1818
# We must install sdk, not just runtime, as it is required by some of our tools, like test-proxy.
19-
# For additional context, see PR: https://github.com/Azure/azure-sdk-tools/pull/5405
19+
# Specifically, test-proxy requires asp.net core runtime, which is installed only when sdk option
20+
# is selected, per: https://github.com/microsoft/azure-pipelines-tasks/issues/14405
21+
#
22+
# For additional context, see:
23+
# https://github.com/Azure/azure-sdk-tools/pull/5405#discussion_r1105006774
24+
# https://github.com/Azure/azure-sdk-tools/pull/5405
2025
packageType: sdk
2126
version: 6.0.x
2227
# performMultiLevelLookup comes into play when given .NET executable target runtime is different
2328
# than the installed .NET SDK. Without this, such runtime would not be found.
2429
performMultiLevelLookup: true
2530

2631
# Future work: add NuGet packages caching. See:
27-
# https://github.com/Azure/azure-sdk-tools/issues/5086
32+
# https://github.com/Azure/azure-sdk-tools/issues/5086

src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Review.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<span class="small text-muted">Approves the current revision of the API</span>
4848
<div class="d-grid gap-2">
4949
<button type="button" class="btn btn-success" data-bs-toggle="modal" data-bs-target="#approveModel">
50-
Approve With Modal
50+
Approve
5151
</button>
5252
</div>
5353
}

tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/ProgramSimplePathTests.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static int Main(
5353
bool excludeNonUserAliases = false,
5454
string? targetDir = null,
5555
string ignoredPathPrefixes = DefaultIgnoredPrefixes,
56-
bool useRegexMatcher = false)
56+
bool useRegexMatcher = CodeownersFile.UseRegexMatcherDefault)
5757
{
5858
try
5959
{
@@ -109,7 +109,7 @@ private static Dictionary<string, CodeownersEntry> GetCodeownersForGlobPath(
109109
string codeownersFilePathOrUrl,
110110
bool excludeNonUserAliases,
111111
string[]? ignoredPathPrefixes = null,
112-
bool useRegexMatcher = false)
112+
bool useRegexMatcher = CodeownersFile.UseRegexMatcherDefault)
113113
{
114114
ignoredPathPrefixes ??= Array.Empty<string>();
115115

@@ -131,7 +131,7 @@ private static CodeownersEntry GetCodeownersForSimplePath(
131131
string targetPath,
132132
string codeownersFilePathOrUrl,
133133
bool excludeNonUserAliases,
134-
bool useRegexMatcher = false)
134+
bool useRegexMatcher = CodeownersFile.UseRegexMatcherDefault)
135135
{
136136
CodeownersEntry codeownersEntry =
137137
CodeownersFile.GetMatchingCodeownersEntry(

tools/code-owners-parser/CodeOwnersParser/CodeownersFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Azure.Sdk.Tools.CodeOwnersParser
88
{
99
public static class CodeownersFile
1010
{
11-
private const bool UseRegexMatcherDefault = true;
11+
public const bool UseRegexMatcherDefault = true;
1212

1313
public static List<CodeownersEntry> GetCodeownersEntriesFromFileOrUrl(
1414
string codeownersFilePathOrUrl)

tools/test-proxy/Azure.Sdk.Tools.TestProxy.Tests/InfoTests.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using Azure.Sdk.Tools.TestProxy.Common;
1+
using Azure.Sdk.Tools.TestProxy.Common;
2+
using Azure.Sdk.Tools.TestProxy.Matchers;
23
using Azure.Sdk.Tools.TestProxy.Models;
34
using Azure.Sdk.Tools.TestProxy.Sanitizers;
5+
using Azure.Sdk.Tools.TestProxy.Transforms;
46
using Microsoft.AspNetCore.Http;
57
using Microsoft.AspNetCore.Mvc;
68
using System;
@@ -58,5 +60,36 @@ public void TestReflectionModelWithAdvancedType()
5860

5961
var result = controller.Active();
6062
}
63+
64+
[Fact]
65+
public async Task TestReflectionModelWithTargetRecordSession()
66+
{
67+
RecordingHandler testRecordingHandler = new RecordingHandler(Directory.GetCurrentDirectory());
68+
var httpContext = new DefaultHttpContext();
69+
70+
await testRecordingHandler.StartPlaybackAsync("Test.RecordEntries/multipart_request.json", httpContext.Response);
71+
testRecordingHandler.Transforms.Clear();
72+
73+
var recordingId = httpContext.Response.Headers["x-recording-id"].ToString();
74+
75+
testRecordingHandler.AddSanitizerToRecording(recordingId, new UriRegexSanitizer(regex: "ABC123"));
76+
testRecordingHandler.AddSanitizerToRecording(recordingId, new BodyRegexSanitizer(regex: ".+?"));
77+
testRecordingHandler.SetMatcherForRecording(recordingId, new CustomDefaultMatcher(compareBodies: false, excludedHeaders: "an-excluded-header"));
78+
79+
var model = new ActiveMetadataModel(testRecordingHandler, recordingId);
80+
var descriptions = model.Descriptions.ToList();
81+
82+
// we should have exactly 6 if we're counting all the customizations appropriately
83+
Assert.True(descriptions.Count == 6);
84+
Assert.True(model.Matchers.Count() == 1);
85+
Assert.True(model.Sanitizers.Count() == 5);
86+
87+
// confirm that the overridden matcher is showing up
88+
Assert.True(descriptions[3].ConstructorDetails.Arguments[1].Item2 == "\"ABC123\"");
89+
Assert.True(descriptions[4].ConstructorDetails.Arguments[1].Item2 == "\".+?\"");
90+
91+
// and finally confirm our sanitizers are what we expect
92+
Assert.True(descriptions[5].Name == "CustomDefaultMatcher");
93+
}
6194
}
6295
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
namespace Azure.Sdk.Tools.TestProxy.Common.Exceptions
3+
{
4+
public class SessionNotActiveException: Exception
5+
{
6+
public SessionNotActiveException()
7+
{
8+
}
9+
public SessionNotActiveException(string message)
10+
: base(message)
11+
{
12+
}
13+
}
14+
}

tools/test-proxy/Azure.Sdk.Tools.TestProxy/Info.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using Azure.Sdk.Tools.TestProxy.Common.Exceptions;
45
using Azure.Sdk.Tools.TestProxy.Models;
56
using Microsoft.AspNetCore.Mvc;
67
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -33,15 +34,26 @@ public async Task<ContentResult> Available()
3334
}
3435

3536
[HttpGet]
36-
public async Task<ContentResult> Active()
37+
public async Task<ContentResult> Active(string id="")
3738
{
38-
var dataModel = new ActiveMetadataModel(_recordingHandler);
39-
var viewHtml = await RenderViewAsync(this, "ActiveExtensions", dataModel);
39+
string content = string.Empty;
40+
41+
try
42+
{
43+
var dataModel = new ActiveMetadataModel(_recordingHandler, recordingId: id);
44+
content = await RenderViewAsync(this, "ActiveExtensions", dataModel);
45+
}
46+
// if a SessionNotActiveException is thrown, we have passed in an invalid recordingId, otherwise it'll be an unhandled
47+
// exception, which the exception middleware should surface just fine.
48+
catch (SessionNotActiveException)
49+
{
50+
content = await RenderViewAsync(this, "Error", new ActiveMetadataModel(id));
51+
}
4052

4153
return new ContentResult
4254
{
4355
ContentType = "text/html",
44-
Content = viewHtml
56+
Content = content
4557
};
4658
}
4759

0 commit comments

Comments
 (0)