diff --git a/src/isn.abst/ApiConfig.cs b/src/isn.abst/ApiConfig.cs
index 46f0efa..aca4e85 100644
--- a/src/isn.abst/ApiConfig.cs
+++ b/src/isn.abst/ApiConfig.cs
@@ -12,5 +12,7 @@ namespace isnd.Entities
public const string Nuspec = "/nuspec";
public const string Nuget = "/nuget";
+
+ public const string Find = "/index/FindPackagesById()"; // /FindPackagesById()?id='isn.abst'&semVerLevel=2.0.0
}
}
\ No newline at end of file
diff --git a/src/isnd/Controllers/HomeController.cs b/src/isnd/Controllers/HomeController.cs
index 45512c1..2d0f766 100644
--- a/src/isnd/Controllers/HomeController.cs
+++ b/src/isnd/Controllers/HomeController.cs
@@ -4,7 +4,6 @@ using Microsoft.Extensions.Logging;
using isnd.Data;
using System.Linq;
using isnd.ViewModels;
-using Unleash;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
@@ -16,19 +15,14 @@ namespace isnd.Controllers
public class HomeController : Controller
{
private readonly ApplicationDbContext _dbContext;
- private readonly IUnleash _unleashĈlient;
///
/// Home controller ctor
///
///
- ///
-
public HomeController(
- ApplicationDbContext dbContext,
- IUnleash unleashĈlient)
+ ApplicationDbContext dbContext)
{
_dbContext = dbContext;
- _unleashĈlient = unleashĈlient;
}
public IActionResult Index()
@@ -36,9 +30,7 @@ namespace isnd.Controllers
return View(new HomeIndexViewModel{
PkgCount = _dbContext.Packages
.Where(p => p.Versions.Count > 0)
- .Count(),
- UnleashClient = _unleashĈlient
- });
+ .Count()});
}
public IActionResult About()
diff --git a/src/isnd/Controllers/Packages/ApiIndex.cs b/src/isnd/Controllers/Packages/ApiIndex.cs
index 0c23c08..19a4502 100644
--- a/src/isnd/Controllers/Packages/ApiIndex.cs
+++ b/src/isnd/Controllers/Packages/ApiIndex.cs
@@ -1,10 +1,8 @@
using Microsoft.AspNetCore.Mvc;
-using isnd.Entities;
using isnd.Services;
using isn.Abstract;
using isn.abst;
using isnd.Interfaces;
-using Unleash;
using System.Linq;
@@ -22,11 +20,10 @@ namespace isnd.Controllers
/// Api Controller Constructor
///
///
- ///
- public ApiController(IPackageManager pm, IUnleash unleashĈlient)
+ public ApiController(IPackageManager pm)
{
packageManager = pm;
- resources = packageManager.GetResources(unleashĈlient).ToArray();
+ resources = packageManager.GetResources().ToArray();
}
///
diff --git a/src/isnd/Controllers/Packages/PackagesController.Catalog.cs b/src/isnd/Controllers/Packages/PackagesController.Catalog.cs
index cc2b60c..c9c2d17 100644
--- a/src/isnd/Controllers/Packages/PackagesController.Catalog.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.Catalog.cs
@@ -44,8 +44,5 @@ namespace isnd.Controllers
if (null == leaf) return NotFound(new { id, version });
return Ok(leaf);
}
-
-
-
}
}
\ No newline at end of file
diff --git a/src/isnd/Controllers/Packages/PackagesController.Search.cs b/src/isnd/Controllers/Packages/PackagesController.Search.cs
index 907d63a..c1979d8 100644
--- a/src/isnd/Controllers/Packages/PackagesController.Search.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.Search.cs
@@ -1,9 +1,11 @@
+using System.Linq;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using isnd.Entities;
using isn.abst;
+using isnd.Data.Catalog;
namespace isnd.Controllers
{
@@ -11,18 +13,32 @@ namespace isnd.Controllers
public partial class PackagesController
{
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
- [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Search)]
- public IActionResult Search(
- string q,
- int skip = 0,
- int take = 25,
+ [HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Find)]
+ [HttpPost("~" + Constants.ApiVersionPrefix + ApiConfig.Find)]
+ public async Task Search(
+ string id,
bool prerelease = false,
+ // string packageType = null,
string semVerLevel = null,
- string packageType = null
+ int skip = 0,
+ int take = 25
)
{
+ id = id.Trim('\'');
+ if (semVerLevel == "2.0.0") prerelease = true;
+
+ //packageManager.SearchCatalogEntriesById(id, semVerLevel, packageType, prerelease);
+ var regs = await packageManager.SearchPackageAsync(
- throw new NotImplementedException();
+ new PackageRegistrationQuery
+ {
+ Query = id,
+ Prerelease = prerelease,
+ Take = take,
+ Skip = skip
+ }
+ );
+ return Ok(new { totalHits = regs.Count(), data = regs });
}
}
}
\ No newline at end of file
diff --git a/src/isnd/Controllers/Packages/PackagesController.cs b/src/isnd/Controllers/Packages/PackagesController.cs
index ddf9e69..cbf2e5d 100644
--- a/src/isnd/Controllers/Packages/PackagesController.cs
+++ b/src/isnd/Controllers/Packages/PackagesController.cs
@@ -1,19 +1,11 @@
-using System.ComponentModel.DataAnnotations;
-using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc;
-using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-using NuGet.Versioning;
using isnd.Data;
using isnd.Entities;
-using Unleash;
-using isnd.Services;
-using isnd.ViewModels;
-using System.Threading.Tasks;
using isnd.Interfaces;
using isn.Abstract;
@@ -30,13 +22,11 @@ namespace isnd.Controllers
private readonly IsndSettings isndSettings;
readonly ApplicationDbContext dbContext;
private readonly IPackageManager packageManager;
- private readonly IUnleash unleashĈlient;
public PackagesController(
ILoggerFactory loggerFactory,
IDataProtectionProvider provider,
IOptions isndOptions,
- IUnleash unleashĈlient,
ApplicationDbContext dbContext,
IPackageManager pm)
{
@@ -45,8 +35,7 @@ namespace isnd.Controllers
protector = provider.CreateProtector(isndSettings.ProtectionTitle);
this.dbContext = dbContext;
packageManager = pm;
- this.unleashĈlient = unleashĈlient;
- resources = packageManager.GetResources(unleashĈlient).ToArray();
+ resources = packageManager.GetResources().ToArray();
}
}
}
diff --git a/src/isnd/Data/ApplicationDbContext.cs b/src/isnd/Data/ApplicationDbContext.cs
index ec0489a..0b651f2 100644
--- a/src/isnd/Data/ApplicationDbContext.cs
+++ b/src/isnd/Data/ApplicationDbContext.cs
@@ -24,7 +24,6 @@ namespace isnd.Data
.HasKey( v => new { v.PackageId, v.FullString } );
_ = builder.Entity()
.HasOne(v => v.Package).WithMany(p => p.Versions).HasForeignKey(x => x.PackageId);
- // _ = builder.Entity().HasMany(p => p.Versions).WithOne(V => V.Package).HasForeignKey(x => new { x.PackageId, x.FullString });
}
diff --git a/src/isnd/Data/Catalog/CatalogEntry.cs b/src/isnd/Data/Catalog/CatalogEntry.cs
index acdebf9..a4a51d7 100644
--- a/src/isnd/Data/Catalog/CatalogEntry.cs
+++ b/src/isnd/Data/Catalog/CatalogEntry.cs
@@ -1,3 +1,4 @@
+using System.ComponentModel;
using System.Net.Sockets;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
@@ -6,10 +7,15 @@ using NuGet.Versioning;
using System.Collections.Generic;
using System;
using isnd.Interfaces;
+using NuGet.Protocol.Core.Types;
+using NuGet.Protocol;
+using NuGet.Packaging;
+using NuGet.Packaging.Core;
+using System.Threading.Tasks;
namespace isnd.Data.Catalog
{
- public class PackageDetails : Permalink, IObject
+ public class PackageDetails : Permalink, IObject, IPackageSearchMetadata
{
///
/// Creates a catalog entry
@@ -20,11 +26,12 @@ namespace isnd.Data.Catalog
{
PackageId = pkg.Package.Id;
Version = pkg.FullString;
- authors = $"{pkg.Package.Owner.FullName} <${pkg.Package.Owner.Email}>";
+ Authors = $"{pkg.Package.Owner.FullName} <${pkg.Package.Owner.Email}>";
packageContent = apiBase + pkg.NugetLink;
CommitId = pkg.CommitId;
CommitTimeStamp = pkg.LatestCommit.CommitTimeStamp;
-
+ IsListed = !pkg.IsDeleted && pkg.Package.Public;
+ // TODO Licence Project Urls, Summary, Title, etc ...
}
[JsonProperty("@type")]
@@ -40,7 +47,8 @@ namespace isnd.Data.Catalog
/// Authors
///
/// string or array of strings
- public string authors { get; set; }
+ [JsonProperty("authors")]
+ public string Authors { get; set; }
///
/// The dependencies of the package, grouped by target framework
@@ -56,36 +64,45 @@ namespace isnd.Data.Catalog
[JsonProperty("description")]
public string Description { get; set; }
- public string iconUrl { get; set; }
+
+ [JsonProperty("iconUrl")]
+ public Uri IconUrl { get; set; }
+
public string language { get; set; }
- public string licenseUrl { get; set; }
+ [JsonProperty("licenseUrl")]
+ public Uri LicenseUrl { get; set; }
+
public string licenseExpression { get; set; }
- ///
- /// Should be considered as listed if absent
- ///
- ///
- public bool listed { get; set; }
+
public string minClientVersion { get; set; }
- public string projectUrl { get; set; }
- public bool requireLicenseAcceptance { get; set; }
- public string summary { get; set; }
+ [JsonProperty("projectUrl")]
+ public Uri ProjectUrl { get; set; }
+
+
+ [JsonProperty("requireLicenseAcceptance")]
+ public bool RequireLicenseAcceptance { get; set; }
+
+ [JsonProperty("summary")]
+ public string Summary { get; set; }
///
/// The tags
///
///
- public string tags { get; set; }
- public string title { get; set; }
-
+ [JsonProperty("tags")]
+ public string Tags { get; set; }
+ [JsonProperty("title")]
+ public string Title { get; set; }
+
///
/// The security vulnerabilities of the package
///
///
- public Vulnerabilitie[] vulnerabilities { get; set; }
+ public IEnumerable Vulnerabilities { get; }
public string packageContent { get; set; }
@@ -94,7 +111,7 @@ namespace isnd.Data.Catalog
///
///
[JsonProperty("published")]
- public DateTime Published { get; set; }
+ public DateTimeOffset? Published { get; set; }
///
/// The full version string after normalization
@@ -107,5 +124,36 @@ namespace isnd.Data.Catalog
[Required,JsonRequired]
[JsonProperty("id")]
public string PackageId { get; set; }
+
+ public IEnumerable DependencySets { get; set; }
+
+ public long? DownloadCount { get; set; }
+
+ public PackageIdentity Identity{ get; set; }
+
+ public Uri ReadmeUrl { get; set; }
+
+ public Uri ReportAbuseUrl { get; set; }
+
+ public Uri PackageDetailsUrl { get; set; }
+
+ public string Owners { get; set; }
+
+ [JsonProperty("isListed")]
+ public bool IsListed { get; set; }
+
+ public bool PrefixReserved { get; set; }
+
+ public LicenseMetadata LicenseMetadata { get; set; }
+
+ public Task GetDeprecationMetadataAsync()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task> GetVersionsAsync()
+ {
+ throw new NotImplementedException();
+ }
}
}
\ No newline at end of file
diff --git a/src/isnd/Data/Catalog/PackageRegistration.cs b/src/isnd/Data/Catalog/PackageRegistration.cs
index bf4aeac..d9f152b 100644
--- a/src/isnd/Data/Catalog/PackageRegistration.cs
+++ b/src/isnd/Data/Catalog/PackageRegistration.cs
@@ -20,8 +20,6 @@ namespace isnd.Data.Catalog
{
new CatalogPage(bid, pkg.Id, apiBase, pkg.Versions)
};
- CommitId = pkg.LatestCommit.CommitId;
- CommitTimeStamp = pkg.LatestCommit.CommitTimeStamp;
}
[JsonProperty("count")]
@@ -29,10 +27,6 @@ namespace isnd.Data.Catalog
[JsonProperty("items")]
public List Items { get; set; }
-
- public string CommitId { get; set; }
- public DateTimeOffset CommitTimeStamp { get; internal set; }
-
}
}
\ No newline at end of file
diff --git a/src/isnd/Data/Catalog/RegistrationPage.cs b/src/isnd/Data/Catalog/RegistrationPage.cs
index 4759866..b8f7e4c 100644
--- a/src/isnd/Data/Catalog/RegistrationPage.cs
+++ b/src/isnd/Data/Catalog/RegistrationPage.cs
@@ -71,11 +71,6 @@ namespace isnd.Data.Catalog
}
Upper = upper.ToFullString();
Lower = lower.ToFullString();
- if (latest != null && latest.LatestCommit !=null)
- {
- CommitId = latest.CommitId;
- CommitTimeStamp = latest.LatestCommit.CommitTimeStamp;
- }
}
///
@@ -100,7 +95,5 @@ namespace isnd.Data.Catalog
[JsonProperty("count")]
public int Count { get => items.Count; }
- public string CommitId { get; internal set; }
- public DateTimeOffset CommitTimeStamp { get; internal set; }
}
}
\ No newline at end of file
diff --git a/src/isnd/Entities/UnleashClientSettings.cs b/src/isnd/Entities/UnleashClientSettings.cs
deleted file mode 100644
index 1313724..0000000
--- a/src/isnd/Entities/UnleashClientSettings.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace isnd.Entities
-{
- public class UnleashClientSettings
- {
- public string ClientApiKey { get; set; }
- public string ApiUrl { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/isnd/Helpers/UnleashHelpers.cs b/src/isnd/Helpers/UnleashHelpers.cs
deleted file mode 100644
index d107bff..0000000
--- a/src/isnd/Helpers/UnleashHelpers.cs
+++ /dev/null
@@ -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
- {
- { "Authorization", unleashClientSettings.ClientApiKey }
- }
- };
-
- UnleashClientFactory unleashClientFactory = new UnleashClientFactory();
- return unleashClientFactory.CreateClient(unleashSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/src/isnd/Interfaces/IPackageManager.cs b/src/isnd/Interfaces/IPackageManager.cs
index b87dc39..cdb6fae 100644
--- a/src/isnd/Interfaces/IPackageManager.cs
+++ b/src/isnd/Interfaces/IPackageManager.cs
@@ -1,15 +1,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using isn.Abstract;
-using isnd.Controllers;
using isnd.Data;
using isnd.Data.Catalog;
using isnd.Data.Packages;
-using isnd.Data.Packages.Catalog;
using isnd.Services;
using isnd.ViewModels;
using NuGet.Versioning;
-using Unleash;
namespace isnd.Interfaces
{
@@ -19,13 +16,13 @@ namespace isnd.Interfaces
AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null);
string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
- IEnumerable GetResources(IUnleash unleashĈlient);
+ IEnumerable GetResources();
Task ÛpdateCatalogForAsync(Commit commit);
Task DeletePackageAsync(string pkgid, string version, string type);
Task UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type);
Task GetPackageAsync(string pkgid, string version, string type);
Task GetCatalogEntryAsync(string pkgId, string version, string pkgType);
- IEnumerable SearchCatalogEntriesById(string pkgId, string semver, string pkgType);
+ IEnumerable SearchCatalogEntriesById(string pkgId, string semver, string pkgType, bool preRelease);
Task GetCatalogIndexAsync();
Task GetPackageRegistrationIndexAsync(PackageRegistrationQuery query);
diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs
index 92d3ea5..bd7bd44 100644
--- a/src/isnd/Services/PackageManager.cs
+++ b/src/isnd/Services/PackageManager.cs
@@ -13,7 +13,6 @@ using isnd.ViewModels;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using NuGet.Versioning;
-using Unleash;
namespace isnd.Services
{
@@ -30,25 +29,25 @@ namespace isnd.Services
apiBase = isndSettings.ExternalUrl + Constants.ApiVersionPrefix;
}
- public IEnumerable GetResources(IUnleash unleashClient)
+ public IEnumerable GetResources()
{
var res = new List
{
- new Resource(apiBase + ApiConfig.Package,
+ new Resource(apiBase + ApiConfig.Package,
"PackagePublish/2.0.0")
{
Comment = "Package Publish service"
},
// under dev, only leash in release mode
- new Resource(apiBase + ApiConfig.Package + "/{id}/{version}",
+ new Resource(apiBase + ApiConfig.Package + "/{id}/{version}",
"PackageDetailsUriTemplate/5.1.0")
{
Comment = "URI template used by NuGet Client to construct details URL for packages"
},
- new Resource(apiBase + ApiConfig.Nuget,
+ new Resource(apiBase + ApiConfig.Nuget,
"PackageBaseAddress/3.0.0")
{
Comment = "Package Base Address service - " +
@@ -56,7 +55,7 @@ namespace isnd.Services
"https:///nupkg/{id-lower}/{version-lower}/{id-lower}.{version-lower}.nupkg"
},
- new Resource(apiBase + ApiConfig.AutoComplete,
+ new Resource(apiBase + ApiConfig.AutoComplete,
"SearchAutocompleteService/" + BASE_API_LEVEL)
{
Comment = "Auto complete service"
@@ -86,7 +85,7 @@ namespace isnd.Services
string packageType = null)
{
var scope = dbContext.PackageVersions.Where(
- v => v.PackageId == id
+ v => v.PackageId.StartsWith(id)
&& (prerelease || !v.IsPrerelease)
&& (packageType == null || v.Type == packageType)
)
@@ -173,17 +172,6 @@ namespace isnd.Services
reason = commit;
i++;
}
-
- if (reason != null)
- {
- index.CommitId = reason.CommitId;
- index.CommitTimeStamp = reason.CommitTimeStamp;
- }
- else
- {
- // From a fresh db
- index.CommitId = "none";
- }
return index;
}
@@ -246,7 +234,7 @@ namespace isnd.Services
public IEnumerable SearchCatalogEntriesById
- (string pkgId, string semver, string pkgType)
+ (string pkgId, string semver, string pkgType, bool preRelease)
{
return dbContext.PackageVersions
@@ -254,7 +242,8 @@ namespace isnd.Services
.Include(v => v.Package.Owner)
.Include(v => v.LatestCommit)
.Where(v => v.PackageId == pkgId && semver == v.FullString
- && (pkgType == null || pkgType == v.Type))
+ && (pkgType == null || pkgType == v.Type)
+ && (preRelease || !v.IsPrerelease))
.OrderByDescending(p => p.CommitNId)
.Select(p => p.ToPackage(apiBase))
;
@@ -277,8 +266,9 @@ namespace isnd.Services
var scope = await dbContext.Packages
.Include(p => p.Versions)
.Include(p => p.Owner)
- .Include(p=>p.LatestCommit)
- .SingleAsync(p => p.Id.ToLower() == query.Query);
+ .Include(p => p.LatestCommit)
+ .SingleOrDefaultAsync(p => p.Id.ToLower() == query.Query);
+ if (scope==null) return null;
if (scope.Versions.Count==0) return null;
string bid = $"{apiBase}{ApiConfig.Registration}";
foreach (var version in scope.Versions)
@@ -300,13 +290,12 @@ namespace isnd.Services
.Skip(query.Skip).Take(query.Take)
.ToListAsync()
);
- var pkgs = scope;
- foreach (var pkg in pkgs)
- {
- foreach (var version in pkg.Versions)
- version.LatestCommit = dbContext.Commits.Single(c=>c.Id == version.CommitNId);
- }
- return pkgs.Select(p => new PackageRegistration(bid, apiBase, p));
+ scope.ForEach(pkg =>
+ pkg.Versions.ForEach (version =>
+ version.LatestCommit = dbContext.Commits.Single(c => c.Id == version.CommitNId))
+ );
+
+ return scope.Select(p => new PackageRegistration(bid, apiBase, p));
}
diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs
index 93be266..963e3f2 100644
--- a/src/isnd/Startup.cs
+++ b/src/isnd/Startup.cs
@@ -1,6 +1,4 @@
-using System.Linq;
-using System.Collections.Generic;
-using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@@ -15,19 +13,11 @@ using isnd.Entities;
using isnd.Authorization;
using isnd.Data.Roles;
using Microsoft.AspNetCore.Authorization;
-using Unleash;
using Microsoft.Extensions.Options;
-using isnd.Helpers;
using Microsoft.IdentityModel.Tokens;
using System;
using Microsoft.OpenApi.Models;
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;
namespace isnd
@@ -49,7 +39,6 @@ namespace isnd
var smtpSettingsconf = Configuration.GetSection("Smtp");
var isndSettingsconf = Configuration.GetSection("Isn");
var adminStartupListConf = Configuration.GetSection("AdminList");
- var unleashConf = Configuration.GetSection("Unleash");
services.Configure(options =>
{
@@ -60,7 +49,6 @@ namespace isnd
services.Configure(smtpSettingsconf)
.Configure(isndSettingsconf)
.Configure(adminStartupListConf)
- .Configure(unleashConf)
.Configure(o => o.Path = "~/migrate")
.AddDbContext(options =>
options.UseNpgsql(
@@ -88,18 +76,7 @@ namespace isnd
.AddTransient()
.AddTransient()
.AddTransient()
- .AddSingleton()
- .AddSingleton(s =>
- {
- var config = s.GetRequiredService>();
- 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().CreateUnleahClient(config.Value);
- });
+ .AddSingleton();
services.AddAuthentication("Bearer")
diff --git a/src/isnd/ViewModels/HomeIndexViewModel.cs b/src/isnd/ViewModels/HomeIndexViewModel.cs
index 3dac63c..d4dead9 100644
--- a/src/isnd/ViewModels/HomeIndexViewModel.cs
+++ b/src/isnd/ViewModels/HomeIndexViewModel.cs
@@ -1,11 +1,9 @@
-using Unleash;
namespace isnd.ViewModels
{
public class HomeIndexViewModel
{
public int PkgCount { get; set; }
- public IUnleash UnleashClient;
}
}
\ No newline at end of file
diff --git a/src/isnd/Views/Home/Features.cshtml b/src/isnd/Views/Home/Features.cshtml
index e38c6a9..836bc7e 100644
--- a/src/isnd/Views/Home/Features.cshtml
+++ b/src/isnd/Views/Home/Features.cshtml
@@ -1,17 +1 @@
@model HomeIndexViewModel
-@{
- foreach (string leashed in new string[] { "pkg-push", "pkg-get",
- "pkg-autocomplete","pkg-search","pkg-catalog"})
- {
- if (Model.UnleashClient.IsEnabled(leashed))
- {
- //do some magic
- @leashed
- }
- else
- {
- //do old boring stuff
- No @leashed (disabled)
- }
- }
-}
\ No newline at end of file
diff --git a/test/isnd.tests/UnitTestWebHost.cs b/test/isnd.tests/UnitTestWebHost.cs
index 2e65f1c..96ba5fd 100644
--- a/test/isnd.tests/UnitTestWebHost.cs
+++ b/test/isnd.tests/UnitTestWebHost.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using System.Threading;
using System;
using Xunit;
@@ -12,6 +13,8 @@ using NuGet.Configuration;
using System.Threading.Tasks;
using NuGet.Protocol.Core.Types;
using isn.abst;
+using NuGet.Common;
+using System.Collections.Generic;
namespace isnd.host.tests
{
@@ -107,5 +110,62 @@ namespace isnd.host.tests
{
throw new NotImplementedException();
}
+ public string SPIIndexURI {
+ get => server.Addresses.First() + "/v3/index";
+ }
+
+ [Fact]
+ public async Task TestGetMetadataAsync()
+ {
+ ILogger logger = NullLogger.Instance;
+ CancellationToken cancellationToken = CancellationToken.None;
+
+ SourceCacheContext cache = new SourceCacheContext();
+ SourceRepository repository = Repository.Factory.GetCoreV3(SPIIndexURI);
+ PackageMetadataResource resource = await repository.GetResourceAsync();
+
+ IEnumerable packages = await resource.GetMetadataAsync(
+ "isn.abst",
+ includePrerelease: true,
+ includeUnlisted: true,
+ cache,
+ logger,
+ cancellationToken);
+
+ Assert.NotEmpty(packages);
+
+ foreach (IPackageSearchMetadata package in packages)
+ {
+ Console.WriteLine($"Version: {package.Identity.Version}");
+ Console.WriteLine($"Listed: {package.IsListed}");
+ Console.WriteLine($"Tags: {package.Tags}");
+ Console.WriteLine($"Description: {package.Description}");
+ }
+ }
+
+ [Fact]
+ public async Task TestFindPackageAsync()
+ {
+ ILogger logger = NullLogger.Instance;
+ CancellationToken cancellationToken = CancellationToken.None;
+
+ SourceRepository repository = Repository.Factory.GetCoreV3(SPIIndexURI);
+ PackageSearchResource resource = await repository.GetResourceAsync();
+ SearchFilter searchFilter = new SearchFilter(includePrerelease: true);
+
+ IEnumerable results = await resource.SearchAsync(
+ "isn",
+ searchFilter,
+ skip: 0,
+ take: 20,
+ logger,
+ cancellationToken);
+
+ foreach (IPackageSearchMetadata result in results)
+ {
+ Console.WriteLine($"Found package {result.Identity.Id} {result.Identity.Version}");
+ }
+
+ }
}
}
diff --git a/test/isnd.tests/WebServerFixture.cs b/test/isnd.tests/WebServerFixture.cs
index b45be22..4c711ff 100644
--- a/test/isnd.tests/WebServerFixture.cs
+++ b/test/isnd.tests/WebServerFixture.cs
@@ -11,8 +11,6 @@ namespace isnd.tests
{
[CollectionDefinition("Web server collection")]
-
-
public class WebServerFixture : IDisposable
{
public IWebHost Host { get; private set;}
@@ -43,20 +41,11 @@ namespace isnd.tests
});
Host = webhostBuilder.Build();
-
Host.Start(); //Starts listening on the configured addresses.
- PrintAddresses(Host.Services);
- }
-
- void PrintAddresses(IServiceProvider services)
- {
- Addresses.Clear();
- Console.WriteLine("Checking addresses...");
- var server = services.GetRequiredService();
+ var server = Host.Services.GetRequiredService();
var addressFeature = server.Features.Get();
foreach (var address in addressFeature.Addresses)
{
- Console.WriteLine("Listing on address: " + address);
Addresses.Add(address);
}
}