From 9c2d9d7a267d89618c24bbdbef6057f34dbbc46c Mon Sep 17 00:00:00 2001 From: Nate Barbettini Date: Wed, 12 Oct 2016 07:47:34 -0400 Subject: [PATCH] Remove old integration test project (moved to aspnet-tck) --- .../AutoCleanup.cs | 76 ------------------- .../IntegrationTestCollection.cs | 10 --- .../Properties/AssemblyInfo.cs | 19 ----- .../StandaloneTestFixture.cs | 64 ---------------- ...Stormpath.AspNetCore.IntegrationTest.xproj | 22 ------ .../TestServerInstance.cs | 41 ---------- .../project.json | 38 ---------- 7 files changed, 270 deletions(-) delete mode 100644 test/Stormpath.AspNetCore.IntegrationTest/AutoCleanup.cs delete mode 100644 test/Stormpath.AspNetCore.IntegrationTest/IntegrationTestCollection.cs delete mode 100644 test/Stormpath.AspNetCore.IntegrationTest/Properties/AssemblyInfo.cs delete mode 100644 test/Stormpath.AspNetCore.IntegrationTest/StandaloneTestFixture.cs delete mode 100644 test/Stormpath.AspNetCore.IntegrationTest/Stormpath.AspNetCore.IntegrationTest.xproj delete mode 100644 test/Stormpath.AspNetCore.IntegrationTest/TestServerInstance.cs delete mode 100644 test/Stormpath.AspNetCore.IntegrationTest/project.json diff --git a/test/Stormpath.AspNetCore.IntegrationTest/AutoCleanup.cs b/test/Stormpath.AspNetCore.IntegrationTest/AutoCleanup.cs deleted file mode 100644 index 6d7f42e..0000000 --- a/test/Stormpath.AspNetCore.IntegrationTest/AutoCleanup.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Stormpath.SDK.Client; -using Stormpath.SDK.Error; -using Stormpath.SDK.Resource; -using Stormpath.SDK.Sync; - -namespace Stormpath.AspNetCore.IntegrationTest -{ - public class AutoCleanup : IDisposable - { - private readonly List _cleanupList; - private readonly Action _log; - private bool _disposed; - - public AutoCleanup(IClient client, Func> setupAction = null, Action logAction = null) - { - if (logAction == null) - { - logAction = _ => { }; - } - _log = logAction; - - _cleanupList = new List(); - - client.GetCurrentTenant(); - - if (setupAction == null) - { - setupAction = _ => Task.FromResult(new IResource[] { }); - } - - var resources = setupAction(client).Result; - _cleanupList.AddRange(resources.OfType()); - } - - public void MarkForDeletion(IDeletable resource) - { - if (_disposed) - { - throw new ObjectDisposedException(nameof(AutoCleanup), "The environment has already been cleaned up"); - } - - if (resource == null) - { - throw new ArgumentNullException(nameof(resource)); - } - - _cleanupList.Add(resource); - } - - public void Dispose() - { - if (_disposed) - { - throw new ObjectDisposedException(nameof(AutoCleanup), "The environment has already been cleaned up"); - } - - foreach (var resource in (_cleanupList as IEnumerable).Reverse()) - { - try - { - resource.Delete(); - } - catch (ResourceException rex) - { - _log($"Could not delete {(resource as IResource)?.Href} - '{rex.DeveloperMessage}'"); - } - } - - _disposed = true; - } - } -} diff --git a/test/Stormpath.AspNetCore.IntegrationTest/IntegrationTestCollection.cs b/test/Stormpath.AspNetCore.IntegrationTest/IntegrationTestCollection.cs deleted file mode 100644 index 7e7a6cf..0000000 --- a/test/Stormpath.AspNetCore.IntegrationTest/IntegrationTestCollection.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Xunit; - -namespace Stormpath.AspNetCore.IntegrationTest -{ - [CollectionDefinition(nameof(IntegrationTestCollection))] - public class IntegrationTestCollection : ICollectionFixture - { - // Intentionally left blank. This class only serves as an anchor for CollectionDefinitionAttribute. - } -} diff --git a/test/Stormpath.AspNetCore.IntegrationTest/Properties/AssemblyInfo.cs b/test/Stormpath.AspNetCore.IntegrationTest/Properties/AssemblyInfo.cs deleted file mode 100644 index f113568..0000000 --- a/test/Stormpath.AspNetCore.IntegrationTest/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Stormpath.AspNetCore.IntegrationTest")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4c251a3b-0ca8-41ac-bd9d-c6feaf7247c2")] diff --git a/test/Stormpath.AspNetCore.IntegrationTest/StandaloneTestFixture.cs b/test/Stormpath.AspNetCore.IntegrationTest/StandaloneTestFixture.cs deleted file mode 100644 index b693803..0000000 --- a/test/Stormpath.AspNetCore.IntegrationTest/StandaloneTestFixture.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Threading.Tasks; -using Stormpath.SDK.Account; -using Stormpath.SDK.Application; -using Stormpath.SDK.Client; -using Stormpath.SDK.Directory; -using Stormpath.SDK.Http; -using Stormpath.SDK.Oauth; -using Stormpath.SDK.Resource; -using Stormpath.SDK.Serialization; - -namespace Stormpath.AspNetCore.IntegrationTest -{ - public class StandaloneTestFixture : IDisposable - { - private readonly AutoCleanup _environment; - - public StandaloneTestFixture() - : this(Clients.Builder() - .SetHttpClient(HttpClients.Create().SystemNetHttpClient()) - .SetSerializer(Serializers.Create().JsonNetSerializer()) - .Build()) - { - } - - public StandaloneTestFixture(IClient client) - { - Client = client; - TestKey = Guid.NewGuid().ToString(); - - _environment = new AutoCleanup(Client, async c => - { - TestApplication = await c.CreateApplicationAsync($"Stormpath.AspNetCore IT {TestKey}", true); - TestDirectory = await TestApplication.GetDefaultAccountStoreAsync() as IDirectory; - return new IResource[] {TestApplication, TestDirectory}; - }); - } - - public async Task GetAccessToken(IAccount account, string password) - { - var grantRequest = OauthRequests.NewPasswordGrantRequest() - .SetLogin(account.Email) - .SetPassword(password) - .Build(); - var grantResponse = await TestApplication.NewPasswordGrantAuthenticator() - .AuthenticateAsync(grantRequest); - - return grantResponse.AccessTokenString; - } - - public IClient Client { get; } - - public string TestKey { get; } - - public IApplication TestApplication { get; private set; } - - public IDirectory TestDirectory { get; private set; } - - public void Dispose() - { - _environment.Dispose(); - } - } -} \ No newline at end of file diff --git a/test/Stormpath.AspNetCore.IntegrationTest/Stormpath.AspNetCore.IntegrationTest.xproj b/test/Stormpath.AspNetCore.IntegrationTest/Stormpath.AspNetCore.IntegrationTest.xproj deleted file mode 100644 index ba1c9fe..0000000 --- a/test/Stormpath.AspNetCore.IntegrationTest/Stormpath.AspNetCore.IntegrationTest.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 4c251a3b-0ca8-41ac-bd9d-c6feaf7247c2 - Stormpath.AspNetCore.IntegrationTest - .\obj - .\bin\ - v4.6.1 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Stormpath.AspNetCore.IntegrationTest/TestServerInstance.cs b/test/Stormpath.AspNetCore.IntegrationTest/TestServerInstance.cs deleted file mode 100644 index f8b9eb2..0000000 --- a/test/Stormpath.AspNetCore.IntegrationTest/TestServerInstance.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Net.Http; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Stormpath.Configuration.Abstractions; - -namespace Stormpath.AspNetCore.IntegrationTest -{ - public static class TestServerInstance - { - public static HttpClient Create( - StandaloneTestFixture fixture, - Action customConfigureServices = null, - Action customConfigureApp = null) - { - return new TestServer(new WebHostBuilder() - .ConfigureServices(services => - { - services.AddStormpath(new StormpathConfiguration() - { - Application = new ApplicationConfiguration() - { - Href = fixture.TestApplication.Href - } - }); - services.AddMvc(); - - customConfigureServices?.Invoke(services); - }) - .Configure(app => - { - app.UseStormpath(); - app.UseMvc(); - customConfigureApp?.Invoke(app); - })) - .CreateClient(); - } - } -} diff --git a/test/Stormpath.AspNetCore.IntegrationTest/project.json b/test/Stormpath.AspNetCore.IntegrationTest/project.json deleted file mode 100644 index 4da5e87..0000000 --- a/test/Stormpath.AspNetCore.IntegrationTest/project.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "authors": [ "Nate Barbettini" ], - "dependencies": { - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "FluentAssertions": "4.14.0", - "Microsoft.AspNetCore.Mvc": "1.0.0", - "Microsoft.AspNetCore.TestHost": "1.0.0", - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - }, - "Newtonsoft.Json": "9.0.1", - "Stormpath.AspNetCore": { - "target": "project", - "version": "0.7.0-beta5" - }, - "xunit": "2.1.0" - }, - "description": "Integration tests for Stormpath ASP.NET Core middleware.", - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dnxcore50", - "portable-net45+win8" - ] - } - }, - "packOptions": { - "licenseUrl": "https://github.com/stormpath/stormpath-dotnet-owin-middleware/blob/master/LICENSE", - "owners": [ "Stormpath, Inc." ], - "projectUrl": "https://github.com/stormpath/stormpath-dotnet-owin-middleware", - "repository": { - "url": "https://github.com/stormpath/stormpath-dotnet-owin-middleware" - } - }, - "testRunner": "xunit", - "version": "0.7.0-beta5" -}