diff --git a/.vs/isn/xs/UserPrefs.xml b/.vs/isn/xs/UserPrefs.xml index d3ad2cc..835aae7 100644 --- a/.vs/isn/xs/UserPrefs.xml +++ b/.vs/isn/xs/UserPrefs.xml @@ -1,34 +1,19 @@  - + - - - + - - - - - - - - - - - - - - - - + + - + + diff --git a/.vscode/settings.json b/.vscode/settings.json index 604ccae..8298106 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,5 +10,29 @@ "dotnetCoreExplorer.runEnvVars": { "ASPNETCORE_ENVIRONMENT": "Testing" }, - "dotnetCoreExplorer.searchpatterns": "test/**/bin/**/*.tests.{dll,exe}" + "dotnetCoreExplorer.searchpatterns": "test/**/bin/**/*.tests.{dll,exe}", + "sqltools.connections": [ + { + "previewLimit": 50, + "server": "localhost", + "port": 5432, + "driver": "PostgreSQL", + "name": "isntest", + "group": "isn", + "database": "nugettest", + "username": "paul", + "password": "R1vJa=y8#b/tfg" + }, + { + "previewLimit": 50, + "server": "localhost", + "port": 5432, + "driver": "PostgreSQL", + "name": "isndev", + "group": "isn", + "database": "dotnetmvc", + "username": "dotnetmvc", + "password": "RvJa=y#b/tfg" + } + ] } \ No newline at end of file diff --git a/isn.sln b/isn.sln index 68c3c7d..1e20c9f 100644 --- a/isn.sln +++ b/isn.sln @@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn", "src\isn\isn.csproj", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn.tests", "test\isn.tests\isn.tests.csproj", "{305F640E-11BA-44F9-95E0-C6882E9CD151}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn.abst", "src\isn.abst\isn.abst.csproj", "{4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -76,11 +78,24 @@ Global {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.Build.0 = Release|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x64.ActiveCfg = Debug|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x64.Build.0 = Debug|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x86.ActiveCfg = Debug|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Debug|x86.Build.0 = Debug|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|Any CPU.Build.0 = Release|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x64.ActiveCfg = Release|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x64.Build.0 = Release|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x86.ActiveCfg = Release|Any CPU + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {9D758F00-17FF-433D-B088-F9C2D97C9BD1} = {3C312E42-9A47-4BED-8265-A405FCA6AFFF} {468DB0E4-6221-4E01-BEFF-F452865E59C1} = {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} + {4EFA7D3E-8B31-4BF7-96D1-B9F2867735C7} = {E8A2DF68-847A-4D88-B002-64FB666F696C} EndGlobalSection EndGlobal diff --git a/isntest.session.sql b/isntest.session.sql new file mode 100644 index 0000000..1350503 --- /dev/null +++ b/isntest.session.sql @@ -0,0 +1 @@ +select * from ApiKLeys; \ No newline at end of file diff --git a/src/isn.abst/ApiIndexViewModel.cs b/src/isn.abst/ApiIndexViewModel.cs new file mode 100644 index 0000000..505cb35 --- /dev/null +++ b/src/isn.abst/ApiIndexViewModel.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; + +namespace isn.Abstract +{ + public class ApiIndexViewModel + { + [JsonProperty("version")] + public string Version { get; set; } + + [JsonProperty("resources")] + public Resource[] Resources { get; set; } + } +} \ No newline at end of file diff --git a/src/isn.abst/Constants.cs b/src/isn.abst/Constants.cs new file mode 100644 index 0000000..bc5cf0a --- /dev/null +++ b/src/isn.abst/Constants.cs @@ -0,0 +1,8 @@ +namespace isn.abst +{ + public static class Constants + { + public const string PublishCommandId = "PackagePublish/2.0.0"; + + } +} \ No newline at end of file diff --git a/src/isnd/Controllers/Resource.cs b/src/isn.abst/Resource.cs similarity index 87% rename from src/isnd/Controllers/Resource.cs rename to src/isn.abst/Resource.cs index c1950c2..235690d 100644 --- a/src/isnd/Controllers/Resource.cs +++ b/src/isn.abst/Resource.cs @@ -1,17 +1,17 @@ -using Newtonsoft.Json; - -namespace isnd.Controllers -{ - public class Resource - { - [JsonProperty("@id")] - public string Id {get; set; } - - [JsonProperty("@type")] - public string Type {get; set; } - - [JsonProperty("comment")] - public string Comment {get; set; } - - } +using Newtonsoft.Json; + +namespace isn.Abstract +{ + public class Resource + { + [JsonProperty("@id")] + public string Id {get; set; } + + [JsonProperty("@type")] + public string Type {get; set; } + + [JsonProperty("comment")] + public string Comment {get; set; } + + } } \ No newline at end of file diff --git a/src/isn.abst/isn.abst.csproj b/src/isn.abst/isn.abst.csproj new file mode 100644 index 0000000..8f24508 --- /dev/null +++ b/src/isn.abst/isn.abst.csproj @@ -0,0 +1,11 @@ + + + + net4.7.2 + + + + + + + diff --git a/src/isn/IsnSourceSettings.cs b/src/isn/IsnSourceSettings.cs new file mode 100644 index 0000000..bc2491c --- /dev/null +++ b/src/isn/IsnSourceSettings.cs @@ -0,0 +1,9 @@ +namespace isn +{ + public class IsnSourceSettings + { + internal string Source { get; set; } + + internal string[] Keys { get; set; } + } +} \ No newline at end of file diff --git a/src/isn/IsndErrorMessage.cs b/src/isn/IsndErrorMessage.cs new file mode 100644 index 0000000..fa6b062 --- /dev/null +++ b/src/isn/IsndErrorMessage.cs @@ -0,0 +1,8 @@ +namespace isn +{ + public class IsndErrorMessage + { + public int ecode { get; set; } + public string msg { get; set; } + } +} \ No newline at end of file diff --git a/src/isn/Program.Commands.cs b/src/isn/Program.Commands.cs deleted file mode 100644 index 897d144..0000000 --- a/src/isn/Program.Commands.cs +++ /dev/null @@ -1,126 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; -using Mono.Options; -using Newtonsoft.Json; - -namespace isn -{ - - partial class Program - { - private static void SourceList(IEnumerable sargs) - { - throw new NotImplementedException(); - } - - private static object SourceAdd(IEnumerable str) - { - throw new NotImplementedException(); - } - - private static object Add(IEnumerable str) - { - throw new NotImplementedException(); - } - - private static async Task> PushPkgAsync(IEnumerable pkgs) - { - List pushReports = new List(); - - foreach (string pkg in pkgs) - { - var report = await PushCommand.RunAsync(pkg, source, apiKey); - - pushReports.Add(report); - } - if (storApiKey) - { - EnsureKeyStored(); - } - return pushReports; - } - static OptionSet storeoptions = new OptionSet { - { "s|source=", "use source", val => source = source ?? val }, - { "h|help", "show this message and exit", h => shouldShowPushHelp = h != null }, - }; - private static string _configFileName = - Path.Combine( - Path.Combine(Environment.GetFolderPath( - Environment.SpecialFolder.UserProfile), ".isn"), - "config.json") - ; - - public class IsnSourceSettings - { - internal string Source { get; set; } - - internal string[] Keys { get; set; } - } - public static IEnumerable Sources { get; protected set; } - - private static void StoreApiKey(IEnumerable storeArgs) - { - var args = storeoptions.Parse(storeArgs); - if (shouldShowPushHelp) - { - // output the options - Console.Error.WriteLine("Push Options:"); - storeoptions.WriteOptionDescriptions(Console.Out); - } - else - { - apiKey = args[0]; - EnsureKeyStored(); - } - } - - public static void EnsureKeyStored() - { - if (source == null) return; - - if (Settings.Sources.ContainsKey(source)) - { - if (apiKey == null) - { - // Une suppression - Settings.Sources.Remove(source); - if (Settings.DefaultSource == source) Settings.DefaultSource = null; - } - else - { - // Une mise À jour - string ptd = Protector.Protect(apiKey); - Settings.Sources[source].ApiKey = ptd; - if (Settings.DefaultSource == null) Settings.DefaultSource = source; - } - } - else if (apiKey != null) - { - // une addition - string ptd = Protector.Protect(apiKey); - Settings.Sources.Add(source, new SourceSettings { ApiKey = ptd }); - } - else return; - FileInfo cfgSettingIf = new FileInfo(_configFileName); - if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create(); - File.WriteAllText( - cfgSettingIf.FullName, - JsonConvert.SerializeObject( - Settings, - Formatting.Indented - )); - } - - public static void LoadConfig() - { - FileInfo cfgSettingIf = new FileInfo(_configFileName); - if (cfgSettingIf.Exists) - { - var json = File.ReadAllText(cfgSettingIf.FullName); - settings = JsonConvert.DeserializeObject(json); - } - } - } -} \ No newline at end of file diff --git a/src/isn/Program.cs b/src/isn/Program.cs index 6173011..0d9b387 100644 --- a/src/isn/Program.cs +++ b/src/isn/Program.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using Mono.Options; using Newtonsoft.Json; @@ -8,6 +9,29 @@ namespace isn { partial class Program { + + public static IEnumerable Sources { get; protected set; } + + public static void LoadConfig() + { + FileInfo cfgSettingIf = new FileInfo(_configFileName); + if (cfgSettingIf.Exists) + { + var json = File.ReadAllText(cfgSettingIf.FullName); + settings = JsonConvert.DeserializeObject(json); + } + } + static OptionSet storeoptions = new OptionSet { + { "s|source=", "use source", val => source = source ?? val }, + { "h|help", "show this message and exit", h => shouldShowPushHelp = h != null }, + }; + private static string _configFileName = + Path.Combine( + Path.Combine(Environment.GetFolderPath( + Environment.SpecialFolder.UserProfile), ".isn"), + "config.json") + ; + public const string push = "push"; static OptionSet options = new OptionSet { { "h|help", "show this message and exit", h => shouldShowHelp = h != null }, @@ -23,6 +47,9 @@ namespace isn { "h|help", "show this message and exit", h => shouldShowSourceHelp = h != null }, }; + static OptionSet showOptions = new OptionSet { + { "h|help", "show this message and exit", h => shouldShowSourceHelp = h != null }, + }; private static bool shouldShowHelp; private static bool shouldShowSourceHelp; @@ -59,10 +86,37 @@ namespace isn { Run = sargs => SourceList(sargs) }; + + var showconfig = new Command("config") + { + Run = sargs => ShowConfig() + }; + var srcadd = new Command("add") { Run = sargs => SourceAdd(sargs) }; + + var showCommand = new Command("show") + { + Run = sargs => + { + var showCommandSet = new CommandSet("show") + { + showconfig + }; + var pargs = showOptions.Parse(sargs); + if (shouldShowSourceHelp) + { + // output the options + Console.WriteLine("Sources Options:"); + showOptions.WriteOptionDescriptions(Console.Out); + return; + } + showCommandSet.Run(pargs); + } + }; + var srcCmd = new Command("sources") { Run = sargs => @@ -73,6 +127,8 @@ namespace isn srclst, srcadd }; + + var pargs = sourceoptions.Parse(sargs); if (shouldShowSourceHelp) { @@ -116,6 +172,7 @@ namespace isn }; commandSet.Add(setapikey); commandSet.Add(srcCmd); + commandSet.Add(showCommand); List extra; try diff --git a/src/isn/PushCommand.cs b/src/isn/PushCommand.cs index 12e2ea7..7c61b39 100644 --- a/src/isn/PushCommand.cs +++ b/src/isn/PushCommand.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Linq; using System.Net; using System.Threading.Tasks; using Newtonsoft.Json; @@ -28,10 +29,16 @@ namespace isn if (source == null) { source = Program.Settings.DefaultSource; - apikey = Program.Settings.Sources[source].ApiKey; + if (apikey is null) if (source!=null) + apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey); } + if (apikey is null) if (source!=null) if (Program.Settings.Sources.ContainsKey(source)) - if (apikey is null) apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey); + apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey); + if (source == null) throw new InvalidOperationException("source is null"); + var resources = await SourceHelpers.GetServerResourcesAsync(source); + if (resources.Resources==null || resources.Resources.Any(res => res.Id == "" )) + throw new InvalidOperationException("Source won't serve the expected push command"); wrqueryHandler.UploadFilesToServer(report, new Uri(source), fi, apikey); } catch (WebException ex) @@ -43,7 +50,7 @@ namespace isn { StreamReader sr = new StreamReader(respStream); string json = sr.ReadToEnd(); - var res = JsonConvert.DeserializeObject(json); + var res = JsonConvert.DeserializeObject(json); // ecode == 1 => package already present server side. report.AlreadyPresent = res.ecode == 1; report.Message = res.msg; diff --git a/src/isn/SourceHelpers.cs b/src/isn/SourceHelpers.cs new file mode 100644 index 0000000..0202937 --- /dev/null +++ b/src/isn/SourceHelpers.cs @@ -0,0 +1,21 @@ +using System.Net.Http; +using System.Threading.Tasks; +using isn.Abstract; +using Newtonsoft.Json; + +namespace isn +{ + public static class SourceHelpers + { + public static async Task GetServerResourcesAsync(string url) + { + HttpClient client = new HttpClient(); + client.DefaultRequestHeaders.Add("content-type","application/json; utf-8"); + using (var indexResponse = await client.GetAsync(url)) + { + var json = await indexResponse.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(json); + } + } + } +} \ No newline at end of file diff --git a/src/isn/UploadFilesToServerUsingWebRequest.cs b/src/isn/UploadFilesToServerUsingWebRequest.cs index 70ea75d..7720390 100644 --- a/src/isn/UploadFilesToServerUsingWebRequest.cs +++ b/src/isn/UploadFilesToServerUsingWebRequest.cs @@ -7,12 +7,7 @@ using Newtonsoft.Json; namespace isn { - public class NugetdErrorMessage - { - public string versionId { get; set; } - public int ecode { get; set; } - public string msg { get; set; } - } + public class UploadFilesToServerUsingWebRequest { internal void UploadFilesToServer(PushReport report, Uri uri, FileInfo fi, diff --git a/src/isn/commands/push.cs b/src/isn/commands/push.cs new file mode 100644 index 0000000..906ca5c --- /dev/null +++ b/src/isn/commands/push.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json; + + +namespace isn +{ + + partial class Program + { + private static async Task> PushPkgAsync(IEnumerable pkgs) + { + List pushReports = new List(); + + foreach (string pkg in pkgs) + { + var report = await PushCommand.RunAsync(pkg, source, apiKey); + + pushReports.Add(report); + } + if (storApiKey) + { + EnsureKeyStored(); + } + return pushReports; + } + + private static object Add(IEnumerable str) + { + throw new NotImplementedException(); + } + + } +} \ No newline at end of file diff --git a/src/isn/commands/set-api-key.cs b/src/isn/commands/set-api-key.cs new file mode 100644 index 0000000..6a54461 --- /dev/null +++ b/src/isn/commands/set-api-key.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Newtonsoft.Json; + + +namespace isn +{ + + partial class Program + { + + private static void StoreApiKey(IEnumerable storeArgs) + { + var args = storeoptions.Parse(storeArgs); + if (shouldShowPushHelp) + { + // output the options + Console.Error.WriteLine("Push Options:"); + storeoptions.WriteOptionDescriptions(Console.Out); + } + else + { + apiKey = args[0]; + EnsureKeyStored(); + } + } + + public static void EnsureKeyStored() + { + if (source == null) return; + + if (Settings.Sources.ContainsKey(source)) + { + if (apiKey == null) + { + // Une suppression + Settings.Sources.Remove(source); + if (Settings.DefaultSource == source) Settings.DefaultSource = null; + } + else + { + // Une mise À jour + string ptd = Protector.Protect(apiKey); + Settings.Sources[source].ApiKey = ptd; + if (Settings.DefaultSource == null) Settings.DefaultSource = source; + } + } + else if (apiKey != null) + { + // une addition + string ptd = Protector.Protect(apiKey); + Settings.Sources.Add(source, new SourceSettings { ApiKey = ptd }); + } + else return; + FileInfo cfgSettingIf = new FileInfo(_configFileName); + if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create(); + File.WriteAllText( + cfgSettingIf.FullName, + JsonConvert.SerializeObject( + Settings, + Formatting.Indented + )); + } + } +} \ No newline at end of file diff --git a/src/isn/commands/show.config.cs b/src/isn/commands/show.config.cs new file mode 100644 index 0000000..f3a347f --- /dev/null +++ b/src/isn/commands/show.config.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + + +namespace isn +{ + + partial class Program + { + + private static void ShowConfig() + { + Console.WriteLine(JsonConvert.SerializeObject(Settings)); + + } + + } +} \ No newline at end of file diff --git a/src/isn/commands/sources.add.cs b/src/isn/commands/sources.add.cs new file mode 100644 index 0000000..90d2aed --- /dev/null +++ b/src/isn/commands/sources.add.cs @@ -0,0 +1,25 @@ + +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace isn +{ + + partial class Program + { + private static void SourceAdd(IEnumerable str) + { + foreach (string arg in str) + { + if (Settings.Sources.ContainsKey(arg)) + { + SourceSettings setting = Settings.Sources[arg]; + throw new InvalidOperationException + (setting.Alias); + } + throw new NotImplementedException(); + } + } + } +} \ No newline at end of file diff --git a/src/isn/commands/sources.list.cs b/src/isn/commands/sources.list.cs new file mode 100644 index 0000000..d25c683 --- /dev/null +++ b/src/isn/commands/sources.list.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Newtonsoft.Json; + + +namespace isn +{ + + partial class Program + { + private static void SourceList(IEnumerable sargs) + { + IEnumerable spec = sargs.Count()>0 ? sargs : Settings.Sources.Keys; + foreach (string arg in spec) + { + SourceSettings setting = Settings.Sources[arg]; + Console.WriteLine(JsonConvert.SerializeObject(setting)); + } + } + + } +} \ No newline at end of file diff --git a/src/isn/isn.1.0.0.nupkg b/src/isn/isn.1.0.0.nupkg deleted file mode 100644 index 39ff9a7..0000000 Binary files a/src/isn/isn.1.0.0.nupkg and /dev/null differ diff --git a/src/isn/isn.csproj b/src/isn/isn.csproj index e11d38f..62b17c7 100644 --- a/src/isn/isn.csproj +++ b/src/isn/isn.csproj @@ -1,7 +1,8 @@  + Exe - net472 + net6 nuget_cli 45b74c62-05bc-4603-95b4-3e80ae2fdf50 1.0.1 @@ -9,10 +10,16 @@ WTFPL true + - - - - - + + + + + + + + + + diff --git a/src/isnd/Constants.cs b/src/isnd/Constants.cs index 0f1d372..f748334 100644 --- a/src/isnd/Constants.cs +++ b/src/isnd/Constants.cs @@ -1,6 +1,6 @@ namespace isnd { - public static class Constants + public static class IsndConstants { public const string AdministratorRoleName = "Admin"; public const string RequireAdminPolicyName = "RequireAdministratorRole"; diff --git a/src/isnd/Controllers/AccountController.cs b/src/isnd/Controllers/AccountController.cs index 2b728c7..e367166 100644 --- a/src/isnd/Controllers/AccountController.cs +++ b/src/isnd/Controllers/AccountController.cs @@ -245,9 +245,9 @@ namespace isnd.Controllers { var user = await _userManager.FindByNameAsync(username); var roles = await _userManager.GetRolesAsync(user); - if (!roles.Contains(Constants.AdministratorRoleName)) + if (!roles.Contains(IsndConstants.AdministratorRoleName)) { - await _userManager.AddToRoleAsync(user, Constants.AdministratorRoleName); + await _userManager.AddToRoleAsync(user, IsndConstants.AdministratorRoleName); } return Ok(); diff --git a/src/isnd/Controllers/NewUpdateController.cs b/src/isnd/Controllers/NewUpdateController.cs index f223178..3cead90 100644 --- a/src/isnd/Controllers/NewUpdateController.cs +++ b/src/isnd/Controllers/NewUpdateController.cs @@ -9,7 +9,7 @@ namespace isnd.Controllers // TODO Web hook CI public class NewUpdateController : Controller { - [Authorize(Policy = Constants.RequireAdminPolicyName)] + [Authorize(Policy = IsndConstants.RequireAdminPolicyName)] public IActionResult NewRelease(NewReleaseInfo version) { throw new NotImplementedException("web hook"); diff --git a/src/isnd/Controllers/PackagesController.cs b/src/isnd/Controllers/PackagesController.cs index ba49932..3ba324d 100644 --- a/src/isnd/Controllers/PackagesController.cs +++ b/src/isnd/Controllers/PackagesController.cs @@ -15,6 +15,7 @@ using isnd.Services; using isnd.ViewModels; using System.Threading.Tasks; using isnd.Interfaces; +using isn.Abstract; namespace isnd.Controllers { @@ -54,7 +55,7 @@ namespace isnd.Controllers [HttpGet(_pkgRootPrefix + ApiConfig.Base)] public IActionResult ApiIndex() { - return Ok(new { version = "3.0.0", resources = _resources }); + return Ok(new ApiIndexViewModel{ Version = "3.0.0", Resources = _resources }); } // GET /autocomplete?id=isn.protocol&prerelease=true diff --git a/src/isnd/Interfaces/IPackageManager.cs b/src/isnd/Interfaces/IPackageManager.cs index 1db467d..746027e 100644 --- a/src/isnd/Interfaces/IPackageManager.cs +++ b/src/isnd/Interfaces/IPackageManager.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; +using isn.Abstract; using isnd.Controllers; using isnd.Data; using isnd.Data.Catalog; diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs index 5ff78c1..0f251df 100644 --- a/src/isnd/Services/PackageManager.cs +++ b/src/isnd/Services/PackageManager.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using isn.abst; +using isn.Abstract; using isnd.Controllers; using isnd.Data; using isnd.Data.Catalog; @@ -41,7 +43,7 @@ namespace isnd.Services new Resource { Id = extUrl + ApiConfig.Publish, - Type = "PackagePublish/2.0.0", + Type = Constants.PublishCommandId, Comment = "Package Publish service" }); // under dev, only leash in release mode diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index 57e086f..6b665cc 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -58,9 +58,9 @@ namespace isnd services.AddAuthorization(options => { - options.AddPolicy(Constants.RequireAdminPolicyName, - policy => policy.RequireRole(Constants.AdministratorRoleName)); - options.AddPolicy(Constants.RequireValidApiKey, policy => + options.AddPolicy(IsndConstants.RequireAdminPolicyName, + policy => policy.RequireRole(IsndConstants.AdministratorRoleName)); + options.AddPolicy(IsndConstants.RequireValidApiKey, policy => policy.Requirements.Add(new ValidApiKeyRequirement())); }) diff --git a/src/isnd/isnd.csproj b/src/isnd/isnd.csproj index 8c556fe..1486e9b 100644 --- a/src/isnd/isnd.csproj +++ b/src/isnd/isnd.csproj @@ -25,6 +25,10 @@ + + + + diff --git a/test/isn.tests/Engine.cs b/test/isn.tests/Engine.cs deleted file mode 100644 index 74627c5..0000000 --- a/test/isn.tests/Engine.cs +++ /dev/null @@ -1,17 +0,0 @@ -using static isn.tests.Tests; - -namespace isn.tests -{ - internal class Engine : INeedEngine - { - public Engine() - { - - } - - public object Parse(string code) - { - throw new System.NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/test/isn.tests/IBody.cs b/test/isn.tests/IBody.cs deleted file mode 100644 index 2869069..0000000 --- a/test/isn.tests/IBody.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace isn.tests -{ - internal interface IBody - { - /// - /// The mult - /// - /// - T Action(T v); - - } -} \ No newline at end of file diff --git a/test/isn.tests/IRing.cs b/test/isn.tests/IRing.cs deleted file mode 100644 index 026a637..0000000 --- a/test/isn.tests/IRing.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace isn.tests -{ - internal interface IRing : IBody - { - - - IRing Add(IRing other); - IRing Mult(TBody v); - } - -} \ No newline at end of file diff --git a/test/isn.tests/Ring.cs b/test/isn.tests/Ring.cs deleted file mode 100644 index 0089db7..0000000 --- a/test/isn.tests/Ring.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace isn.tests -{ - internal class Body : IBody - { - static public Ring One { get ;} - - public T Action(T v) - { - throw new System.NotImplementedException(); - } - - } - internal class Ring : Body, IRing - { - public static IRing Zero => throw new System.NotImplementedException(); - - - public IRing Add(IRing unity) - { - throw new System.NotImplementedException(); - } - - public IRing Mult(TBody v) - { - throw new System.NotImplementedException(); - } - - } -} \ No newline at end of file diff --git a/test/isn.tests/UnitTest1.cs b/test/isn.tests/UnitTest1.cs index c52b45d..92bb565 100644 --- a/test/isn.tests/UnitTest1.cs +++ b/test/isn.tests/UnitTest1.cs @@ -1,25 +1,14 @@ using System; +using System.Data; using System.IO; -using System.Text; +using System.Xml; using NUnit.Framework; namespace isn.tests { public class Tests { - private const int V = 0; - private const int V1 = 1; - - public interface INeedEngine - { - object Parse(string code); - - } - - [SetUp] - public void Setup() - { - } + private DataRow dataRow; [Test] public void HAveADefaultDataProtector() @@ -32,43 +21,19 @@ namespace isn.tests Assert.AreEqual(pass, unprotectedpass); Assert.Pass($"Good jod man! (decoding {protectedpass})"); } - - // Not a [Test] - public void TestParseCplus() - { - INeedEngine engine = new Engine(); - IRing c = new Ring(); - Assert.Equals((INeedEngine)engine.Parse("c+"), c.Add(Ring.One)); - } - - public void AssertIRingIsABody() - { - Ring c = new Ring(); - Ring one = Ring.One; - Assert.True(c.Mult(one).Equals(c)); - } - - public void AssertIRingIsARing() - { - AssertIRingIsABody(); - Ring c = new Ring(); - IRing zero = Ring.Zero; - Assert.True(c.Add(zero).Equals(c)); - } - [Test] - public void AssertReadInput() + public void Test() { - var oldOut = Console.Out; - StringBuilder censoredTxt = new StringBuilder(); - var newOut = new StringWriter(censoredTxt); - Console.SetOut(newOut); - Console.WriteLine("~~censored~~"); - Console.SetOut(oldOut); - Console.Write("Hello "); - Console.Write(censoredTxt); - } + System.Data.DataTable dataTable = new System.Data.DataTable(); +dataTable.Columns.Add(new DataColumn("x")); +dataTable.Columns.Add(new DataColumn("y")); +dataRow = dataTable.NewRow(); +dataRow[0]= 1; +dataRow[1]= 2; +dataTable.Rows.Add(dataRow); + + } } } \ No newline at end of file diff --git a/test/isn.tests/isn.tests.csproj b/test/isn.tests/isn.tests.csproj index 3ac8d60..e5bb5fd 100644 --- a/test/isn.tests/isn.tests.csproj +++ b/test/isn.tests/isn.tests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + net6 false diff --git a/test/isnd.tests/UnitTestWebHost.cs b/test/isnd.tests/UnitTestWebHost.cs index 407fd0e..9b92b3a 100644 --- a/test/isnd.tests/UnitTestWebHost.cs +++ b/test/isnd.tests/UnitTestWebHost.cs @@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using System.Collections.Generic; namespace isnd.host.tests { @@ -38,11 +39,21 @@ namespace isnd.host.tests } } } - + public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() .Build(); + + private class Butts: List + { + public bool Im12 { get; set; } + } + + private class Butt + { + public bool Im12 { get; set; } + } } } diff --git a/test/isnd.tests/isnd.tests.csproj b/test/isnd.tests/isnd.tests.csproj index 786d7e6..1bcc331 100644 --- a/test/isnd.tests/isnd.tests.csproj +++ b/test/isnd.tests/isnd.tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net6 false d7144e46-4e63-4391-ba86-64b61f6e7be4 @@ -28,7 +28,7 @@