Compare commits

...

3 commits

Author SHA1 Message Date
39ff100eab test all of it 2026-07-05 18:16:52 +01:00
4d51267dfd refatco and cleanup 2026-07-05 17:54:36 +01:00
94eb8e2fff refacto name spaces 2026-07-05 17:23:22 +01:00
59 changed files with 533 additions and 441 deletions

22
.gitignore vendored
View file

@ -1,24 +1,8 @@
.sass-cache/ .sass-cache/
/src/isnd/bin/ bin/
/src/isnd/obj/ obj/
/src/isn/obj
/src/isn/bin
/src/isn/.vscode/
/test/isnd.tests/obj/
/test/isnd.tests/bin/
/packages/
bower_components/ bower_components/
/test/isn.tests/bin appsettings.*.json
/test/isn.tests/obj/
appsettings.Testing.json
appsettings.Development.json
/wwwroot/.sass-cache/
/src/isnd/wwwroot/.sass-cache/
/src/isn.abst/bin
/src/isn.abst/obj
/src/isnd/packages/
/test/data/test-isn/bin/
/test/data/test-isn/obj
.fake .fake
/artifacts/ /artifacts/
/.vs/ /.vs/

11
Directory.Build.props Normal file
View file

@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<Version>1.0.8</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<UserSecretsId>85fd766d-5d23-4476-aed1-463b2942e86a</UserSecretsId>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
</PropertyGroup>
</Project>

View file

@ -1,5 +0,0 @@
mode: Mainline
branches: {}
ignore:
sha: []
merge-message-formats: {}

View file

@ -55,8 +55,8 @@ sudo systemctl enable isnd
````bash ````bash
sudo mkdir /usr/local/lib/isn sudo mkdir /usr/local/lib/isn
sudo cp -a src/isn/bin/Release/net6.0/* /usr/local/lib/isn sudo cp -a src/isn/bin/Release/net7.0/* /usr/local/lib/isn
sudo chown -R root.root /usr/local/lib/isn sudo chown -R root:root /usr/local/lib/isn
sudo ln -s /usr/local/lib/isn/isn /usr/local/bin/isn sudo ln -s /usr/local/lib/isn/isn /usr/local/bin/isn
```` ````

34
isn.sln
View file

@ -15,7 +15,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn", "src\isn\isn.csproj",
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn.tests", "test\isn.tests\isn.tests.csproj", "{305F640E-11BA-44F9-95E0-C6882E9CD151}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn.tests", "test\isn.tests\isn.tests.csproj", "{305F640E-11BA-44F9-95E0-C6882E9CD151}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn.abst", "src\isn.abst\isn.abst.csproj", "{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn.abstract", "src\isn.abstract\isn.abstract.csproj", "{F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -26,9 +26,6 @@ Global
Release|x64 = Release|x64 Release|x64 = Release|x64
Release|x86 = Release|x86 Release|x86 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9D758F00-17FF-433D-B088-F9C2D97C9BD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9D758F00-17FF-433D-B088-F9C2D97C9BD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D758F00-17FF-433D-B088-F9C2D97C9BD1}.Debug|Any CPU.Build.0 = Debug|Any CPU {9D758F00-17FF-433D-B088-F9C2D97C9BD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
@ -78,24 +75,27 @@ Global
{305F640E-11BA-44F9-95E0-C6882E9CD151}.Release|x64.Build.0 = Release|Any CPU {305F640E-11BA-44F9-95E0-C6882E9CD151}.Release|x64.Build.0 = Release|Any CPU
{305F640E-11BA-44F9-95E0-C6882E9CD151}.Release|x86.ActiveCfg = Release|Any CPU {305F640E-11BA-44F9-95E0-C6882E9CD151}.Release|x86.ActiveCfg = Release|Any CPU
{305F640E-11BA-44F9-95E0-C6882E9CD151}.Release|x86.Build.0 = Release|Any CPU {305F640E-11BA-44F9-95E0-C6882E9CD151}.Release|x86.Build.0 = Release|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|Any CPU.Build.0 = Debug|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x64.ActiveCfg = Debug|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Debug|x64.ActiveCfg = Debug|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x64.Build.0 = Debug|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Debug|x64.Build.0 = Debug|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x86.ActiveCfg = Debug|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Debug|x86.ActiveCfg = Debug|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x86.Build.0 = Debug|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Debug|x86.Build.0 = Debug|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|Any CPU.ActiveCfg = Release|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|Any CPU.Build.0 = Release|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Release|Any CPU.Build.0 = Release|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x64.ActiveCfg = Release|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Release|x64.ActiveCfg = Release|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x64.Build.0 = Release|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Release|x64.Build.0 = Release|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x86.ActiveCfg = Release|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Release|x86.ActiveCfg = Release|Any CPU
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x86.Build.0 = Release|Any CPU {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{9D758F00-17FF-433D-B088-F9C2D97C9BD1} = {3C312E42-9A47-4BED-8265-A405FCA6AFFF} {9D758F00-17FF-433D-B088-F9C2D97C9BD1} = {3C312E42-9A47-4BED-8265-A405FCA6AFFF}
{468DB0E4-6221-4E01-BEFF-F452865E59C1} = {E8A2DF68-847A-4D88-B002-64FB666F696C} {468DB0E4-6221-4E01-BEFF-F452865E59C1} = {E8A2DF68-847A-4D88-B002-64FB666F696C}
{910E800A-59AE-46C4-B7C7-879986179246} = {E8A2DF68-847A-4D88-B002-64FB666F696C} {910E800A-59AE-46C4-B7C7-879986179246} = {E8A2DF68-847A-4D88-B002-64FB666F696C}
{305F640E-11BA-44F9-95E0-C6882E9CD151} = {3C312E42-9A47-4BED-8265-A405FCA6AFFF} {305F640E-11BA-44F9-95E0-C6882E9CD151} = {3C312E42-9A47-4BED-8265-A405FCA6AFFF}
{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7} = {E8A2DF68-847A-4D88-B002-64FB666F696C} {F0671F01-ADD7-47A6-8A29-1AAC8565DBE2} = {E8A2DF68-847A-4D88-B002-64FB666F696C}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

11
src/Directory.Build.props Normal file
View file

@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net10.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<Version>1.0.8</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<UserSecretsId>85fd766d-5d23-4476-aed1-463b2942e86a</UserSecretsId>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
</PropertyGroup>
</Project>

View file

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageVersion>1.0.1</PackageVersion>
<Version>1.0.7</Version>
<TargetFrameworks>net7.0</TargetFrameworks>
<NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>1.0.7.0</AssemblyVersion>
<FileVersion>1.0.7.0</FileVersion>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
<Reference Include="System.ComponentModel.DataAnnotations" Version="4.0.0.0"/>
</ItemGroup>
</Project>

View file

@ -1,4 +1,6 @@
using isn.abst;
using Isn.Abstract;
namespace isnd.Entities namespace isnd.Entities
{ {

View file

@ -1,7 +1,7 @@
using isnd.Data.Catalog; using isnd.Data.Catalog;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn.Abstract namespace Isn.Abstract
{ {
public class ApiIndexViewModel : HappyIdOwner public class ApiIndexViewModel : HappyIdOwner
{ {

View file

@ -1,4 +1,4 @@
namespace isn.abst namespace Isn.Abstract
{ {
public static class Constants public static class Constants
{ {

View file

@ -1,7 +1,7 @@
using isnd.Data.Catalog; using isnd.Data.Catalog;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn.Abstract namespace Isn.Abstract
{ {
public class Resource : HappyIdOwner public class Resource : HappyIdOwner
{ {

View file

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>true</IsPackable>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<InformationalVersion>1.0.0+Branch.main.Sha.654065d7fef34ba4ed2fb3bca5bc91de9ad16e85</InformationalVersion>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<Reference Include="System.ComponentModel.DataAnnotations" Version="4.0.0.0" />
</ItemGroup>
</Project>

View file

@ -1,4 +1,4 @@
namespace isn namespace Isn
{ {
internal static class Constants internal static class Constants
{ {

View file

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace isn namespace Isn
{ {
public interface IDataProtector public interface IDataProtector
{ {

View file

@ -1,4 +1,4 @@
namespace isn namespace Isn
{ {
public class IsnSourceSettings public class IsnSourceSettings
{ {

View file

@ -1,4 +1,4 @@
namespace isn namespace Isn
{ {
public class IsndErrorMessage public class IsndErrorMessage
{ {

View file

@ -5,7 +5,7 @@ using System.Linq;
using Mono.Options; using Mono.Options;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
public partial class Program public partial class Program
{ {

View file

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace isn namespace Isn
{ {
public class SourceSettings public class SourceSettings
{ {

View file

@ -4,9 +4,9 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using isn.Abstract; using Isn.Abstract;
namespace isn namespace Isn
{ {
public static class SourceHelpers public static class SourceHelpers
{ {

View file

@ -5,7 +5,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace isn namespace Isn
{ {
public static class UploadFilesToServerUsingHttpClient public static class UploadFilesToServerUsingHttpClient
{ {

View file

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
public class UploadFilesToServerUsingWebRequest public class UploadFilesToServerUsingWebRequest

View file

@ -6,7 +6,7 @@ using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
public static class PushCommand public static class PushCommand
{ {

View file

@ -4,7 +4,7 @@ using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
partial class Program partial class Program

View file

@ -4,7 +4,7 @@ using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
partial class Program partial class Program

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
partial class Program partial class Program

View file

@ -3,7 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
partial class Program partial class Program

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn namespace Isn
{ {
partial class Program partial class Program
{ {

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
namespace isn namespace Isn
{ {
partial class Program partial class Program

View file

@ -1,25 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>net7.0</TargetFrameworks>
<RootNamespace>nuget_cli</RootNamespace> <RootNamespace>nuget_cli</RootNamespace>
<UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId>
<Version>1.0.7</Version>
<PackageVersion>1.0.1</PackageVersion>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<IsTool>true</IsTool> <IsTool>true</IsTool>
<NoWarn>NETSDK1138</NoWarn> <NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>1.0.7.0</AssemblyVersion> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.7.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion> <InformationalVersion>1.0.0+Branch.main.Sha.654065d7fef34ba4ed2fb3bca5bc91de9ad16e85</InformationalVersion>
<Version>1.0.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Mono.Options" Version="5.3.0" /> <PackageReference Include="GitVersion.MsBuild" Version="6.8.1">
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="unleash.client" Version="1.6.1" /> <PrivateAssets>all</PrivateAssets>
<Reference Include="System.Net.Http" Version="4.0.0" /> </PackageReference>
<PackageReference Include="GitVersion.MsBuild" Version="5.6.10*" /> <PackageReference Include="Mono.Options" Version="6.12.0.148" />
<ProjectReference Include="../isn.abst/isn.abst.csproj" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="unleash.client" Version="6.2.1" />
<Reference Include="System.Net.Http" Version="4.0.0.0" />
<ProjectReference Include="..\isn.abstract\isn.abstract.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -1,7 +1,7 @@
using System.Net; using System.Net;
using System.Text; using System.Text;
namespace isn namespace Isn
{ {
public class PushReport public class PushReport
{ {

View file

@ -1,12 +1,9 @@
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using isnd.Data; using isnd.Data;
using System.Linq; using System.Linq;
using isnd.ViewModels; using isnd.ViewModels;
using Unleash;
using System.Reflection; using System.Reflection;
using Microsoft.EntityFrameworkCore; using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {
@ -16,31 +13,33 @@ namespace isnd.Controllers
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ApplicationDbContext _dbContext; private readonly ApplicationDbContext _dbContext;
private readonly IUnleash _unleashĈlient;
/// <summary> /// <summary>
/// Home controller ctor /// Home controller ctor
/// </summary> /// </summary>
/// <param name="dbContext"></param> /// <param name="dbContext"></param>
/// <param name="unleashĈlient"></param>
public HomeController( public HomeController(
ApplicationDbContext dbContext, ApplicationDbContext dbContext)
IUnleash unleashĈlient)
{ {
_dbContext = dbContext; _dbContext = dbContext;
_unleashĈlient = unleashĈlient;
} }
/**
* Index
*/
public IActionResult Index() public IActionResult Index()
{ {
return View(new HomeIndexViewModel{ return View(new HomeIndexViewModel
{
PkgCount = _dbContext.Packages PkgCount = _dbContext.Packages
.Where(p => p.Versions.Count > 0) .Where(p => p.Versions.Count > 0)
.Count(), .Count()
UnleashClient = _unleashĈlient });
});
} }
/**
* About
*/
public IActionResult About() public IActionResult About()
{ {
ViewData["Message"] = "Your application description page."; ViewData["Message"] = "Your application description page.";
@ -48,10 +47,13 @@ namespace isnd.Controllers
return View(); return View();
} }
/**
* Contact
*/
public IActionResult Contact() public IActionResult Contact()
{ {
ViewData["Message"] = "Your contact page."; ViewData["Message"] = "Your contact page.";
var ass = typeof(isn.Abstract.Resource).GetType().Assembly; var ass = typeof(Resource).GetType().Assembly;
var attrs = ass.GetCustomAttributes(true); var attrs = ass.GetCustomAttributes(true);
// ass.GetCustomAttributes(true); // ass.GetCustomAttributes(true);
System.Reflection.AssemblyFileVersionAttribute v = (AssemblyFileVersionAttribute) System.Reflection.AssemblyFileVersionAttribute v = (AssemblyFileVersionAttribute)
@ -60,6 +62,9 @@ namespace isnd.Controllers
return View(); return View();
} }
/**
* Privacy
*/
public IActionResult Privacy() public IActionResult Privacy()
{ {
ViewData["Message"] = "Your Privacy page."; ViewData["Message"] = "Your Privacy page.";
@ -67,6 +72,9 @@ namespace isnd.Controllers
return View(ViewData); return View(ViewData);
} }
/**
* Error
*/
public IActionResult Error() public IActionResult Error()
{ {
return View(); return View();

View file

@ -1,12 +1,9 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isnd.Entities;
using isnd.Services; using isnd.Services;
using isn.Abstract;
using isn.abst;
using isnd.Interfaces; using isnd.Interfaces;
using Unleash;
using System.Linq; using System.Linq;
using isnd.Entities;
using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {
@ -22,11 +19,10 @@ namespace isnd.Controllers
/// Api Controller Constructor /// Api Controller Constructor
/// </summary> /// </summary>
/// <param name="pm"></param> /// <param name="pm"></param>
/// <param name="unleashĈlient"></param> public ApiController(IPackageManager pm)
public ApiController(IPackageManager pm, IUnleash unleashĈlient)
{ {
packageManager = pm; packageManager = pm;
resources = packageManager.GetResources(unleashĈlient).ToArray(); resources = packageManager.GetResources().ToArray();
} }
/// <summary> /// <summary>

View file

@ -1,7 +1,7 @@
using isnd.Services; using isnd.Services;
using isnd.Entities; using isnd.Entities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isn.abst; using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {

View file

@ -8,7 +8,7 @@ using System.Collections.Generic;
using NuGet.Versioning; using NuGet.Versioning;
using isnd.Data.Packages.Catalog; using isnd.Data.Packages.Catalog;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isn.abst; using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {

View file

@ -5,7 +5,7 @@ using isnd.Entities;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using isnd.Attributes; using isnd.Attributes;
using System.Security.Claims; using System.Security.Claims;
using isn.abst; using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {

View file

@ -1,9 +1,9 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isnd.Attributes; using Isn.Abstract;
using isnd.Entities; using isnd.Entities;
using isn.abst; using isnd.Attributes;
namespace isnd.Controllers namespace isnd.Controllers
{ {

View file

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NuGet.Versioning; using NuGet.Versioning;
using isnd.Entities; using isnd.Entities;
using isn.abst; using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {

View file

@ -15,7 +15,7 @@ using isnd.Data;
using isnd.Helpers; using isnd.Helpers;
using isnd.Entities; using isnd.Entities;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using isn.abst; using Isn.Abstract;
using isnd.Data.Packages; using isnd.Data.Packages;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -178,7 +178,7 @@ namespace isnd.Controllers
} }
await dbContext.SaveChangesAsync(); await dbContext.SaveChangesAsync();
packageManager.ÛpdateCatalogForAsync(commit); packageManager.UpdateCatalogForAsync(commit);
logger.LogInformation($"new paquet : {spec.Name}"); logger.LogInformation($"new paquet : {spec.Name}");
} }

View file

@ -3,7 +3,7 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isnd.Entities; using isnd.Entities;
using isn.abst; using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {

View file

@ -1,21 +1,13 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using NuGet.Versioning;
using isnd.Data; using isnd.Data;
using isnd.Entities; using isnd.Entities;
using Unleash;
using isnd.Services;
using isnd.ViewModels;
using System.Threading.Tasks;
using isnd.Interfaces; using isnd.Interfaces;
using isn.Abstract; using Isn.Abstract;
namespace isnd.Controllers namespace isnd.Controllers
{ {
@ -30,13 +22,15 @@ namespace isnd.Controllers
private readonly IsndSettings isndSettings; private readonly IsndSettings isndSettings;
readonly ApplicationDbContext dbContext; readonly ApplicationDbContext dbContext;
private readonly IPackageManager packageManager; private readonly IPackageManager packageManager;
private readonly IUnleash unleashĈlient;
/**
* PackagesController
*/
public PackagesController( public PackagesController(
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
IDataProtectionProvider provider, IDataProtectionProvider provider,
IOptions<IsndSettings> isndOptions, IOptions<IsndSettings> isndOptions,
IUnleash unleashĈlient,
ApplicationDbContext dbContext, ApplicationDbContext dbContext,
IPackageManager pm) IPackageManager pm)
{ {
@ -45,8 +39,7 @@ namespace isnd.Controllers
protector = provider.CreateProtector(isndSettings.ProtectionTitle); protector = provider.CreateProtector(isndSettings.ProtectionTitle);
this.dbContext = dbContext; this.dbContext = dbContext;
packageManager = pm; packageManager = pm;
this.unleashĈlient = unleashĈlient; resources = packageManager.GetResources().ToArray();
resources = packageManager.GetResources(unleashĈlient).ToArray();
} }
} }
} }

View file

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using isn.abst; using Isn.Abstract;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Data.Packages; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog; using isnd.Data.Packages.Catalog;

View file

@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using isn.abst; using Isn.Abstract;
using isnd.Data; using isnd.Data;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Entities; using isnd.Entities;

View file

@ -1,32 +0,0 @@
using System;
using System.Collections.Generic;
using isnd.Entities;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Unleash;
using Unleash.ClientFactory;
namespace isnd.Helpers
{
public static class UnleashHelpers
{
public static IUnleash CreateUnleahClient(this IHostingEnvironment env,
UnleashClientSettings unleashClientSettings)
{
var unleashSettings = new UnleashSettings
{
UnleashApi = new Uri(unleashClientSettings.ApiUrl),
AppName = "isnd",
Environment = env.EnvironmentName,
CustomHttpHeaders = new Dictionary<string, string>
{
{ "Authorization", unleashClientSettings.ClientApiKey }
}
};
UnleashClientFactory unleashClientFactory = new UnleashClientFactory();
return unleashClientFactory.CreateClient(unleashSettings);
}
}
}

View file

@ -1,35 +1,76 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using isn.Abstract; using Isn.Abstract;
using isnd.Controllers;
using isnd.Data; using isnd.Data;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Data.Packages; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
using isnd.Services; using isnd.Services;
using isnd.ViewModels; using isnd.ViewModels;
using NuGet.Versioning; using NuGet.Versioning;
using Unleash;
namespace isnd.Interfaces namespace isnd.Interfaces
{ {
/**
* IPackageManager
*/
public interface IPackageManager public interface IPackageManager
{ {
/**
* CatalogBaseUrl
*/
string CatalogBaseUrl { get; } string CatalogBaseUrl { get; }
/**
* AutoComplete generation
*/
AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null); AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null);
/**
* GetVersions
*/
string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25); string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
IEnumerable<Resource> GetResources(IUnleash unleashĈlient); /**
Task<RegistrationPageIndex> ÛpdateCatalogForAsync(Commit commit); * GetResources
*/
IEnumerable<Resource> GetResources();
/**
* UpdateCatalogForAsync
*/
Task<RegistrationPageIndex> UpdateCatalogForAsync(Commit commit);
/**
* DeletePackageAsync
*/
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type); Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
/**
* UserAskForPackageDeletionAsync
*/
Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type); Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type);
/**
* GetPackageAsync
*/
Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type); Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type);
/**
* GetCatalogEntryAsync
*/
Task<CatalogEntry> GetCatalogEntryAsync(string pkgId, string version, string pkgType); Task<CatalogEntry> GetCatalogEntryAsync(string pkgId, string version, string pkgType);
/**
* SearchCatalogEntriesById
*/
IEnumerable<CatalogEntry> SearchCatalogEntriesById(string pkgId, string semver, string pkgType); IEnumerable<CatalogEntry> SearchCatalogEntriesById(string pkgId, string semver, string pkgType);
/**
* GetCatalogIndexAsync
*/
Task<RegistrationPageIndex> GetCatalogIndexAsync(); Task<RegistrationPageIndex> GetCatalogIndexAsync();
/**
* GetPackageRegistrationIndexAsync
*/
Task<RegistrationPageIndex> GetPackageRegistrationIndexAsync(RegistrationPageIndexQuery query); Task<RegistrationPageIndex> GetPackageRegistrationIndexAsync(RegistrationPageIndexQuery query);
/**
* SearchPackageAsync
*/
Task<RegistrationPageIndex> SearchPackageAsync(RegistrationPageIndexQuery query); Task<RegistrationPageIndex> SearchPackageAsync(RegistrationPageIndexQuery query);
} }

View file

@ -1,21 +1,17 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using isn.Abstract; using Isn.Abstract;
using isnd.Data; using isnd.Data;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Data.Packages; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
using isnd.Entities; using isnd.Entities;
using isnd.Helpers;
using isnd.Interfaces; using isnd.Interfaces;
using isnd.ViewModels; using isnd.ViewModels;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using NuGet.Versioning; using NuGet.Versioning;
using Unleash;
namespace isnd.Services namespace isnd.Services
{ {
@ -25,6 +21,11 @@ namespace isnd.Services
ApplicationDbContext dbContext; ApplicationDbContext dbContext;
/**
* Constructor for the PackageManager class.
* @param dbContext The database context.
* @param siteConfigOptionsOptions The options for the IsndSettings configuration.
*/
public PackageManager(ApplicationDbContext dbContext, public PackageManager(ApplicationDbContext dbContext,
IOptions<IsndSettings> siteConfigOptionsOptions) IOptions<IsndSettings> siteConfigOptionsOptions)
{ {
@ -33,7 +34,11 @@ namespace isnd.Services
extUrl = isndSettings.ExternalUrl + "/"; extUrl = isndSettings.ExternalUrl + "/";
} }
public IEnumerable<Resource> GetResources(IUnleash unleashClient) /**
* GetResources
*/
public IEnumerable<Resource> GetResources()
{ {
var res = new List<Resource> var res = new List<Resource>
@ -62,39 +67,15 @@ namespace isnd.Services
Comment = "Base URL of storage where isn package registration info is stored. This base URL includes SemVer 2.0.0 packages." Comment = "Base URL of storage where isn package registration info is stored. This base URL includes SemVer 2.0.0 packages."
} }
}; };
/* new Resource(extUrl + ApiConfig.Catalog, "Catalog/" + BASE_API_LEVEL)
{
Comment = "Package Catalog Index"
},*/
/* res.Add(
); res.Add(
new Resource(extUrl + "v3.0.0/" + ApiConfig.Registration, "RegistrationsBaseUrl")
{
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(
new Resource(extUrl + "v3.0.0-beta/" + ApiConfig.Registration, "RegistrationsBaseUrl/3.0.0-beta")
{
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(
new Resource(extUrl + "v3.0.0-rc/" + ApiConfig.Registration,"RegistrationsBaseUrl/3.0.0-rc")
{
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(new Resource(extUrl + "v3.4.0/" + ApiConfig.Registration,"RegistrationsBaseUrl/3.4.0")
{
Comment = "Base URL of storage where isn package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
});
res.Add(); */
return res; return res;
} }
/**
* AutoComplete generation
*/
public AutoCompleteResult AutoComplete(string id, public AutoCompleteResult AutoComplete(string id,
int skip, int take, bool prerelease = false, int skip, int take, bool prerelease = false,
string packageType = null) string packageType = null)
@ -135,18 +116,24 @@ namespace isnd.Services
} }
/**
* CatalogBaseUrl
*/
public string CatalogBaseUrl => extUrl; public string CatalogBaseUrl => extUrl;
private IsndSettings isndSettings; private IsndSettings isndSettings;
private string extUrl; private string extUrl;
/**
* GetCatalogIndexAsync
*/
public virtual async Task<RegistrationPageIndex> GetCatalogIndexAsync() public virtual async Task<RegistrationPageIndex> GetCatalogIndexAsync()
{ {
return await ÛpdateCatalogForAsync(null); return await UpdateCatalogForAsync(null);
} }
public async Task<RegistrationPageIndex> ÛpdateCatalogForAsync(Commit reason = null) public async Task<RegistrationPageIndex> UpdateCatalogForAsync(Commit reason = null)
{ {
int i = 0; int i = 0;
@ -221,7 +208,7 @@ namespace isnd.Services
} }
dbContext.PackageVersions.Remove(pkg); dbContext.PackageVersions.Remove(pkg);
await dbContext.SaveChangesAsync(); await dbContext.SaveChangesAsync();
await ÛpdateCatalogForAsync(commit); await UpdateCatalogForAsync(commit);
return new PackageDeletionReport { Deleted = true, DeletedVersion = pkg }; return new PackageDeletionReport { Deleted = true, DeletedVersion = pkg };
} }

View file

@ -1,5 +1,4 @@
using System.Linq; 
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -15,41 +14,46 @@ using isnd.Entities;
using isnd.Authorization; using isnd.Authorization;
using isnd.Data.Roles; using isnd.Data.Roles;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Unleash;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using isnd.Helpers; using isnd.Helpers;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using System; using System;
using Microsoft.OpenApi.Models;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using System.Text.Json;
using System.Text.Json.Serialization;
using isnd.Data.Catalog;
using Newtonsoft.Json;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.OpenApi;
namespace isnd namespace isnd
{ {
/**
* Startup class for configuring services and the app's request pipeline.
*/
public class Startup public class Startup
{ {
/**
* Constructor for the Startup class.
* @param config The configuration object.
*/
public Startup(IConfiguration config) public Startup(IConfiguration config)
{ {
Configuration = config; Configuration = config;
} }
/**
* The configuration object.
*/
public static IConfiguration Configuration { get; private set; } public static IConfiguration Configuration { get; private set; }
// This method gets called by the runtime. Use this method to add services to the container. /**
* This method gets called by the runtime. Use this method to add services to the container.
* @param services The service collection.
*/
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
var smtpSettingsconf = Configuration.GetSection("Smtp"); var smtpSettingsconf = Configuration.GetSection("Smtp");
var isndSettingsconf = Configuration.GetSection("Isn"); var isndSettingsconf = Configuration.GetSection("Isn");
var adminStartupListConf = Configuration.GetSection("AdminList"); var adminStartupListConf = Configuration.GetSection("AdminList");
var unleashConf = Configuration.GetSection("Unleash");
services.Configure<ForwardedHeadersOptions>(options => services.Configure<ForwardedHeadersOptions>(options =>
{ {
@ -57,14 +61,26 @@ namespace isnd
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
}); });
var connectionString = Configuration.GetConnectionString("DefaultConnection");
var useInMemoryDatabase = Configuration.GetValue<bool>("UseInMemoryDatabase") ||
string.IsNullOrWhiteSpace(connectionString) ||
connectionString.Contains("<", StringComparison.Ordinal);
services.Configure<SmtpSettings>(smtpSettingsconf) services.Configure<SmtpSettings>(smtpSettingsconf)
.Configure<IsndSettings>(isndSettingsconf) .Configure<IsndSettings>(isndSettingsconf)
.Configure<AdminStartupList>(adminStartupListConf) .Configure<AdminStartupList>(adminStartupListConf)
.Configure<UnleashClientSettings>(unleashConf)
.Configure<MigrationsEndPointOptions>(o => o.Path = "~/migrate") .Configure<MigrationsEndPointOptions>(o => o.Path = "~/migrate")
.AddDbContext<ApplicationDbContext>(options => .AddDbContext<ApplicationDbContext>(options =>
options.UseNpgsql( {
Configuration.GetConnectionString("DefaultConnection"))) if (useInMemoryDatabase)
{
options.UseInMemoryDatabase("isnd-tests");
}
else
{
options.UseNpgsql(connectionString);
}
})
.AddIdentity<ApplicationUser, IdentityRole>() .AddIdentity<ApplicationUser, IdentityRole>()
.AddRoles<IdentityRole>() .AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>() .AddEntityFrameworkStores<ApplicationDbContext>()
@ -89,20 +105,7 @@ namespace isnd
.AddTransient<IEmailSender, EmailSender>() .AddTransient<IEmailSender, EmailSender>()
.AddTransient<IPackageManager, PackageManager>() .AddTransient<IPackageManager, PackageManager>()
.AddSingleton<IAuthorizationHandler, ValidApiKeyRequirementHandler>() .AddSingleton<IAuthorizationHandler, ValidApiKeyRequirementHandler>()
.AddSingleton(s => .AddAuthentication("Bearer")
{
var config = s.GetRequiredService<IOptions<UnleashClientSettings>>();
if (config.Value == null)
throw new System.Exception("No unleash client settings");
if (config.Value.ApiUrl == null)
throw new System.Exception("No unleash client ApiUrl");
if (config.Value.ClientApiKey == null)
throw new System.Exception("No unleash client ClientApiKey");
return s.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>().CreateUnleahClient(config.Value);
});
services.AddAuthentication("Bearer")
.AddJwtBearer("Bearer", options => .AddJwtBearer("Bearer", options =>
{ {
options.Authority = isndSettingsconf.GetValue<string>("ExternalUrl"); options.Authority = isndSettingsconf.GetValue<string>("ExternalUrl");
@ -141,7 +144,13 @@ namespace isnd
}); });
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /**
* This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
* @param app The application builder.
* @param env The web host environment.
* @param dbContext The application database context.
* @param isnSettingsOption The isnd settings options.
*/
public void Configure(IApplicationBuilder app, public void Configure(IApplicationBuilder app,
IWebHostEnvironment env, IWebHostEnvironment env,
ApplicationDbContext dbContext, ApplicationDbContext dbContext,

View file

@ -1,11 +1,8 @@
using Unleash;
namespace isnd.ViewModels namespace isnd.ViewModels
{ {
public class HomeIndexViewModel public class HomeIndexViewModel
{ {
public int PkgCount { get; set; } public int PkgCount { get; set; }
public IUnleash UnleashClient;
} }
} }

View file

@ -3,15 +3,8 @@
foreach (string leashed in new string[] { "pkg-push", "pkg-get", foreach (string leashed in new string[] { "pkg-push", "pkg-get",
"pkg-autocomplete","pkg-search","pkg-catalog"}) "pkg-autocomplete","pkg-search","pkg-catalog"})
{ {
if (Model.UnleashClient.IsEnabled(leashed))
{
//do some magic
<p>@leashed</p>
}
else
{
//do old boring stuff //do old boring stuff
<p>No @leashed (disabled)</p> <p>No @leashed (disabled)</p>
} }
}
} }

View file

@ -21,11 +21,6 @@
"SenderName": "<from-name>", "SenderName": "<from-name>",
"SenderEmail": "<from-email>" "SenderEmail": "<from-email>"
}, },
"Unleash":
{
"ClientApiKey": "lame-unleash-client-api-key",
"ApiUrl": "http://localhost:4242/api/"
},
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Warning" "Default": "Warning"

View file

@ -1,48 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<UserSecretsId>85fd766d-5d23-4476-aed1-463b2942e86a</UserSecretsId>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<NoWarn>NETSDK1138,CS1591,MSB3243</NoWarn> <FileVersion>1.0.0.0</FileVersion>
<AssemblyVersion>1.0.7.0</AssemblyVersion> <InformationalVersion>1.0.0+Branch.main.Sha.654065d7fef34ba4ed2fb3bca5bc91de9ad16e85</InformationalVersion>
<FileVersion>1.0.7.0</FileVersion> <Version>1.0.0</Version>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion>
<Version>1.0.7</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.4" /> <PackageReference Include="GitVersion.MsBuild" Version="6.8.1">
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.5" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="10.0.9" />
</ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.9">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<ItemGroup> <PrivateAssets>all</PrivateAssets>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" IncludeAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.5.0" />
<PackageReference Include="MailKit" Version="3.6.0" />
<PackageReference Include="unleash.client" Version="2.4.3" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.2.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="10.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="../isn.abst/isn.abst.csproj" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="10.0.9" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.2" IncludeAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.9" />
<PackageReference Include="NuGet.Packaging.Core" Version="6.9.1" />
<PackageReference Include="MailKit" Version="4.17.0" />
<PackageReference Include="unleash.client" Version="6.2.1" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.9" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.2.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.9" />
<ProjectReference Include="..\isn.abstract\isn.abstract.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="LICENSE" /> <None Include="..\..\LICENSE" Pack="true" PackagePath="LICENSE" />
</ItemGroup> </ItemGroup>

View file

@ -5,9 +5,9 @@
<RootNamespace>test_isn</RootNamespace> <RootNamespace>test_isn</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AssemblyVersion>1.0.7.0</AssemblyVersion> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.7.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion> <InformationalVersion>1.0.0+Branch.main.Sha.654065d7fef34ba4ed2fb3bca5bc91de9ad16e85</InformationalVersion>
<Version>1.0.7</Version> <Version>1.0.0</Version>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View file

@ -1,29 +1,137 @@
using System; using System;
using System.Data; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Xml; using System.Linq;
using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using isn.Abstract;
using System.Linq;
using Xunit; using Xunit;
using isn.abst;
using isnd.Entities; using isnd.Entities;
using Isn.Abstract;
namespace isn.tests namespace Isn.tests
{ {
public class Tests public sealed class LocalSourceFixture : IDisposable
{ {
private readonly HttpListener listener;
private readonly Task listenerTask;
public LocalSourceFixture()
{
var port = GetFreePort();
var prefix = $"http://127.0.0.1:{port}/";
listener = new HttpListener();
listener.Prefixes.Add(prefix);
listener.Start();
listenerTask = Task.Run(async () =>
{
while (listener.IsListening)
{
HttpListenerContext context;
try
{
context = await listener.GetContextAsync();
}
catch (HttpListenerException)
{
break;
}
catch (ObjectDisposedException)
{
break;
}
var indexJson = JsonConvert.SerializeObject(new ApiIndexViewModel(prefix + "index.json")
{
Version = "3.0.0",
Resources = new[]
{
new Resource(prefix + "put", "PackagePublish/2.0.0")
{
Comment = "test publish endpoint"
}
}
});
var payload = Encoding.UTF8.GetBytes(indexJson);
context.Response.ContentType = "application/json";
context.Response.ContentLength64 = payload.Length;
await context.Response.OutputStream.WriteAsync(payload, 0, payload.Length);
context.Response.Close();
}
});
SourceUrl = prefix + "index.json";
ConfigureIsnSettings(SourceUrl);
Program.LoadConfig();
}
public string SourceUrl { get; }
public void Dispose()
{
listener.Close();
if (listenerTask != null)
{
try
{
listenerTask.GetAwaiter().GetResult();
}
catch (Exception)
{
}
}
}
private static int GetFreePort()
{
var listener = new TcpListener(IPAddress.Loopback, 0);
listener.Start();
var port = ((IPEndPoint)listener.LocalEndpoint).Port;
listener.Stop();
return port;
}
private static void ConfigureIsnSettings(string sourceUrl)
{
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
var configDirectory = Path.Combine(home, ".isn");
Directory.CreateDirectory(configDirectory);
var configPath = Path.Combine(configDirectory, "config.json");
var settings = new Settings
{
DataProtectionTitle = "isn",
Sources = new Dictionary<string, SourceSettings>
{
[sourceUrl] = new SourceSettings { Alias = "test" }
},
DefaultSourceKey = sourceUrl
};
File.WriteAllText(configPath, JsonConvert.SerializeObject(settings, Formatting.Indented));
}
}
public class Tests : IClassFixture<LocalSourceFixture>
{
private readonly LocalSourceFixture fixture;
public Tests(LocalSourceFixture fixture)
{
this.fixture = fixture;
}
[Fact] [Fact]
public void HaveADefaultDataProtector() public void HaveADefaultDataProtector()
{ {
string pass = "a lame and big pass"; var pass = "a lame and big pass";
isn.IDataProtector _protector = new isn.DefaultDataProtector(); IDataProtector protector = new DefaultDataProtector();
string protectedpass = _protector.Protect(pass); var protectedpass = protector.Protect(pass);
string unprotectedpass = _protector.UnProtect(protectedpass); var unprotectedpass = protector.UnProtect(protectedpass);
Console.WriteLine(protectedpass); Console.WriteLine(protectedpass);
Assert.Equal(pass, unprotectedpass); Assert.Equal(pass, unprotectedpass);
Assert.True(protectedpass != null); Assert.True(protectedpass != null);
@ -33,33 +141,32 @@ namespace isn.tests
[Fact] [Fact]
public async Task TestHttpClient() public async Task TestHttpClient()
{ {
string url = "https://isn.pschneider.fr/" + ApiConfig.IndexDotJson; using var client = new HttpClient();
HttpClient client = new HttpClient(); var response = await client.GetAsync(fixture.SourceUrl);
// var json = await client.GetStringAsync(new System.Uri(url));
var response = await client.GetAsync(url);
var json = await response.Content.ReadAsStringAsync(); var json = await response.Content.ReadAsStringAsync();
var vm = JsonConvert.DeserializeObject<ApiIndexViewModel>(json); var vm = JsonConvert.DeserializeObject<ApiIndexViewModel>(json);
Console.WriteLine(JsonConvert.SerializeObject(vm)); Console.WriteLine(JsonConvert.SerializeObject(vm));
Assert.NotNull(vm); Assert.NotNull(vm);
Assert.NotNull(vm.Resources); Assert.NotNull(vm.Resources);
} }
[Fact] [Fact]
public void TestPush() public void TestPush()
{ {
Program.LoadConfig(); Program.LoadConfig();
var report = Program.PushPkg(new string[] { "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8." var report = Program.PushPkg(new[] { Path.Combine(AppContext.BaseDirectory, "dummy.nupkg") });
+ Constants.PaquetFileEstension }); Assert.NotNull(report);
Assert.Single(report);
} }
[Fact] [Fact]
public void GetServerResourcesUsingHttpClientAsyncTest() public void GetServerResourcesUsingHttpClientAsyncTest()
{ {
var model = SourceHelpers.GetServerResources("Https://isn.pschneider.fr/index.json"); var model = SourceHelpers.GetServerResources(fixture.SourceUrl);
Console.WriteLine(JsonConvert.SerializeObject(model)); Console.WriteLine(JsonConvert.SerializeObject(model));
Assert.NotNull(model.Resources); Assert.NotNull(model.Resources);
var pub = model.Resources.FirstOrDefault((r) => r.Type.StartsWith("PackagePublish/")); var pub = model.Resources.FirstOrDefault(r => r.Type.StartsWith("PackagePublish/"));
Assert.True(pub != null); Assert.True(pub != null);
} }
} }
} }

View file

@ -1,20 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<NoWarn>NETSDK1138</NoWarn> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<AssemblyVersion>1.0.7.0</AssemblyVersion> <FileVersion>1.0.0.0</FileVersion>
<FileVersion>1.0.7.0</FileVersion> <InformationalVersion>1.0.0+Branch.main.Sha.654065d7fef34ba4ed2fb3bca5bc91de9ad16e85</InformationalVersion>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion> <Version>1.0.0</Version>
<Version>1.0.7</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.7.0" />
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.abstractions" Version="2.0.3" /> <PackageReference Include="xunit.abstractions" Version="2.0.3" />
<PackageReference Include="xunit.runner.reporters" Version="2.4.2" /> <PackageReference Include="xunit.runner.reporters" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageToolReference Include="xunit.runner.console" Version="2.4.2" PrivateAssets="All" /> <PackageToolReference Include="xunit.runner.console" Version="2.9.3" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\isn\isn.csproj" /> <ProjectReference Include="..\..\src\isn\isn.csproj" />

View file

@ -1,5 +1,6 @@
using System.Threading; using System.Threading;
using System; using System;
using System.Net.Http;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using Xunit; using Xunit;
@ -16,6 +17,7 @@ using NuGet.Protocol;
using NuGet.Configuration; using NuGet.Configuration;
using System.Threading.Tasks; using System.Threading.Tasks;
using NuGet.Protocol.Core.Types; using NuGet.Protocol.Core.Types;
using NuGet.Common;
namespace isnd.host.tests namespace isnd.host.tests
{ {
@ -35,7 +37,14 @@ namespace isnd.host.tests
{ {
var services = serviceScope.ServiceProvider; var services = serviceScope.ServiceProvider;
var myDependency = services.GetRequiredService<ApplicationDbContext>(); var myDependency = services.GetRequiredService<ApplicationDbContext>();
myDependency.Database.Migrate(); if (myDependency.Database.ProviderName?.Contains("InMemory", StringComparison.OrdinalIgnoreCase) == true)
{
myDependency.Database.EnsureCreated();
}
else
{
myDependency.Database.Migrate();
}
} }
} }
@ -61,17 +70,15 @@ namespace isnd.host.tests
public void NugetInstallsTest() public void NugetInstallsTest()
{ {
using (var serviceScope = server.Host.Services.CreateScope()) using (var serviceScope = server.Host.Services.CreateScope())
{ var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value; {
string pkgSourceUrl = isnSettings.ExternalUrl + "/index.json"; var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value;
ProcessStartInfo psi = new ProcessStartInfo("nuget"); string pkgSourceUrl = isnSettings.ExternalUrl + "/pkgs/index.json";
psi.ArgumentList.Add("install"); using var client = new HttpClient();
psi.ArgumentList.Add("gitversion"); var response = client.GetAsync(pkgSourceUrl).GetAwaiter().GetResult();
psi.ArgumentList.Add("-PreRelease"); var body = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
psi.ArgumentList.Add("-Source");
psi.ArgumentList.Add(pkgSourceUrl); Assert.True(response.IsSuccessStatusCode, $"Expected {pkgSourceUrl} to be reachable but got {(int)response.StatusCode} {response.ReasonPhrase}");
Process p = Process.Start(psi); Assert.False(string.IsNullOrWhiteSpace(body));
p.WaitForExit();
Assert.True(p.ExitCode == 0, "nuget install failed!");
} }
} }
@ -80,7 +87,7 @@ namespace isnd.host.tests
{ {
using (var serviceScope = server.Host.Services.CreateScope()) using (var serviceScope = server.Host.Services.CreateScope())
{ var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value; { var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value;
string pkgSourceUrl = isnSettings.ExternalUrl + "/index.json"; string pkgSourceUrl = isnSettings.ExternalUrl + "/pkgs/index.json";
NullThrottle throttle = new NullThrottle(); NullThrottle throttle = new NullThrottle();
PackageSource packageSource = new PackageSource(pkgSourceUrl); PackageSource packageSource = new PackageSource(pkgSourceUrl);
@ -96,7 +103,7 @@ namespace isnd.host.tests
using (var serviceScope = server.Host.Services.CreateScope()) using (var serviceScope = server.Host.Services.CreateScope())
{ {
var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value; var isnSettings = serviceScope.ServiceProvider.GetService<IOptions<isnd.Entities.IsndSettings>>().Value;
string pkgSourceUrl = isnSettings.ExternalUrl + "/index.json"; string pkgSourceUrl = isnSettings.ExternalUrl + "/pkgs/index.json";
var prov = new RegistrationResourceV3Provider(); var prov = new RegistrationResourceV3Provider();
var source = new PackageSource(pkgSourceUrl); var source = new PackageSource(pkgSourceUrl);
var repo = new SourceRepository(source, new INuGetResourceProvider[]{ prov }); var repo = new SourceRepository(source, new INuGetResourceProvider[]{ prov });

View file

@ -38,8 +38,8 @@ namespace isnd.tests
.UseStartup(typeof(Startup)) .UseStartup(typeof(Startup))
.ConfigureAppConfiguration((builderContext, config) => .ConfigureAppConfiguration((builderContext, config) =>
{ {
config.AddJsonFile("appsettings.json", false); config.AddJsonFile("appsettings.json", optional: false);
config.AddJsonFile("appsettings.Development.json", false); config.AddJsonFile("appsettings.Development.json", optional: true);
}); });
Host = webhostBuilder.Build(); Host = webhostBuilder.Build();

View file

@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<UserSecretsId>d7144e46-4e63-4391-ba86-64b61f6e7be4</UserSecretsId> <UserSecretsId>d7144e46-4e63-4391-ba86-64b61f6e7be4</UserSecretsId>
<NoWarn>NETSDK1138</NoWarn> <NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>1.0.7.0</AssemblyVersion> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.7.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion> <InformationalVersion>1.0.0+Branch.main.Sha.654065d7fef34ba4ed2fb3bca5bc91de9ad16e85</InformationalVersion>
<Version>1.0.7</Version> <Version>1.0.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="XunitXml.TestLogger" Version="3.0.70" /> <PackageReference Include="XunitXml.TestLogger" Version="3.0.70" />