Skip to content

Commit c00789d

Browse files
authored
Disabling TRACE method functional tests (#10391)
* Setup for running functional tests locally. * Printing URL * Not testing TRACE requests.
1 parent 011771d commit c00789d

4 files changed

Lines changed: 85 additions & 53 deletions

File tree

tests/NuGetGallery.FunctionalTests/Security/HttpToHttpsRedirectTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -93,7 +93,7 @@ await VerifyHttpResponseStatus(
9393

9494
public static IEnumerable<object[]> RemainingUrlsAndMethodsForAppService =>
9595
from url in UrlsToTest.Concat(UrlsExcludedFromRedirectInCloudService).SelectMany(x => x)
96-
from method in new[] { HttpMethod.Get, HttpMethod.Head, HttpMethod.Options, HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete, HttpMethod.Trace }
96+
from method in new[] { HttpMethod.Get, HttpMethod.Head, HttpMethod.Options, HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }
9797
select new object[] { method, url };
9898

9999
/// <summary>

tests/Scripts/Import-GalleryConfiguration.ps1

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,57 +17,7 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem
1717
$basicAuth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'PAT', $PersonalAccessToken)))
1818
$headers = @{ Authorization = ("Basic {0}" -f $basicAuth) }
1919

20-
Function Merge-Objects {
21-
<#
22-
.SYNOPSIS
23-
Merges a PSObject with another PSObject.
24-
25-
.DESCRIPTION
26-
Iterates through every NoteProperty in the source object.
27-
Properties of the source object are added to the target object.
28-
If these properties already exist in the target object, they are overwritten.
29-
Properties that are PSObjects are merged recursively.
30-
31-
.PARAMETER Source
32-
The object to merge the target with.
33-
34-
.PARAMETER Output
35-
The object that the properties of the source are copied into.
36-
This object is mutated by the function.
37-
38-
.OUTPUTS
39-
None
40-
41-
.EXAMPLE
42-
$source = New-Object PSObject -Property @{ A = "A", B = New-Object PSObject -Property @{ C = "C" }, D = "D"}
43-
$target = New-Object PSObject -Property @{ D = "E", E = "E" }
44-
45-
Merge-Objects -Source $source -Target $target
46-
47-
$target is now @{ A = "A", B = New-Object PSObject -Property @{ C = "C" }, D = "D", E = "E" }
48-
#>
49-
param(
50-
[PSObject]$Source,
51-
[PSObject]$Target
52-
)
53-
54-
# For each property of the source object, add the property to the target object
55-
$Source | `
56-
Get-Member -MemberType NoteProperty | `
57-
ForEach-Object {
58-
$name = $_.Name
59-
$value = $Source."$name"
60-
$existingValue = $Target."$name"
61-
if ($_.Definition.StartsWith("System.Management.Automation.PSCustomObject") -and $existingValue -is [PSObject]) {
62-
# If the property is a nested object in both the source and target, merge the nested object in the source with the target object
63-
Merge-Objects -Source $value -Target $existingValue
64-
} else {
65-
# Add the property to the target object
66-
# If the property already exists on the target object, overwrite it
67-
$Target | Add-Member -MemberType NoteProperty -Name $name -Value $value -Force
68-
}
69-
}
70-
}
20+
Import-Module "$PSScriptRoot\TestUtilities.psm1" -Force
7121

7222
# Download the config files--common, per environment, and per region--and merge them into a single file
7323
$configObject = New-Object PSObject
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
param(
2+
[Parameter(Mandatory=$true)][string]$ConfigurationsPath,
3+
[Parameter(Mandatory=$true)][ValidateSet("production", "staging")][string]$Slot = "production",
4+
[Parameter(Mandatory=$true)][ValidateSet("Dev", "Int", "Prod")][string]$Environment,
5+
[Parameter(Mandatory=$true)][ValidateSet("USNC", "USSC", "USNC-PREVIEW", "USSC-PREVIEW", "USNC-ASE", "USSC-ASE")][string]$Region,
6+
[Parameter(Mandatory)][string[]]$TestCategories
7+
)
8+
9+
Import-Module "$PSScriptRoot\TestUtilities.psm1" -Force
10+
11+
$configObject = New-Object PSObject
12+
"Common", $Environment, "$Environment-$Region" | `
13+
ForEach-Object {
14+
$file = "$ConfigurationsPath\$_.json"
15+
if (-not (Test-Path $file)) {
16+
Write-Error "Missing configuration file: $file"
17+
exit 1
18+
}
19+
$configData = Get-Content -Path $file | ConvertFrom-Json
20+
# Merge the current file with the last files
21+
Merge-Objects -Source $configData -Target $configObject
22+
}
23+
24+
$configObject | Add-Member -MemberType NoteProperty -Name "Slot" -Value $Slot
25+
$configurationFilePath = "$PSScriptRoot\Config-$Environment-$Region.json"
26+
ConvertTo-Json $configObject | Out-File $configurationFilePath
27+
28+
$env:ConfigurationFilePath = $configurationFilePath
29+
& $PSScriptRoot\RunGalleryFunctionalTests.ps1 -TestCategories ($TestCategories -join ";")

tests/Scripts/TestUtilities.psm1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Function Merge-Objects {
2+
<#
3+
.SYNOPSIS
4+
Merges a PSObject with another PSObject.
5+
6+
.DESCRIPTION
7+
Iterates through every NoteProperty in the source object.
8+
Properties of the source object are added to the target object.
9+
If these properties already exist in the target object, they are overwritten.
10+
Properties that are PSObjects are merged recursively.
11+
12+
.PARAMETER Source
13+
The object to merge the target with.
14+
15+
.PARAMETER Output
16+
The object that the properties of the source are copied into.
17+
This object is mutated by the function.
18+
19+
.OUTPUTS
20+
None
21+
22+
.EXAMPLE
23+
$source = New-Object PSObject -Property @{ A = "A", B = New-Object PSObject -Property @{ C = "C" }, D = "D"}
24+
$target = New-Object PSObject -Property @{ D = "E", E = "E" }
25+
26+
Merge-Objects -Source $source -Target $target
27+
28+
$target is now @{ A = "A", B = New-Object PSObject -Property @{ C = "C" }, D = "D", E = "E" }
29+
#>
30+
param(
31+
[PSObject]$Source,
32+
[PSObject]$Target
33+
)
34+
35+
# For each property of the source object, add the property to the target object
36+
$Source | `
37+
Get-Member -MemberType NoteProperty | `
38+
ForEach-Object {
39+
$name = $_.Name
40+
$value = $Source."$name"
41+
$existingValue = $Target."$name"
42+
if ($_.Definition.StartsWith("System.Management.Automation.PSCustomObject") -and $existingValue -is [PSObject]) {
43+
# If the property is a nested object in both the source and target, merge the nested object in the source with the target object
44+
Merge-Objects -Source $value -Target $existingValue
45+
} else {
46+
# Add the property to the target object
47+
# If the property already exists on the target object, overwrite it
48+
$Target | Add-Member -MemberType NoteProperty -Name $name -Value $value -Force
49+
}
50+
}
51+
}
52+
53+
Export-ModuleMember -Function Merge-Objects

0 commit comments

Comments
 (0)