diff --git a/.gitignore b/.gitignore
index 6f203acd4..697621123 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,6 +128,7 @@ publish/
*.azurePubxml
*.pubxml
*.pubxml.user
+!Release.pubxml
# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
diff --git a/Bonobo.Git.Server.Test/Bonobo.Git.Server.Test.csproj b/Bonobo.Git.Server.Test/Bonobo.Git.Server.Test.csproj
index 4a0291c85..e38a19081 100644
--- a/Bonobo.Git.Server.Test/Bonobo.Git.Server.Test.csproj
+++ b/Bonobo.Git.Server.Test/Bonobo.Git.Server.Test.csproj
@@ -1,223 +1,41 @@
-
-
-
+
+
- Debug
- AnyCPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}
- Library
- Properties
- Bonobo.Git.Server.Test
- Bonobo.Git.Server.Test
- v4.6
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 10.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
-
-
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
- true
- bin\Test\
- DEBUG;TRACE
- full
- AnyCPU
- prompt
- MinimumRecommendedRules.ruleset
+ netcoreapp2.2
+
+ false
+
-
- ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
- True
-
-
- ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
- True
-
-
- ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
- True
-
-
- ..\packages\SpecsFor.Mvc.4.8.0\lib\net451\SpecsFor.Mvc.dll
- True
-
-
-
-
-
-
- ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
- True
-
-
- ..\packages\Microsoft.AspNet.Mvc.Futures.5.0.0\lib\net40\Microsoft.Web.Mvc.dll
- True
-
-
-
- ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net46\System.Data.SQLite.dll
- True
-
-
- ..\packages\System.Data.SQLite.EF6.1.0.104.0\lib\net46\System.Data.SQLite.EF6.dll
- True
-
-
- ..\packages\System.Data.SQLite.Linq.1.0.104.0\lib\net46\System.Data.SQLite.Linq.dll
- True
-
-
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll
- True
-
-
- ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll
- True
-
-
- ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll
- True
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll
- True
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll
- True
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll
- True
-
-
- ..\packages\Selenium.WebDriver.3.3.0\lib\net40\WebDriver.dll
- True
-
-
- ..\packages\Selenium.Support.3.3.0\lib\net40\WebDriver.Support.dll
- True
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
- {6129b3fe-b282-4f6f-8836-8af66602f8da}
- Bonobo.Git.Server
-
+
+
+
-
-
+
-
-
-
-
- False
-
-
- False
-
-
- False
-
-
- False
-
-
-
-
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
diff --git a/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADBackendStoreTest.cs b/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADBackendStoreTest.cs
index bcfb1e700..62bfb8dff 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADBackendStoreTest.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADBackendStoreTest.cs
@@ -2,7 +2,9 @@
using System.IO;
using System.Linq;
using Bonobo.Git.Server.Data;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NSubstitute;
namespace Bonobo.Git.Server.Test.MembershipTests.ADTests
{
@@ -42,7 +44,8 @@ private void SafelyDeleteTestData()
private static ADBackendStore MakeStore()
{
- return new ADBackendStore(Path.GetTempPath(), "BonoboTestStore");
+ var hostingEnvironment = Substitute.For();
+ return new ADBackendStore(hostingEnvironment, Path.GetTempPath(), "BonoboTestStore");
}
[TestMethod]
diff --git a/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADPermissionServiceTest.cs b/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADPermissionServiceTest.cs
index 9b1d5eaad..8e5b0fb5d 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADPermissionServiceTest.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/ADTests/ADPermissionServiceTest.cs
@@ -31,10 +31,7 @@ private void InitialiseTestObjects()
_users = new ADMembershipServiceTestFacade(new ADMembershipService(), _testSupport);
_repos = new ADRepositoryRepository();
- _service = new RepositoryPermissionService
- {
- Repository = _repos, RoleProvider = _roles, TeamRepository = _teams
- };
+ _service = new RepositoryPermissionService(_repos, _roles, _teams);
}
protected override TeamModel CreateTeam()
diff --git a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFMembershipServiceTest.cs b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFMembershipServiceTest.cs
index 1ef435350..5f56a6fe8 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFMembershipServiceTest.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFMembershipServiceTest.cs
@@ -5,6 +5,7 @@
using Bonobo.Git.Server.Data.Update;
using Bonobo.Git.Server.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NSubstitute;
namespace Bonobo.Git.Server.Test.MembershipTests.EFTests
{
@@ -19,7 +20,7 @@ public abstract class EFMembershipServiceTest : MembershipServiceTestBase
public void UpdatesCanBeRunOnAlreadyUpdatedDatabase()
{
// Run all the updates again - this should be completely harmless
- new AutomaticUpdater().RunWithContext(GetContext());
+ new AutomaticUpdater().RunWithContext(GetContext(), Substitute.For());
}
[TestMethod]
@@ -123,8 +124,8 @@ private BonoboGitServerContext GetContext()
protected void InitialiseTestObjects()
{
- _service = new EFMembershipService {CreateContext = GetContext};
- new AutomaticUpdater().RunWithContext(GetContext());
+ _service = new EFMembershipService(GetContext);
+ new AutomaticUpdater().RunWithContext(GetContext(), Substitute.For());
}
}
}
\ No newline at end of file
diff --git a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFPermissionServiceTest.cs b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFPermissionServiceTest.cs
index 0574023e1..19dac662e 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFPermissionServiceTest.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFPermissionServiceTest.cs
@@ -3,6 +3,7 @@
using Bonobo.Git.Server.Models;
using Bonobo.Git.Server.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NSubstitute;
namespace Bonobo.Git.Server.Test.MembershipTests.EFTests
{
@@ -44,19 +45,14 @@ public abstract class EFPermissionServiceTest : PermissionServiceTestBase
protected void InitialiseTestObjects()
{
- _teams = new EFTeamRepository { CreateContext = () => _connection.GetContext() };
- _users = new EFMembershipService { CreateContext = () => _connection.GetContext() };
- _repos = new EFRepositoryRepository { CreateContext = () => _connection.GetContext() };
- _roles = new EFRoleProvider { CreateContext = () => _connection.GetContext() };
+ _teams = new EFTeamRepository(() => _connection.GetContext());
+ _users = new EFMembershipService(() => _connection.GetContext());
+ _repos = new EFRepositoryRepository(() => _connection.GetContext());
+ _roles = new EFRoleProvider(() => _connection.GetContext() );
- _service = new RepositoryPermissionService
- {
- Repository = _repos,
- TeamRepository = _teams,
- RoleProvider = _roles
- };
+ _service = new RepositoryPermissionService(_repos, _roles, _teams);
- new AutomaticUpdater().RunWithContext(_connection.GetContext());
+ new AutomaticUpdater().RunWithContext(_connection.GetContext(), Substitute.For());
}
protected override TeamModel CreateTeam()
diff --git a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRepositoryRepositoryTest.cs b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRepositoryRepositoryTest.cs
index 51670c9ed..9acb862ad 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRepositoryRepositoryTest.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRepositoryRepositoryTest.cs
@@ -3,6 +3,7 @@
using Bonobo.Git.Server.Models;
using Bonobo.Git.Server.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NSubstitute;
namespace Bonobo.Git.Server.Test.MembershipTests.EFTests
{
@@ -44,14 +45,14 @@ public abstract class EFRepositoryRepositoryTest : RepositoryRepositoryTestBase
protected override UserModel AddUserFred()
{
- IMembershipService memberService = new EFMembershipService { CreateContext = GetContext };
+ IMembershipService memberService = new EFMembershipService(GetContext);
memberService.CreateUser("fred", "letmein", "Fred", "Blogs", "fred@aol");
return memberService.GetUserModel("fred");
}
protected override TeamModel AddTeam()
{
- EFTeamRepository teams = new EFTeamRepository { CreateContext = GetContext };
+ EFTeamRepository teams = new EFTeamRepository(GetContext);
var newTeam = new TeamModel { Name="Team1" };
teams.Create(newTeam);
return newTeam;
@@ -64,8 +65,8 @@ BonoboGitServerContext GetContext()
protected void InitialiseTestObjects()
{
- _repo = new EFRepositoryRepository {CreateContext = () => _connection.GetContext()};
- new AutomaticUpdater().RunWithContext(_connection.GetContext());
+ _repo = new EFRepositoryRepository(() => _connection.GetContext());
+ new AutomaticUpdater().RunWithContext(_connection.GetContext(), Substitute.For());
}
}
}
\ No newline at end of file
diff --git a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRoleProviderTest.cs b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRoleProviderTest.cs
index 0ec799cb8..bae54bae1 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRoleProviderTest.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFRoleProviderTest.cs
@@ -4,6 +4,7 @@
using Bonobo.Git.Server.Data.Update;
using Bonobo.Git.Server.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NSubstitute;
namespace Bonobo.Git.Server.Test.MembershipTests.EFTests
{
@@ -48,7 +49,7 @@ public abstract class EFRoleProviderTest
public void UpdatesCanBeRunOnAlreadyUpdatedDatabase()
{
// Run all the updates again - this should be completely harmless
- new AutomaticUpdater().RunWithContext(GetContext());
+ new AutomaticUpdater().RunWithContext(GetContext(), Substitute.For());
}
[TestMethod]
@@ -148,14 +149,14 @@ public void TestRoleCanBeDeletedWhilePopulatedIfAllowed()
Guid AddUserFred()
{
- EFMembershipService memberService = new EFMembershipService { CreateContext = GetContext };
+ EFMembershipService memberService = new EFMembershipService(GetContext);
memberService.CreateUser("fred", "letmein", "Fred", "FredBlogs", "fred@aol");
return memberService.GetUserModel("fred").Id;
}
Guid GetAdminId()
{
- EFMembershipService memberService = new EFMembershipService { CreateContext = GetContext };
+ EFMembershipService memberService = new EFMembershipService(GetContext);
return memberService.GetUserModel("Admin").Id;
}
@@ -166,8 +167,8 @@ private BonoboGitServerContext GetContext()
protected void InitialiseTestObjects()
{
- _provider = new EFRoleProvider {CreateContext = () => _connection.GetContext()};
- new AutomaticUpdater().RunWithContext(_connection.GetContext());
+ _provider = new EFRoleProvider(() => _connection.GetContext());
+ new AutomaticUpdater().RunWithContext(_connection.GetContext(), Substitute.For());
}
}
}
\ No newline at end of file
diff --git a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFTeamRepositoryTests.cs b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFTeamRepositoryTests.cs
index 238b1d660..63cc3dae1 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFTeamRepositoryTests.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/EFTests/EFTeamRepositoryTests.cs
@@ -6,6 +6,7 @@
using Bonobo.Git.Server.Models;
using Bonobo.Git.Server.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using NSubstitute;
namespace Bonobo.Git.Server.Test.MembershipTests.EFTests
{
@@ -49,9 +50,9 @@ public abstract class EFTeamRepositoryTests : TeamRepositoryTestsBase
protected void InitialiseTestObjects()
{
- _repo = new EFTeamRepository {CreateContext = () => _connection.GetContext()};
- _membershipService = new EFMembershipService { CreateContext = () => _connection.GetContext() };
- new AutomaticUpdater().RunWithContext(_connection.GetContext());
+ _repo = new EFTeamRepository(() => _connection.GetContext());
+ _membershipService = new EFMembershipService(() => _connection.GetContext());
+ new AutomaticUpdater().RunWithContext(_connection.GetContext(), Substitute.For());
}
protected override bool CreateTeam(TeamModel team)
diff --git a/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqlServerTestConnection.cs b/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqlServerTestConnection.cs
index 869bac6c2..125ec2831 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqlServerTestConnection.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqlServerTestConnection.cs
@@ -2,12 +2,13 @@
using System.Data.SqlClient;
using System.IO;
using Bonobo.Git.Server.Data;
+using Microsoft.EntityFrameworkCore;
namespace Bonobo.Git.Server.Test.MembershipTests.EFTests
{
class SqlServerTestConnection : IDatabaseTestConnection
{
- readonly SqlConnection _connection;
+ readonly DbContextOptionsBuilder _optionsBuilder;
private readonly string _databaseName;
private static readonly string _instanceName;
@@ -52,13 +53,15 @@ public SqlServerTestConnection()
Console.WriteLine("Created test database: " + fileName);
- _connection = new SqlConnection(String.Format(@"Data Source=(LocalDB)\{0};Integrated Security=True;AttachDbFilename={1};Initial Catalog={2}", _instanceName, fileName, _databaseName));
- _connection.Open();
+ _optionsBuilder = new DbContextOptionsBuilder();
+ _optionsBuilder.UseSqlServer(string.Format(
+ @"Data Source=(LocalDB)\{0};Integrated Security=True;AttachDbFilename={1};Initial Catalog={2}",
+ _instanceName, fileName, _databaseName));
}
public BonoboGitServerContext GetContext()
{
- return BonoboGitServerContext.FromDatabase(_connection);
+ return new BonoboGitServerContext(_optionsBuilder.Options);
}
void CreateDB(string fileName)
@@ -96,7 +99,6 @@ private void Exec(SqlConnection connection, string commandText)
public void Dispose()
{
- _connection.Dispose();
SqlConnection.ClearAllPools();
TryToDeleteDatabaseFiles();
}
diff --git a/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqliteTestConnection.cs b/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqliteTestConnection.cs
index 0e0fc99d4..604e9d12a 100644
--- a/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqliteTestConnection.cs
+++ b/Bonobo.Git.Server.Test/MembershipTests/EFTests/SqliteTestConnection.cs
@@ -1,6 +1,8 @@
using System;
using System.Data.Common;
using Bonobo.Git.Server.Data;
+using Microsoft.Data.Sqlite;
+using Microsoft.EntityFrameworkCore;
namespace Bonobo.Git.Server.Test.MembershipTests.EFTests
{
@@ -11,18 +13,20 @@ public interface IDatabaseTestConnection : IDisposable
class SqliteTestConnection : IDatabaseTestConnection
{
- readonly DbConnection _connection;
+ private readonly DbConnection _connection;
public SqliteTestConnection()
{
- _connection = DbProviderFactories.GetFactory("System.Data.SQLite").CreateConnection();
- _connection.ConnectionString = "Data Source =:memory:;BinaryGUID=False";
+ _connection = SqliteFactory.Instance.CreateConnection();
+ _connection.ConnectionString = "Data Source =:memory:";
_connection.Open();
}
public BonoboGitServerContext GetContext()
{
- return BonoboGitServerContext.FromDatabase(_connection);
+ var optionsBuilder = new DbContextOptionsBuilder();
+ optionsBuilder.UseSqlite(_connection);
+ return new BonoboGitServerContext(optionsBuilder.Options);
}
public void Dispose()
diff --git a/Bonobo.Git.Server.Test/Properties/AssemblyInfo.cs b/Bonobo.Git.Server.Test/Properties/AssemblyInfo.cs
deleted file mode 100644
index 5307292ec..000000000
--- a/Bonobo.Git.Server.Test/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +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: AssemblyTitle("Bonobo.Git.Server.Test")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Bonobo.Git.Server.Test")]
-[assembly: AssemblyCopyright("Copyright © 2013")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 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("94027fbc-c2ed-4081-bed2-8148b04215cd")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Bonobo.Git.Server.Test/TestCategories.cs b/Bonobo.Git.Server.Test/TestCategories.cs
index 722cda47b..c1c700755 100644
--- a/Bonobo.Git.Server.Test/TestCategories.cs
+++ b/Bonobo.Git.Server.Test/TestCategories.cs
@@ -1,9 +1,3 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
namespace Bonobo.Git.Server.Test
{
public static class TestCategories
@@ -19,4 +13,4 @@ public static class TestCategories
public const string AuthWindows = "AuthWindowsAuth";
public const string AuthADFS = "AuthADFS";
}
-}
+}
\ No newline at end of file
diff --git a/Bonobo.Git.Server.Test/UnitTests/CustomHtmlHelperTest.cs b/Bonobo.Git.Server.Test/UnitTests/CustomHtmlHelperTest.cs
index 95f2984a4..dd67224dd 100644
--- a/Bonobo.Git.Server.Test/UnitTests/CustomHtmlHelperTest.cs
+++ b/Bonobo.Git.Server.Test/UnitTests/CustomHtmlHelperTest.cs
@@ -1,7 +1,6 @@
using System.ComponentModel.DataAnnotations;
-using System.Web.Mvc;
-using Bonobo.Git.Server.Data;
using Bonobo.Git.Server.Helpers;
+using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Bonobo.Git.Server.Test.UnitTests
@@ -9,7 +8,7 @@ namespace Bonobo.Git.Server.Test.UnitTests
[TestClass]
public class CustomHtmlHelperTest
{
- readonly HtmlHelper Html = new HtmlHelper(new ViewContext(), new ViewPage());
+ private readonly IHtmlHelper Html;
[TestMethod]
public void EnumsWithDisplayAttributesAreFormatted()
diff --git a/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlServer.cs b/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlServer.cs
index d7c399558..d821a3e41 100644
--- a/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlServer.cs
+++ b/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlServer.cs
@@ -3,6 +3,7 @@
using Bonobo.Git.Server.Test.MembershipTests.EFTests;
using Bonobo.Git.Server.Data.Update;
using Bonobo.Git.Server.Data;
+using Microsoft.EntityFrameworkCore;
namespace Bonobo.Git.Server.Test.UnitTests
{
diff --git a/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlite.cs b/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlite.cs
index 1067bf137..8d3f55df1 100644
--- a/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlite.cs
+++ b/Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlite.cs
@@ -3,6 +3,9 @@
using Bonobo.Git.Server.Test.MembershipTests.EFTests;
using Bonobo.Git.Server.Data.Update;
using Bonobo.Git.Server.Data;
+using Bonobo.Git.Server.Security;
+using Microsoft.EntityFrameworkCore;
+using NSubstitute;
namespace Bonobo.Git.Server.Test.UnitTests
{
@@ -91,7 +94,7 @@ Foreign Key ([Team_Name]) References [Team]([Name])
);
");
- new AutomaticUpdater().RunWithContext(_connection.GetContext());
+ new AutomaticUpdater().RunWithContext(_connection.GetContext(), Substitute.For());
}
[TestMethod]
diff --git a/Bonobo.Git.Server.Test/UnitTests/GitAuthorizeAttributeTest.cs b/Bonobo.Git.Server.Test/UnitTests/GitAuthorizeAttributeTest.cs
index e7081ef95..79acddc8d 100644
--- a/Bonobo.Git.Server.Test/UnitTests/GitAuthorizeAttributeTest.cs
+++ b/Bonobo.Git.Server.Test/UnitTests/GitAuthorizeAttributeTest.cs
@@ -10,9 +10,9 @@ public class GitAuthorizeAttributeTest
[TestMethod]
public void GetRepoPathTest()
{
- var repo = GitAuthorizeAttribute.GetRepoPath("/other/test.git/info/refs", "/other");
+ var repo = GitAuthorizationHandler.GetRepoPath("/other/test.git/info/refs", "/other");
Assert.AreEqual("test", repo);
- repo = GitAuthorizeAttribute.GetRepoPath("/test.git/info/refs", "/");
+ repo = GitAuthorizationHandler.GetRepoPath("/test.git/info/refs", "/");
Assert.AreEqual("test", repo);
}
}
diff --git a/Bonobo.Git.Server.Test/app.config b/Bonobo.Git.Server.Test/app.config
deleted file mode 100644
index 7cd250804..000000000
--- a/Bonobo.Git.Server.Test/app.config
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Bonobo.Git.Server.Test/packages.config b/Bonobo.Git.Server.Test/packages.config
deleted file mode 100644
index ba78b3b29..000000000
--- a/Bonobo.Git.Server.Test/packages.config
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Bonobo.Git.Server.sln b/Bonobo.Git.Server.sln
index bf06ec7ef..d84fa0f08 100644
--- a/Bonobo.Git.Server.sln
+++ b/Bonobo.Git.Server.sln
@@ -1,60 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29001.49
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bonobo.Git.Server", "Bonobo.Git.Server\Bonobo.Git.Server.csproj", "{6129B3FE-B282-4F6F-8836-8AF66602F8DA}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bonobo.Git.Server", "Bonobo.Git.Server\Bonobo.Git.Server.csproj", "{7E7F9919-537C-4735-BFE8-80B24D3A2DE8}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bonobo.Git.Server.Test", "Bonobo.Git.Server.Test\Bonobo.Git.Server.Test.csproj", "{0B124D88-5C2B-47AD-B660-434B709A0DFF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bonobo.Git.Server.Test", "Bonobo.Git.Server.Test\Bonobo.Git.Server.Test.csproj", "{4517FCEF-5456-48AC-9909-7246F8104E5C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
- Debug|Mixed Platforms = Debug|Mixed Platforms
- Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
- Release|Mixed Platforms = Release|Mixed Platforms
- Release|x86 = Release|x86
- Test|Any CPU = Test|Any CPU
- Test|Mixed Platforms = Test|Mixed Platforms
- Test|x86 = Test|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Debug|x86.ActiveCfg = Debug|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|Any CPU.Build.0 = Release|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Release|x86.ActiveCfg = Release|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Any CPU.ActiveCfg = Test|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Any CPU.Build.0 = Test|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Mixed Platforms.ActiveCfg = Test|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|Mixed Platforms.Build.0 = Test|Any CPU
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}.Test|x86.ActiveCfg = Test|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Debug|x86.ActiveCfg = Debug|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Release|Any CPU.Build.0 = Release|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Release|x86.ActiveCfg = Release|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Test|Any CPU.ActiveCfg = Test|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Test|Any CPU.Build.0 = Test|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Test|Mixed Platforms.ActiveCfg = Test|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Test|Mixed Platforms.Build.0 = Test|Any CPU
- {0B124D88-5C2B-47AD-B660-434B709A0DFF}.Test|x86.ActiveCfg = Test|Any CPU
+ {7E7F9919-537C-4735-BFE8-80B24D3A2DE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7E7F9919-537C-4735-BFE8-80B24D3A2DE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7E7F9919-537C-4735-BFE8-80B24D3A2DE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7E7F9919-537C-4735-BFE8-80B24D3A2DE8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4517FCEF-5456-48AC-9909-7246F8104E5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4517FCEF-5456-48AC-9909-7246F8104E5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4517FCEF-5456-48AC-9909-7246F8104E5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4517FCEF-5456-48AC-9909-7246F8104E5C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- EnterpriseLibraryConfigurationToolBinariesPath = packages\Unity.2.1.505.2\lib\NET35
+ SolutionGuid = {D7177A2D-3FB7-46B2-8371-D9B3D24498A7}
EndGlobalSection
EndGlobal
diff --git a/Bonobo.Git.Server/App.config b/Bonobo.Git.Server/App.config
new file mode 100644
index 000000000..93d49879d
--- /dev/null
+++ b/Bonobo.Git.Server/App.config
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Bonobo.Git.Server/App_GlobalResources/Resources.Designer.cs b/Bonobo.Git.Server/App_GlobalResources/Resources.Designer.cs
index eafec560a..5317b5e50 100644
--- a/Bonobo.Git.Server/App_GlobalResources/Resources.Designer.cs
+++ b/Bonobo.Git.Server/App_GlobalResources/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace Bonobo.Git.Server.App_GlobalResources {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public class Resources {
diff --git a/Bonobo.Git.Server/App_GlobalResources/Resources.it-IT.designer.cs b/Bonobo.Git.Server/App_GlobalResources/Resources.it-IT.designer.cs
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Bonobo.Git.Server/App_Start/BundleConfig.cs b/Bonobo.Git.Server/App_Start/BundleConfig.cs
deleted file mode 100644
index 58dbf656c..000000000
--- a/Bonobo.Git.Server/App_Start/BundleConfig.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Bonobo.Git.Server.Helpers;
-using System.Web.Optimization;
-
-namespace Bonobo.Git.Server.App_Start
-{
- public class BundleConfig
- {
- // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
- public static void RegisterBundles(BundleCollection bundles)
- {
-
- bundles.Add(new ScriptBundle("~/bundledJs")
- .Include("~/Scripts/jquery-{version}.js")
- .Include("~/Scripts/jquery.validate*", "~/Content/uni/js/uni-form-validation.jquery.js", "~/Scripts/MicrosoftAjax.js", "~/Scripts/MicrosoftMvcAjax.js")
- .Include("~/Scripts/highlight.pack.js")
- .Include("~/Scripts/clipboard.min.js"));
-
- bundles.Add(new StyleBundle("~/Content/bundledCss")
- .Include("~/Content/components/pure/pure-min.css", new CssRewriteUrlTransformWrapper())
- .Include("~/Content/components/font-awesome/css/font-awesome.min.css", new CssRewriteUrlTransformWrapper())
- .Include("~/Content/components/highlight/styles/github.css")
- .Include("~/Content/fonts.css", "~/Content/site.css"));
- }
- }
-}
\ No newline at end of file
diff --git a/Bonobo.Git.Server/App_Start/RouteConfig.cs b/Bonobo.Git.Server/App_Start/RouteConfig.cs
index fafd1d6be..6f13791d6 100644
--- a/Bonobo.Git.Server/App_Start/RouteConfig.cs
+++ b/Bonobo.Git.Server/App_Start/RouteConfig.cs
@@ -1,32 +1,32 @@
-using System;
-using System.Web.Mvc;
-using System.Web.Routing;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Routing;
+using Microsoft.AspNetCore.Routing.Constraints;
namespace Bonobo.Git.Server.App_Start
{
public class RouteConfig
{
- public static void RegisterRoutes(RouteCollection routes)
+ public static IRouteBuilder RegisterRoutes(IRouteBuilder routes)
{
routes.MapRoute("SecureInfoRefs",
"{repositoryName}.git/info/refs",
new { controller = "Git", action = "SecureGetInfoRefs" },
- new { method = new HttpMethodConstraint("GET") });
+ new { method = new HttpMethodRouteConstraint("GET") });
routes.MapRoute("SecureUploadPack",
"{repositoryName}.git/git-upload-pack",
new { controller = "Git", action = "SecureUploadPack" },
- new { method = new HttpMethodConstraint("POST") });
+ new { method = new HttpMethodRouteConstraint("POST") });
routes.MapRoute("SecureReceivePack",
"{repositoryName}.git/git-receive-pack",
new { controller = "Git", action = "SecureReceivePack" },
- new { method = new HttpMethodConstraint("POST") });
+ new { method = new HttpMethodRouteConstraint("POST") });
routes.MapRoute("GitBaseUrl",
"{repositoryName}.git",
new { controller = "Git", action = "GitUrl" },
- new { method = new HttpMethodConstraint("GET") });
+ new { method = new HttpMethodRouteConstraint("GET") });
routes.MapRoute("IndexRoute",
"{controller}/Index/",
@@ -71,34 +71,37 @@ public static void RegisterRoutes(RouteCollection routes)
new { id = @"\d+" });
routes.MapRoute("Repository",
- "Repository/{id}/{action}/{reponame}",
- new { controller = "Repository", action = "Detail", reponame = UrlParameter.Optional },
+ "Repository/{id}/{action}/{reponame?}",
+ new { controller = "Repository", action = "Detail" },
new { id = @"\d+" });
routes.MapRoute("Account",
- "Account/{id}/{action}/{username}",
- new { controller = "Account", action = "Detail", username = UrlParameter.Optional },
+ "Account/{id}/{action}/{username?}",
+ new { controller = "Account", action = "Detail" },
new { id = @"\d+" });
routes.MapRoute("Team",
- "Team/{id}/{action}/{teamname}",
- new { controller = "Team", action = "Detail", teamname = UrlParameter.Optional },
+ "Team/{id}/{action}/{teamname?}",
+ new { controller = "Team", action = "Detail" },
new { id = @"\d+" });
- routes.MapRoute("Validation", "Validation/{action}", new { controller = "Validation", action = String.Empty });
+ routes.MapRoute("Validation", "Validation/{action}",
+ new {controller = "Validation", action = string.Empty});
routes.MapRoute("RepoCommits",
- "Repository/Commits/{id}",
- new { controller = "Repository", action = "Commits", id = string.Empty});
+ "Repository/Commits/{id?}",
+ new { controller = "Repository", action = "Commits"});
routes.MapRoute("Default",
- "{controller}/{action}/{id}",
- new { controller = "Home", action = "Index", id = String.Empty });
+ "{controller}/{action}/{id?}",
+ new { controller = "Home", action = "Index" });
- routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
+ //routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
- routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
+ //routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
+
+ return routes;
}
}
}
\ No newline at end of file
diff --git a/Bonobo.Git.Server/Attributes/AllViewsAttribute.cs b/Bonobo.Git.Server/Attributes/AllViewsAttribute.cs
index 63477e8d6..088453231 100644
--- a/Bonobo.Git.Server/Attributes/AllViewsAttribute.cs
+++ b/Bonobo.Git.Server/Attributes/AllViewsAttribute.cs
@@ -1,11 +1,14 @@
using Bonobo.Git.Server.App_GlobalResources;
using Bonobo.Git.Server.Models;
using Bonobo.Git.Server.Security;
-using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Web.Mvc;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+using Microsoft.AspNetCore.Mvc.Infrastructure;
+using Microsoft.AspNetCore.Mvc.Rendering;
+using Microsoft.AspNetCore.Mvc.Routing;
namespace Bonobo.Git.Server.Attributes
{
@@ -33,15 +36,24 @@ public int GetHashCode(T obj)
public class AllViewsFilter : ActionFilterAttribute
{
- [Dependency]
public IRepositoryPermissionService RepoPermissions { get; set; }
+ private readonly IActionContextAccessor _actionContextAccessor;
+
+ public AllViewsFilter(IRepositoryPermissionService repoPermissions, IActionContextAccessor actionContextAccessor)
+ {
+ RepoPermissions = repoPermissions;
+ _actionContextAccessor = actionContextAccessor;
+ }
+
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
- filterContext.Controller.ViewBag.PermittedRepositories = PopulateRepoGoToList(filterContext.HttpContext.User.Id(), filterContext.Controller.ControllerContext);
+ Controller controler = filterContext.Controller as Controller;
+ if (controler == null) return;
+ controler.ViewBag.PermittedRepositories = PopulateRepoGoToList(filterContext.HttpContext.User.Id());
}
- private List PopulateRepoGoToList(Guid id, ControllerContext ControllerContext)
+ private List PopulateRepoGoToList(Guid id)
{
var pullList = RepoPermissions.GetAllPermittedRepositories(id, RepositoryAccessLevel.Pull);
var adminList = RepoPermissions.GetAllPermittedRepositories(id, RepositoryAccessLevel.Administer);
@@ -49,7 +61,7 @@ private List PopulateRepoGoToList(Guid id, ControllerContext Con
.OrderBy(x => x.Name.ToLowerInvariant())
.GroupBy(x => x.Group == null ? Resources.Repository_No_Group : x.Group);
List items = new List();
- var u = new UrlHelper(ControllerContext.RequestContext);
+ var u = new UrlHelper(_actionContextAccessor.ActionContext);
var groups = new Dictionary();
foreach (var grouped in firstList)
{
diff --git a/Bonobo.Git.Server/Attributes/FileExtensionsCustom.cs b/Bonobo.Git.Server/Attributes/FileExtensionsCustom.cs
index 4346662b3..0d577cb45 100644
--- a/Bonobo.Git.Server/Attributes/FileExtensionsCustom.cs
+++ b/Bonobo.Git.Server/Attributes/FileExtensionsCustom.cs
@@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Web;
+using Microsoft.AspNetCore.Http;
namespace Bonobo.Git.Server.Attributes
{
@@ -74,7 +75,7 @@ public override bool IsValid(object value)
return true;
}
- HttpPostedFileBase valueAsString = value as HttpPostedFileBase;
+ IFormFile valueAsString = value as IFormFile;
if (valueAsString != null)
{
diff --git a/Bonobo.Git.Server/Attributes/GitAuthorizeAttribute.cs b/Bonobo.Git.Server/Attributes/GitAuthorizeAttribute.cs
index f0b547206..4a0e0a68a 100644
--- a/Bonobo.Git.Server/Attributes/GitAuthorizeAttribute.cs
+++ b/Bonobo.Git.Server/Attributes/GitAuthorizeAttribute.cs
@@ -1,92 +1,45 @@
using System;
-using System.Net;
using System.Security.Claims;
using System.Text;
-using System.Web;
-using System.Web.Mvc;
+using System.Threading.Tasks;
using Bonobo.Git.Server.Data;
using Bonobo.Git.Server.Security;
-using Microsoft.Practices.Unity;
using Bonobo.Git.Server.Helpers;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
using Serilog;
namespace Bonobo.Git.Server
{
- public class GitAuthorizeAttribute : AuthorizeAttribute
+ public class GitRequirement : IAuthorizationRequirement
+ { }
+
+ public class GitAuthorizationHandler : AuthorizationHandler
{
- [Dependency]
+ private readonly IHttpContextAccessor _httpContextAccessor;
public IMembershipService MembershipService { get; set; }
-
- [Dependency]
public IAuthenticationProvider AuthenticationProvider { get; set; }
-
- [Dependency]
public IRepositoryPermissionService RepositoryPermissionService { get; set; }
-
- [Dependency]
public IRepositoryRepository RepositoryRepository { get; set; }
- public static string GetRepoPath(string path, string applicationPath)
+ public GitAuthorizationHandler(IHttpContextAccessor httpContextAccessor, IMembershipService membershipService,
+ IAuthenticationProvider authenticationProvider, IRepositoryPermissionService repositoryPermissionService,
+ IRepositoryRepository repositoryRepository)
{
- var repo = path.Replace(applicationPath, "").Replace("/","");
- return repo.Substring(0, repo.IndexOf(".git"));
+ _httpContextAccessor = httpContextAccessor;
+ MembershipService = membershipService;
+ AuthenticationProvider = authenticationProvider;
+ RepositoryPermissionService = repositoryPermissionService;
+ RepositoryRepository = repositoryRepository;
}
- public override void OnAuthorization(System.Web.Mvc.AuthorizationContext filterContext)
+ public static string GetRepoPath(string path, string applicationPath)
{
- if (filterContext == null)
- {
- throw new ArgumentNullException("filterContext");
- }
-
- HttpContextBase httpContext = filterContext.HttpContext;
-
- string incomingRepoName = GetRepoPath(httpContext.Request.Path, httpContext.Request.ApplicationPath);
- string repoName = Repository.NormalizeRepositoryName(incomingRepoName, RepositoryRepository);
-
- // Add header to prevent redirection to login page even if we fail auth later (see IAuthenticationProvider.Configure)
- // If we don't fail auth later, then this is benign
- httpContext.Request.Headers.Add("AuthNoRedirect", "1");
-
- if (httpContext.Request.IsAuthenticated && httpContext.User != null && httpContext.User.Identity is System.Security.Claims.ClaimsIdentity)
- {
- // We already have a claims id, we don't need to worry about the rest of these checks
- Log.Verbose("GitAuth: User {username} already has identity", httpContext.User.DisplayName());
- return;
- }
-
- string authHeader = httpContext.Request.Headers["Authorization"];
-
- if (String.IsNullOrEmpty(authHeader))
- {
- // We don't have an auth header, but if we're doing an anonymous operation, that's OK
- if (RepositoryPermissionService.HasPermission(Guid.Empty, repoName, RepositoryAccessLevel.Pull))
- {
- // Allow this through. If it turns out they're actually trying to do an anon push and that's not allowed for this repo
- // then the GitController will reject them in there
- Log.Information("GitAuth: No auth header, anon operation may be allowed");
- return;
- }
- else
- {
- // If we're not even allowed to do an anonymous pull, then we should bounce this now,
- // and tell the other end to try again with an auth header included next time
- httpContext.Response.Headers.Add("WWW-Authenticate", "Basic realm=\"Bonobo Git\"");
- filterContext.Result = new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
-
- Log.Warning("GitAuth: No auth header, anon operations not allowed");
- return;
- }
- }
-
- // Process the auth header and see if we've been given valid credentials
- if (!IsUserAuthorized(authHeader, httpContext))
- {
- filterContext.Result = new HttpStatusCodeResult(HttpStatusCode.Unauthorized);
- }
+ var repo = path.Replace(applicationPath, "").Replace("/","");
+ return repo.Substring(0, repo.IndexOf(".git"));
}
- private bool IsUserAuthorized(string authHeader, HttpContextBase httpContext)
+ private bool IsUserAuthorized(string authHeader, HttpContext httpContext)
{
byte[] encodedDataAsBytes = Convert.FromBase64String(authHeader.Replace("Basic ", String.Empty));
string value = Encoding.ASCII.GetString(encodedDataAsBytes);
@@ -135,5 +88,63 @@ private bool IsUserAuthorized(string authHeader, HttpContextBase httpContext)
Log.Warning("GitAuth: User {username} not authorized", username);
return false;
}
+
+ protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, GitRequirement requirement)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+
+ HttpContext httpContext = _httpContextAccessor.HttpContext;
+
+ string incomingRepoName = GetRepoPath(httpContext.Request.Path, httpContext.Request.PathBase);
+ string repoName = Repository.NormalizeRepositoryName(incomingRepoName, RepositoryRepository);
+
+ // Add header to prevent redirection to login page even if we fail auth later (see IAuthenticationProvider.Configure)
+ // If we don't fail auth later, then this is benign
+ httpContext.Request.Headers.Add("AuthNoRedirect", "1");
+
+ if (context.User != null && context.User.Identity.IsAuthenticated && context.User.Identity is ClaimsIdentity)
+ {
+ // We already have a claims id, we don't need to worry about the rest of these checks
+ Log.Verbose("GitAuth: User {username} already has identity", httpContext.User.DisplayName());
+ context.Succeed(requirement);
+ return Task.FromResult(0);
+ }
+
+ string authHeader = httpContext.Request.Headers["Authorization"];
+
+ if (String.IsNullOrEmpty(authHeader))
+ {
+ // We don't have an auth header, but if we're doing an anonymous operation, that's OK
+ if (RepositoryPermissionService.HasPermission(Guid.Empty, repoName, RepositoryAccessLevel.Pull))
+ {
+ // Allow this through. If it turns out they're actually trying to do an anon push and that's not allowed for this repo
+ // then the GitController will reject them in there
+ Log.Information("GitAuth: No auth header, anon operation may be allowed");
+ context.Succeed(requirement);
+ return Task.FromResult(0);
+ }
+ else
+ {
+ // If we're not even allowed to do an anonymous pull, then we should bounce this now,
+ // and tell the other end to try again with an auth header included next time
+ httpContext.Response.Headers.Add("WWW-Authenticate", "Basic realm=\"Bonobo Git\"");
+ context.Fail();
+
+ Log.Warning("GitAuth: No auth header, anon operations not allowed");
+ return Task.FromResult(0);
+ }
+ }
+
+ // Process the auth header and see if we've been given valid credentials
+ if (!IsUserAuthorized(authHeader, httpContext))
+ {
+ context.Fail();
+ }
+
+ return Task.FromResult(0);
+ }
}
}
\ No newline at end of file
diff --git a/Bonobo.Git.Server/Attributes/IsValidRegexAttribute.cs b/Bonobo.Git.Server/Attributes/IsValidRegexAttribute.cs
index 3bbbd6b56..1afa672ed 100644
--- a/Bonobo.Git.Server/Attributes/IsValidRegexAttribute.cs
+++ b/Bonobo.Git.Server/Attributes/IsValidRegexAttribute.cs
@@ -1,14 +1,7 @@
-using Bonobo.Git.Server.Data;
-using Bonobo.Git.Server.App_GlobalResources;
-using Microsoft.Practices.Unity;
+using Bonobo.Git.Server.App_GlobalResources;
using System;
-using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Web;
-using System.Web.Mvc;
-using Bonobo.Git.Server.Models;
using System.Text.RegularExpressions;
namespace Bonobo.Git.Server.Attributes
diff --git a/Bonobo.Git.Server/Attributes/RepositoryNameNormalizerAttribute.cs b/Bonobo.Git.Server/Attributes/RepositoryNameNormalizerAttribute.cs
index f79b4a884..8acc0a701 100644
--- a/Bonobo.Git.Server/Attributes/RepositoryNameNormalizerAttribute.cs
+++ b/Bonobo.Git.Server/Attributes/RepositoryNameNormalizerAttribute.cs
@@ -1,6 +1,5 @@
-using System.Web.Mvc;
using Bonobo.Git.Server.Data;
-using Microsoft.Practices.Unity;
+using Microsoft.AspNetCore.Mvc.Filters;
namespace Bonobo.Git.Server
{
@@ -13,27 +12,28 @@ namespace Bonobo.Git.Server
///
public class RepositoryNameNormalizerAttribute : ActionFilterAttribute
{
+ public IRepositoryRepository RepositoryRepository { get; set; }
+
private readonly string _repositoryNameParameterName;
- public RepositoryNameNormalizerAttribute(string repositoryNameParameterName)
+ public RepositoryNameNormalizerAttribute(IRepositoryRepository repositoryRepository, string repositoryNameParameterName)
{
+ RepositoryRepository = repositoryRepository;
_repositoryNameParameterName = repositoryNameParameterName;
}
- [Dependency]
- public IRepositoryRepository RepositoryRepository { get; set; }
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
object incomingRepositoryNameParameter;
- if(filterContext.ActionParameters.TryGetValue(_repositoryNameParameterName, out incomingRepositoryNameParameter))
+ if(filterContext.ActionArguments.TryGetValue(_repositoryNameParameterName, out incomingRepositoryNameParameter))
{
var incomingRepositoryName = (string)incomingRepositoryNameParameter;
var normalizedName = Repository.NormalizeRepositoryName(incomingRepositoryName, RepositoryRepository);
if (normalizedName != incomingRepositoryName)
{
// We've had to correct the incoming repository name
- filterContext.ActionParameters[_repositoryNameParameterName] = normalizedName;
+ filterContext.ActionArguments[_repositoryNameParameterName] = normalizedName;
}
}
}
diff --git a/Bonobo.Git.Server/Attributes/UniqueRepoNameAttribute.cs b/Bonobo.Git.Server/Attributes/UniqueRepoNameAttribute.cs
index 2b642ba26..1986ecd8e 100644
--- a/Bonobo.Git.Server/Attributes/UniqueRepoNameAttribute.cs
+++ b/Bonobo.Git.Server/Attributes/UniqueRepoNameAttribute.cs
@@ -1,14 +1,9 @@
using Bonobo.Git.Server.Data;
using Bonobo.Git.Server.App_GlobalResources;
-using Microsoft.Practices.Unity;
-using System;
-using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Web;
-using System.Web.Mvc;
using Bonobo.Git.Server.Models;
+using Microsoft.Extensions.DependencyInjection;
namespace Bonobo.Git.Server.Attributes
{
@@ -22,7 +17,7 @@ protected override ValidationResult IsValid(object value, ValidationContext cont
return new ValidationResult("empty repo name?");
}
- IRepositoryRepository RepositoryRepository = DependencyResolver.Current.GetService();
+ IRepositoryRepository RepositoryRepository = context.GetService();
if (RepositoryRepository.NameIsUnique(value.ToString(), ((RepositoryDetailModel)context.ObjectInstance).Id))
{
return ValidationResult.Success;
diff --git a/Bonobo.Git.Server/Attributes/WebAuthorizeAttribute.cs b/Bonobo.Git.Server/Attributes/WebAuthorizeAttribute.cs
index e19075752..4e271b93d 100644
--- a/Bonobo.Git.Server/Attributes/WebAuthorizeAttribute.cs
+++ b/Bonobo.Git.Server/Attributes/WebAuthorizeAttribute.cs
@@ -1,14 +1,27 @@
using System;
using System.Linq;
-using System.Web.Mvc;
-using System.Web.Routing;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
namespace Bonobo.Git.Server
{
- [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
- public class WebAuthorizeAttribute : AuthorizeAttribute
+ public class WebRequirement : IAuthorizationRequirement
{
- public new string Roles
+
+ }
+
+ public class WebAuthorizationHandler : AuthorizationHandler
+ {
+ private string[] roles;
+
+ public WebAuthorizationHandler()
+ {
+
+ }
+
+ public string Roles
{
get
{
@@ -20,24 +33,25 @@ public class WebAuthorizeAttribute : AuthorizeAttribute
}
}
- private string[] roles;
-
- public override void OnAuthorization(AuthorizationContext filterContext)
+ protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, WebRequirement requirement)
{
- base.OnAuthorization(filterContext);
+ var redirectContext = context.Resource as AuthorizationFilterContext;
+ if (!context.User.IsInRole(Definitions.Roles.Member) && !context.User.Identity.IsAuthenticated)
+ {
+ context.Fail();
+ redirectContext.Result = new RedirectToActionResult("Unauthorized", "Home", null);
+ return Task.CompletedTask;
+ }
- if (!(filterContext.Result is HttpUnauthorizedResult))
+ if (roles != null && roles.Length != 0 && !context.User.Roles().Any(x => roles.Contains(x)))
{
- if (!filterContext.HttpContext.User.IsInRole(Definitions.Roles.Member) && !filterContext.HttpContext.User.Identity.IsAuthenticated)
- {
- filterContext.Result = new RedirectResult("~/Home/Unauthorized");
- }
-
- if (roles != null && roles.Length != 0 && !filterContext.HttpContext.User.Roles().Any(x => roles.Contains(x)))
- {
- filterContext.Result = new RedirectResult("~/Home/Unauthorized");
- }
+ context.Fail();
+ redirectContext.Result = new RedirectToActionResult("Unauthorized", "Home", null);
+ return Task.CompletedTask;
}
+
+ context.Succeed(requirement);
+ return Task.CompletedTask;
}
}
}
\ No newline at end of file
diff --git a/Bonobo.Git.Server/Attributes/WebAuthorizeRepositoryAttribute.cs b/Bonobo.Git.Server/Attributes/WebAuthorizeRepositoryAttribute.cs
index 687a6b72f..df6f9f390 100644
--- a/Bonobo.Git.Server/Attributes/WebAuthorizeRepositoryAttribute.cs
+++ b/Bonobo.Git.Server/Attributes/WebAuthorizeRepositoryAttribute.cs
@@ -1,59 +1,63 @@
-using System.Web.Mvc;
-using System.Web.Routing;
-using Bonobo.Git.Server.Data;
-using Bonobo.Git.Server.Security;
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Routing;
-using Microsoft.Practices.Unity;
-using System;
+using Bonobo.Git.Server.Security;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc.Infrastructure;
namespace Bonobo.Git.Server
{
- public class WebAuthorizeRepositoryAttribute : WebAuthorizeAttribute
+ public class WebRepositoryAuthorizationHandler : WebAuthorizationHandler
{
- [Dependency]
+ private readonly IActionContextAccessor _actionContextAccessor;
public IRepositoryPermissionService RepositoryPermissionService { get; set; }
public bool RequiresRepositoryAdministrator { get; set; }
- public override void OnAuthorization(AuthorizationContext filterContext)
+ public WebRepositoryAuthorizationHandler(IActionContextAccessor actionContextAccessor, IRepositoryPermissionService repositoryPermissionService)
{
- base.OnAuthorization(filterContext);
+ _actionContextAccessor = actionContextAccessor;
+ RepositoryPermissionService = repositoryPermissionService;
+ }
- if (!(filterContext.Result is HttpUnauthorizedResult))
+ protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, WebRequirement requirement)
+ {
+ Guid repoId;
+ var urlhelper = new UrlHelper(_actionContextAccessor.ActionContext);
+ if (Guid.TryParse(_actionContextAccessor.ActionContext.RouteData.Values["id"].ToString(), out repoId))
{
- Guid repoId;
- var urlhelper = new UrlHelper(filterContext.RequestContext);
- if (Guid.TryParse(filterContext.Controller.ControllerContext.RouteData.Values["id"].ToString(), out repoId))
- {
- Guid userId = filterContext.HttpContext.User.Id();
+ Guid userId = context.User.Id();
- var requiredAccess = RequiresRepositoryAdministrator
- ? RepositoryAccessLevel.Administer
- : RepositoryAccessLevel.Push;
+ var requiredAccess = RequiresRepositoryAdministrator
+ ? RepositoryAccessLevel.Administer
+ : RepositoryAccessLevel.Push;
- if (RepositoryPermissionService.HasPermission(userId, repoId, requiredAccess))
- {
- return;
- }
+ if (RepositoryPermissionService.HasPermission(userId, repoId, requiredAccess))
+ {
+ context.Succeed(requirement);
+ return Task.FromResult(0);
+ }
- filterContext.Result = new RedirectResult(urlhelper.Action("Unauthorized", "Home"));
+ //filterContext.Result = new RedirectResult(urlhelper.Action("Unauthorized", "Home"));
+ }
+ else
+ {
+ var rd = _actionContextAccessor.ActionContext.RouteData;
+ rd.Values.TryGetValue("action", out var action);
+ rd.Values.TryGetValue("controller", out var controller);
+ if (((string)action).Equals("index", StringComparison.OrdinalIgnoreCase) && ((string)controller).Equals("repository", StringComparison.OrdinalIgnoreCase))
+ {
+ //filterContext.Result = new RedirectResult(urlhelper.Action("Unauthorized", "Home"));
}
else
{
- var rd = filterContext.RequestContext.RouteData;
- var action = rd.GetRequiredString("action");
- var controller = rd.GetRequiredString("controller");
- if (action.Equals("index", StringComparison.OrdinalIgnoreCase) && controller.Equals("repository", StringComparison.OrdinalIgnoreCase))
- {
- filterContext.Result = new RedirectResult(urlhelper.Action("Unauthorized", "Home"));
- }
- else
- {
- filterContext.Controller.TempData["RepositoryNotFound"] = true;
- filterContext.Result = new RedirectResult(urlhelper.Action("Index", "Repository"));
- }
+ //filterContext.Controller.TempData["RepositoryNotFound"] = true;
+ //filterContext.Result = new RedirectResult(urlhelper.Action("Index", "Repository"));
}
}
+ return Task.FromResult(0);
}
}
}
diff --git a/Bonobo.Git.Server/Bonobo.Git.Server.csproj b/Bonobo.Git.Server/Bonobo.Git.Server.csproj
index ff55b58b6..49a60a6e6 100644
--- a/Bonobo.Git.Server/Bonobo.Git.Server.csproj
+++ b/Bonobo.Git.Server/Bonobo.Git.Server.csproj
@@ -1,775 +1,75 @@
-
-
-
-
-
-
-
+
+
- Debug
- AnyCPU
-
-
- 2.0
- {6129B3FE-B282-4F6F-8836-8AF66602F8DA}
- {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
- Library
- Properties
- Bonobo.Git.Server
- Bonobo.Git.Server
- v4.6
- false
-
- true
-
-
- 4.0
-
-
-
- 4.0
-
- enabled
- enabled
- false
- ..\
- true
- true
-
-
+ netcoreapp2.2
-
- true
- full
- false
- bin\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- bin\
- TRACE
- prompt
- 4
- true
- false
- true
- false
- false
-
-
-
- ..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll
- True
-
-
- ..\packages\CommonMark.NET.0.15.1\lib\net45\CommonMark.dll
- True
-
-
- ..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll
- True
-
-
- ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
- True
-
-
- ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
- True
-
-
- ..\packages\LibGit2Sharp.0.23.1\lib\net40\LibGit2Sharp.dll
- True
-
-
- ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
-
-
-
- ..\packages\Microsoft.IdentityModel.Logging.1.1.3\lib\net451\Microsoft.IdentityModel.Logging.dll
- True
-
-
- ..\packages\Microsoft.IdentityModel.Protocol.Extensions.1.0.4.403061554\lib\net45\Microsoft.IdentityModel.Protocol.Extensions.dll
- True
-
-
- ..\packages\Microsoft.IdentityModel.Tokens.5.1.3\lib\net451\Microsoft.IdentityModel.Tokens.dll
- True
-
-
- ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll
- True
-
-
- ..\packages\Microsoft.Owin.Host.SystemWeb.3.0.1\lib\net45\Microsoft.Owin.Host.SystemWeb.dll
- True
-
-
- ..\packages\Microsoft.Owin.Security.3.0.1\lib\net45\Microsoft.Owin.Security.dll
- True
-
-
- ..\packages\Microsoft.Owin.Security.Cookies.3.0.1\lib\net45\Microsoft.Owin.Security.Cookies.dll
- True
-
-
- ..\packages\Microsoft.Owin.Security.WsFederation.3.0.1\lib\net45\Microsoft.Owin.Security.WsFederation.dll
- True
-
-
- ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll
- True
-
-
- ..\packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.dll
- True
-
-
- ..\packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.Configuration.dll
- True
-
-
- ..\packages\Unity.Mvc.4.0.1\lib\net45\Microsoft.Practices.Unity.Mvc.dll
- True
-
-
- ..\packages\Unity.4.0.1\lib\net45\Microsoft.Practices.Unity.RegistrationByConvention.dll
- True
-
-
-
- ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
- True
-
-
- ..\packages\MediaTypeMap.2.1.0.0\lib\net40\MimeTypeMap.dll
- True
-
-
- ..\packages\MvcCheckBoxList.1.4.5\lib\net45\MvcCheckBoxList.dll
- True
-
-
- ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
- True
-
-
- ..\packages\Owin.1.0\lib\net40\Owin.dll
- True
-
-
- ..\packages\Serilog.2.4.0\lib\net46\Serilog.dll
- True
-
-
- ..\packages\Serilog.Settings.AppSettings.2.1.0\lib\net45\Serilog.Settings.AppSettings.dll
- True
-
-
- ..\packages\Serilog.Sinks.File.3.2.0\lib\net45\Serilog.Sinks.File.dll
- True
-
-
- ..\packages\Serilog.Sinks.RollingFile.3.3.0\lib\net45\Serilog.Sinks.RollingFile.dll
- True
-
-
-
-
- ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net46\System.Data.SQLite.dll
- True
-
-
- ..\packages\System.Data.SQLite.EF6.1.0.104.0\lib\net46\System.Data.SQLite.EF6.dll
- True
-
-
- ..\packages\System.Data.SQLite.Linq.1.0.104.0\lib\net46\System.Data.SQLite.Linq.dll
- True
-
-
-
-
-
- 3.5
-
-
-
- ..\packages\System.IdentityModel.Tokens.Jwt.4.0.4.403061554\lib\net45\System.IdentityModel.Tokens.Jwt.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll
- True
-
-
- ..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll
- True
-
-
- ..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll
- True
-
-
- ..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll
- True
-
-
- False
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll
- True
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll
- True
-
-
- ..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll
- True
-
-
-
-
-
-
-
- ..\packages\UDE.CSharp.1.1.0\lib\Ude.dll
- True
-
-
- ..\packages\WebActivatorEx.2.2.0\lib\net40\WebActivatorEx.dll
- True
-
-
- ..\packages\WebGrease.1.6.0\lib\WebGrease.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Global.asax
-
-
-
-
-
-
-
-
-
-
-
+
+
+ false
+ 7
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Resources.af-ZA.designer.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Designer
-
-
-
- Designer
-
-
-
-
-
-
- Designer
-
-
- changelog.md
-
-
- license.md
-
-
- readme.md
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Web.config
-
-
- Web.config
-
-
- Web.config
- Designer
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
- True
+
True
+ True
Resources.resx
-
+
+
+
+
PublicResXFileCodeGenerator
Resources.Designer.cs
- Designer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 10.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
-
-
- true
- bin\
- DEBUG;TRACE
- full
- AnyCPU
- prompt
- MinimumRecommendedRules.ruleset
-
-
-
-
-
-
-
-
-
-
-
-
- True
-
-
-
-
-
-
-
-
-
-
- if not exist "$(TargetDir)NativeBinaries" md "$(TargetDir)NativeBinaries"
-if not exist "$(TargetDir)NativeBinaries\x86" md "$(TargetDir)NativeBinaries\x86"
-xcopy /s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.21.0.176\lib\net40\NativeBinaries\x86\*.*" "$(TargetDir)NativeBinaries\x86\"
-if not exist "$(TargetDir)NativeBinaries\amd64" md "$(TargetDir)NativeBinaries\amd64"
-xcopy/s /y /d "$(SolutionDir)packages\LibGit2Sharp.0.21.0.176\lib\net40\NativeBinaries\amd64\*.*" "$(TargetDir)NativeBinaries\amd64\"
-
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
diff --git a/Bonobo.Git.Server/Bonobo.Git.Server.csproj.DotSettings b/Bonobo.Git.Server/Bonobo.Git.Server.csproj.DotSettings
deleted file mode 100644
index 73e96563f..000000000
--- a/Bonobo.Git.Server/Bonobo.Git.Server.csproj.DotSettings
+++ /dev/null
@@ -1,2 +0,0 @@
-
- CSharp60
\ No newline at end of file
diff --git a/Bonobo.Git.Server/Configuration/ActiveDirectorySettings.cs b/Bonobo.Git.Server/Configuration/ActiveDirectorySettings.cs
index 81f473473..c69f3e5e9 100644
--- a/Bonobo.Git.Server/Configuration/ActiveDirectorySettings.cs
+++ b/Bonobo.Git.Server/Configuration/ActiveDirectorySettings.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
-using System.Linq;
-using System.Web;
namespace Bonobo.Git.Server.Configuration
{
diff --git a/Bonobo.Git.Server/Configuration/ConfigurationEntry.cs b/Bonobo.Git.Server/Configuration/ConfigurationEntry.cs
index e8843e324..6b016f806 100644
--- a/Bonobo.Git.Server/Configuration/ConfigurationEntry.cs
+++ b/Bonobo.Git.Server/Configuration/ConfigurationEntry.cs
@@ -1,20 +1,20 @@
using System.Configuration;
using System.IO;
-using System.Web;
-using System.Web.Hosting;
using System.Xml.Serialization;
+using Bonobo.Git.Server.Extensions;
+using Microsoft.AspNetCore.Hosting;
namespace Bonobo.Git.Server.Configuration
{
public abstract class ConfigurationEntry where Entry : ConfigurationEntry, new()
{
private static Entry _current = null;
+ protected static IHostingEnvironment hostingEnvironment;
private static readonly object _sync = new object();
private static readonly XmlSerializer _serializer = new XmlSerializer(typeof(Entry));
- private static readonly string _configPath = Path.IsPathRooted(ConfigurationManager.AppSettings["UserConfiguration"])
- ? ConfigurationManager.AppSettings["UserConfiguration"]
- : HostingEnvironment.MapPath(ConfigurationManager.AppSettings["UserConfiguration"]);
-
+ private static string ConfigPath => Path.IsPathRooted(ConfigurationManager.AppSettings["UserConfiguration"])
+ ? ConfigurationManager.AppSettings["UserConfiguration"]
+ : hostingEnvironment.MapPath(ConfigurationManager.AppSettings["UserConfiguration"]);
public static Entry Current { get { return _current ?? Load(); } }
@@ -27,7 +27,7 @@ private static Entry Load()
{
try
{
- using (var stream = File.Open(_configPath, FileMode.Open))
+ using (var stream = File.Open(ConfigPath, FileMode.Open))
{
_current = _serializer.Deserialize(stream) as Entry;
}
@@ -48,7 +48,7 @@ public void Save()
{
if (_current != null)
{
- using (var stream = File.Open(_configPath, FileMode.Create))
+ using (var stream = File.Open(ConfigPath, FileMode.Create))
{
_serializer.Serialize(stream, _current);
}
diff --git a/Bonobo.Git.Server/Configuration/DiagnosticReporter.cs b/Bonobo.Git.Server/Configuration/DiagnosticReporter.cs
index 706d7f8aa..f3f4880a7 100644
--- a/Bonobo.Git.Server/Configuration/DiagnosticReporter.cs
+++ b/Bonobo.Git.Server/Configuration/DiagnosticReporter.cs
@@ -4,9 +4,11 @@
using System.Linq;
using System.Net;
using System.Text;
-using System.Web.Hosting;
using Bonobo.Git.Server.Data;
+using Bonobo.Git.Server.Extensions;
using Bonobo.Git.Server.Security;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.DependencyInjection;
namespace Bonobo.Git.Server.Configuration
{
@@ -18,16 +20,22 @@ namespace Bonobo.Git.Server.Configuration
///
public class DiagnosticReporter
{
+ private readonly IHostingEnvironment _hostingEnvironment;
private readonly StringBuilder _report = new StringBuilder();
private readonly UserConfiguration _userConfig = UserConfiguration.Current;
- public string GetVerificationReport()
+ public DiagnosticReporter(IHostingEnvironment hostingEnvironment)
{
- RunReport();
+ _hostingEnvironment = hostingEnvironment;
+ }
+
+ public string GetVerificationReport(IServiceProvider serviceProvider)
+ {
+ RunReport(serviceProvider);
return _report.ToString();
}
- private void RunReport()
+ private void RunReport(IServiceProvider serviceProvider)
{
DumpAppSettings();
CheckUserConfigurationFile();
@@ -35,7 +43,7 @@ private void RunReport()
CheckGitSettings();
CheckFederatedAuth();
CheckADMembership();
- CheckInternalMembership();
+ CheckInternalMembership(serviceProvider);
ExceptionLog();
}
@@ -180,13 +188,15 @@ private bool DirectoryIsWritable(string directory)
}
}
- private void CheckInternalMembership()
+ private void CheckInternalMembership(IServiceProvider serviceProvider)
{
_report.AppendLine("Internal Membership");
if (AppSetting("MembershipService") == "Internal")
{
- SafelyReport("User count", () => new EFMembershipService { CreateContext = () => new BonoboGitServerContext() }.GetAllUsers().Count);
+ SafelyReport("User count",
+ () => new EFMembershipService(serviceProvider.GetService)
+ .GetAllUsers().Count);
}
else
{
@@ -203,7 +213,7 @@ private void ExceptionLog()
_report.AppendLine("Exception Log");
SafelyRun(() =>
{
- var nameFormat = MvcApplication.GetLogFileNameFormat();
+ var nameFormat = Startup.GetLogFileNameFormat(_hostingEnvironment);
var todayLogFileName = nameFormat.Replace("{Date}", DateTime.Now.ToString("yyyyMMdd"));
SafelyReport("LogFileName: ", () => todayLogFileName);
var chunkSize = 10000;
@@ -263,7 +273,7 @@ private void SafelyReport(string tag, Func