Skip to content

Commit c9a6303

Browse files
authored
Delete web UI tests, enable using test config from a local directory (#10681)
* Add scripts that can take config from a local directory * Delete web UI tests since they have been replaced by Playwright * Binding redirect hack * Handle null response, log test result location
1 parent f66a31a commit c9a6303

27 files changed

Lines changed: 112 additions & 852 deletions

NuGetGallery.FunctionalTests.sln

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.11.35111.106
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.3.11322.18 main
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{37E5C8A5-C7A6-400E-A0EA-6C2C6F9B160D}"
77
ProjectSection(SolutionItems) = preProject
@@ -12,14 +12,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.FunctionalTest
1212
EndProject
1313
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.FunctionalTests.Core", "tests\NuGetGallery.FunctionalTests.Core\NuGetGallery.FunctionalTests.Core.csproj", "{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}"
1414
EndProject
15-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P0", "tests\NuGetGallery.WebUITests.P0\NuGetGallery.WebUITests.P0.csproj", "{B3D313C5-A076-424C-B812-4EDE2D9EE888}"
16-
EndProject
17-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P1", "tests\NuGetGallery.WebUITests.P1\NuGetGallery.WebUITests.P1.csproj", "{66ACA75F-EE4D-4D23-AEC5-E38C715CDC7E}"
18-
EndProject
19-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.P2", "tests\NuGetGallery.WebUITests.P2\NuGetGallery.WebUITests.P2.csproj", "{30F7F8C9-46BC-4677-9D26-43395A2B6DF5}"
20-
EndProject
21-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGetGallery.WebUITests.ReadOnlyMode", "tests\NuGetGallery.WebUITests.ReadOnlyMode\NuGetGallery.WebUITests.ReadOnlyMode.csproj", "{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}"
22-
EndProject
2315
Global
2416
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2517
Debug|Any CPU = Debug|Any CPU
@@ -34,22 +26,6 @@ Global
3426
{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}.Debug|Any CPU.Build.0 = Debug|Any CPU
3527
{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}.Release|Any CPU.ActiveCfg = Release|Any CPU
3628
{8496C7FE-8A93-4D2E-A9DC-5DE44017187C}.Release|Any CPU.Build.0 = Release|Any CPU
37-
{B3D313C5-A076-424C-B812-4EDE2D9EE888}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38-
{B3D313C5-A076-424C-B812-4EDE2D9EE888}.Debug|Any CPU.Build.0 = Debug|Any CPU
39-
{B3D313C5-A076-424C-B812-4EDE2D9EE888}.Release|Any CPU.ActiveCfg = Release|Any CPU
40-
{B3D313C5-A076-424C-B812-4EDE2D9EE888}.Release|Any CPU.Build.0 = Release|Any CPU
41-
{66ACA75F-EE4D-4D23-AEC5-E38C715CDC7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42-
{66ACA75F-EE4D-4D23-AEC5-E38C715CDC7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
43-
{66ACA75F-EE4D-4D23-AEC5-E38C715CDC7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
44-
{66ACA75F-EE4D-4D23-AEC5-E38C715CDC7E}.Release|Any CPU.Build.0 = Release|Any CPU
45-
{30F7F8C9-46BC-4677-9D26-43395A2B6DF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46-
{30F7F8C9-46BC-4677-9D26-43395A2B6DF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
47-
{30F7F8C9-46BC-4677-9D26-43395A2B6DF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
48-
{30F7F8C9-46BC-4677-9D26-43395A2B6DF5}.Release|Any CPU.Build.0 = Release|Any CPU
49-
{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50-
{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}.Debug|Any CPU.Build.0 = Debug|Any CPU
51-
{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}.Release|Any CPU.ActiveCfg = Release|Any CPU
52-
{8F78E483-F3F8-4504-BEB8-4F854DF5E80E}.Release|Any CPU.Build.0 = Release|Any CPU
5329
EndGlobalSection
5430
GlobalSection(SolutionProperties) = preSolution
5531
HideSolutionNode = FALSE

tests/NuGetGallery.FunctionalTests.Core/GalleryConfiguration.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ static GalleryConfiguration()
3434
// This test suite hits the gallery which requires TLS 1.2 (at least in some environments).
3535
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
3636

37-
// This method is a workaround for binding redirect issues. Please check the implementation for more information.
38-
RedirectAssembly("Newtonsoft.Json");
39-
4037
// Load the configuration without injection. This allows us to read KeyVault configuration.
4138
var uninjectedBuilder = new ConfigurationBuilder()
4239
.AddJsonFile(EnvironmentSettings.ConfigurationFilePath, optional: false);
@@ -72,45 +69,6 @@ static GalleryConfiguration()
7269
}
7370
}
7471

75-
/// <summary>
76-
/// Source: https://stackoverflow.com/a/32698357
77-
/// </summary>
78-
public static void RedirectAssembly(string shortName)
79-
{
80-
/* The following code was added due to an issue with loading assemblies, at some point two versions of Newtonsoft.Json
81-
* where loaded on the AppDomain, this led to an issue where a package needed an specific assembly version
82-
* and the loaded assembly didn't contain a certain implementation. To fix this we are loading the last assembly
83-
* for the specified name (which at least for this case it's the valid one) at runtime.
84-
* This issue appeared on the FunciontalTests solution, so for the LoadTests project we only needed to
85-
* add the dependentAssembly specified on the app.config file.
86-
* Providing dependentAssembly did not work for WebUiTests projects since they use QTAgent (internal stuff for legacy mstest)
87-
* that has it's own configuration file with their own binding redirects.
88-
*
89-
* In short, this implements a binding redirect at runtime for an entry point that we don't control the config file for.
90-
*
91-
* There is an issue to migrate to newer framework/technology on GitHub: https://github.com/NuGet/NuGetGallery/issues/8916
92-
*/
93-
ResolveEventHandler handler = null;
94-
95-
handler = (sender, args) =>
96-
{
97-
var requestedAssembly = new AssemblyName(args.Name);
98-
if (requestedAssembly.Name != shortName)
99-
{
100-
return null;
101-
}
102-
103-
var current = AppDomain
104-
.CurrentDomain
105-
.GetAssemblies()
106-
.LastOrDefault(x => x.GetName().Name == shortName);
107-
108-
return current;
109-
};
110-
111-
AppDomain.CurrentDomain.AssemblyResolve += handler;
112-
}
113-
11472
public class AccountConfiguration : OrganizationConfiguration
11573
{
11674
public string Email { get; set; }

tests/NuGetGallery.FunctionalTests.Core/Helpers/AssertAndValidationHelper.cs

Lines changed: 0 additions & 172 deletions
This file was deleted.
Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
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;
5-
using System.Collections.Generic;
6-
using System.Linq;
7-
using Microsoft.VisualStudio.TestTools.WebTesting;
85

96
namespace NuGetGallery.FunctionalTests.Helpers
107
{
118
public static class UploadHelper
129
{
1310
private static readonly object UniqueLock = new object();
1411

15-
/// <summary>
12+
/// <summary>
1613
/// Helper class for defining the properties of a test package to be uploaded.
1714
/// </summary>
1815
public class PackageToUpload
@@ -69,69 +66,5 @@ public static string GetUniquePackageVersion()
6966
return $"1.0.0-v{ticks}";
7067
}
7168
}
72-
73-
/// <summary>
74-
/// Uploads a set of test packages using Gallery UI. Validates that logon prompt appears to upload and checks that the package's home page opens post upload.
75-
/// </summary>
76-
public static IEnumerator<WebTestRequest> UploadPackages(WebTest test, IEnumerable<PackageToUpload> packages)
77-
{
78-
return UploadPackages(test, packages.Select(p => new PackageToUploadInternal(p)));
79-
}
80-
81-
public class PackageToUploadInternal : PackageToUpload
82-
{
83-
public string FullPath { get; }
84-
85-
public PackageToUploadInternal(PackageToUpload package)
86-
: base(package)
87-
{
88-
FullPath = new PackageCreationHelper().CreatePackage(Id, Version).Result;
89-
}
90-
}
91-
92-
private static IEnumerator<WebTestRequest> UploadPackages(WebTest test, IEnumerable<PackageToUploadInternal> packagesToUpload)
93-
{
94-
return
95-
Login(test)
96-
.Concat(packagesToUpload.SelectMany(p => UploadPackage(test, p)))
97-
.GetEnumerator();
98-
}
99-
100-
private static IEnumerable<WebTestRequest> Login(WebTest test)
101-
{
102-
var defaultExtractionRule = AssertAndValidationHelper.GetDefaultExtractHiddenFields();
103-
104-
// Do initial login
105-
var logonGet = AssertAndValidationHelper.GetLogonGetRequest();
106-
yield return logonGet;
107-
108-
var logonPost = AssertAndValidationHelper.GetLogonPostRequest(test);
109-
yield return logonPost;
110-
}
111-
112-
private static IEnumerable<WebTestRequest> UploadPackage(WebTest test, PackageToUploadInternal packageToUpload)
113-
{
114-
// Navigate to the upload page.
115-
var uploadRequest = AssertAndValidationHelper.GetHttpRequestForUrl(UrlHelper.UploadPageUrl);
116-
yield return uploadRequest;
117-
118-
// Cancel any pending uploads.
119-
// We can't upload the new package if any uploads are pending.
120-
var cancelUploadPostRequest = AssertAndValidationHelper.GetCancelUploadPostRequestForPackage(test);
121-
yield return cancelUploadPostRequest;
122-
123-
// Upload the new package.
124-
var uploadPostRequest = AssertAndValidationHelper.GetUploadPostRequestForPackage(test, packageToUpload.FullPath);
125-
yield return uploadPostRequest;
126-
127-
// Verify the new package.
128-
var verifyUploadPostRequest = AssertAndValidationHelper.GetVerifyPackagePostRequestForPackage(test,
129-
packageToUpload.Id,
130-
packageToUpload.Version,
131-
UrlHelper.GetPackagePageUrl(packageToUpload.Id, packageToUpload.Version),
132-
packageToUpload.Id,
133-
packageToUpload.Owner);
134-
yield return verifyUploadPostRequest;
135-
}
13669
}
13770
}

tests/NuGetGallery.FunctionalTests.Core/NuGetGallery.FunctionalTests.Core.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\VisualStudioSearchPath.props" />
33
<PropertyGroup>
44
<TargetFramework>net472</TargetFramework>
55
<RootNamespace>NuGetGallery.FunctionalTests</RootNamespace>
66
</PropertyGroup>
77
<ItemGroup>
8-
<Reference Include="$(PkgMicrosoft_TestPlatform)\tools\net462\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.QualityTools.WebTestFramework.dll" />
98
<Reference Include="System.IO.Compression" />
109
</ItemGroup>
1110
<ItemGroup>
@@ -17,7 +16,6 @@
1716
-->
1817
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" VersionOverride="2.2.0" />
1918
<PackageReference Include="Microsoft.Playwright.Xunit" />
20-
<PackageReference Include="Microsoft.TestPlatform" GeneratePathProperty="true" />
2119
<PackageReference Include="Microsoft.Web.Xdt" />
2220
<PackageReference Include="NuGet.Core" />
2321
<PackageReference Include="NuGet.Services.Configuration" VersionOverride="2.94.0" />

0 commit comments

Comments
 (0)