Commit b162a9cd authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

New: Api refactoring

parent a19772c5
......@@ -268,3 +268,6 @@ __pycache__/
tools/*
!tools/packages.config
dist/
#linq2db
src/.tools/
......@@ -19,15 +19,6 @@ cake:Test:
- master
- tags
docs:
stage: docs
script:
- .\publishDocs.ps1 $GITLAB_TOKEN
variables:
GIT_STRATEGY: clone
only:
- tags
cake:Release:
stage: release
script:
......
param(
$token
)
$remoteUrl = git config --get remote.origin.url
$remoteUrl = $remoteUrl.replace("git@", "")
$remoteUrl = $remoteUrl -replace "https(.*?)@",""
$remoteUrl = $remoteUrl.replace(":", "/")
$remoteUrl = $remoteUrl.replace(".git", ".wiki.git")
$temporaryFolderName = "publishDocsTempFolder"
git clone "https://gitlab-ci-token:$($token)@$($remoteUrl)" $temporaryFolderName
cd $temporaryFolderName
Remove-Item *
cp -r ../docs/* ./
git add .
git commit -m "Docs: Documentation Update"
git push
\ No newline at end of file
param($installPath, $toolsPath, $package, $project)
# get the active solution
$solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
$solutionPath = [System.IO.Path]::GetDirectoryName($solution.FullName)
$linq2dbToolsPath = [System.IO.Path]::Combine($solutionPath, ".tools", "linq2db.t4models")
# tools copy
xcopy $("$toolsPath\*.*") $("$linq2dbToolsPath\") /y /e
using Coscine.Api.Project.Controllers;
using Coscine.Api.Project.Models;
using Coscine.Database.Models;
using Coscine.ApiCommons.Utils;
using Coscine.Database.Model;
using Coscine.Database.DataModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
......@@ -14,6 +14,9 @@ using System.IO;
using System.Linq;
using System.Management;
using System.Security.Claims;
using LinqToDB.Data;
using Coscine.Database.Settings;
using Coscine.Configuration;
namespace Coscine.Api.Project.Tests
{
......@@ -21,7 +24,7 @@ namespace Coscine.Api.Project.Tests
{
protected T Controller { get; }
protected readonly List<Coscine.Database.Model.Project> Projects = new List<Coscine.Database.Model.Project>();
protected readonly List<Coscine.Database.DataModel.Project> Projects = new List<Coscine.Database.DataModel.Project>();
protected readonly List<User> Users = new List<User>();
protected readonly List<ProjectRole> ProjectRoles = new List<ProjectRole>();
protected readonly List<ResourceType> ResourceTypes = new List<ResourceType>();
......@@ -44,6 +47,7 @@ namespace Coscine.Api.Project.Tests
[OneTimeSetUp]
public void Setup()
{
DataConnection.DefaultSettings = new CoscineSettings(new ConsulConfiguration());
DisciplineModel disciplineModel = new DisciplineModel();
Discipline = new Discipline()
{
......@@ -87,7 +91,7 @@ namespace Coscine.Api.Project.Tests
FakeControllerContext(user);
var project = new Coscine.Database.Model.Project()
var project = new Coscine.Database.DataModel.Project()
{
Description = "Description",
ProjectName = "TestProject",
......@@ -122,7 +126,7 @@ namespace Coscine.Api.Project.Tests
Projects.Add(projectModel.GetById(project.Id));
var project2 = new Coscine.Database.Model.Project()
var project2 = new Coscine.Database.DataModel.Project()
{
Description = "Description2",
ProjectName = "TestProject",
......
......@@ -56,17 +56,17 @@
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.Action, Version=1.9.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.9.0\lib\net461\Coscine.Action.dll</HintPath>
<Reference Include="Coscine.Action, Version=1.10.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.10.0\lib\net461\Coscine.Action.dll</HintPath>
</Reference>
<Reference Include="Coscine.ApiCommons, Version=1.5.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.5.0\lib\net461\Coscine.ApiCommons.dll</HintPath>
<Reference Include="Coscine.ApiCommons, Version=1.6.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.6.0\lib\net461\Coscine.ApiCommons.dll</HintPath>
</Reference>
<Reference Include="Coscine.Configuration, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.4.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Coscine.Database, Version=1.15.1.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.15.1\lib\net461\Coscine.Database.dll</HintPath>
<Reference Include="Coscine.Database, Version=1.16.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Database.1.16.0\lib\net461\Coscine.Database.dll</HintPath>
</Reference>
<Reference Include="Coscine.Logging, Version=1.0.1.0, Culture=neutral, PublicKeyToken=e1ed402bc3f6525e, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Logging.1.0.1\lib\net461\Coscine.Logging.dll</HintPath>
......@@ -74,14 +74,8 @@
<Reference Include="Coscine.ProxyApi, Version=1.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ProxyApi.1.2.1\lib\net461\Coscine.ProxyApi.dll</HintPath>
</Reference>
<Reference Include="Coscine.SharePoint.Webparts.Vue, Version=1.4.0.0, Culture=neutral, PublicKeyToken=0fe8d3e516df6d98, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.SharePoint.Webparts.Vue.1.4.0\lib\net461\Coscine.SharePoint.Webparts.Vue.dll</HintPath>
</Reference>
<Reference Include="dotNetRDF, Version=2.2.1.0, Culture=neutral, PublicKeyToken=6055ffe4c97cc780, processorArchitecture=MSIL">
<HintPath>..\packages\dotNetRDF.2.2.1\lib\net40\dotNetRDF.dll</HintPath>
</Reference>
<Reference Include="dotNetRDF.Data.Virtuoso, Version=2.2.1.0, Culture=neutral, PublicKeyToken=6055ffe4c97cc780, processorArchitecture=MSIL">
<HintPath>..\packages\dotNetRDF.Data.Virtuoso.2.2.1\lib\net40\dotNetRDF.Data.Virtuoso.dll</HintPath>
<Reference Include="Coscine.SharePoint.Webparts.Vue, Version=1.5.0.0, Culture=neutral, PublicKeyToken=0fe8d3e516df6d98, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.SharePoint.Webparts.Vue.1.5.0\lib\net461\Coscine.SharePoint.Webparts.Vue.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
......@@ -95,11 +89,8 @@
<Reference Include="linq2db, Version=2.6.4.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL">
<HintPath>..\packages\linq2db.2.6.4\lib\net46\linq2db.dll</HintPath>
</Reference>
<Reference Include="LinqKit, Version=1.1.16.0, Culture=neutral, PublicKeyToken=bc217f8844052a91, processorArchitecture=MSIL">
<HintPath>..\packages\LinqKit.1.1.16\lib\net45\LinqKit.dll</HintPath>
</Reference>
<Reference Include="Metadata, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Metadata.1.0.0\lib\net461\Metadata.dll</HintPath>
<Reference Include="LinqKit, Version=1.1.17.0, Culture=neutral, PublicKeyToken=bc217f8844052a91, processorArchitecture=MSIL">
<HintPath>..\packages\LinqKit.1.1.17\lib\net45\LinqKit.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll</HintPath>
......@@ -392,11 +383,11 @@
<Reference Include="Microsoft.Win32.Registry, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Win32.Registry.4.5.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.12.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.12.0\lib\net45\Moq.dll</HintPath>
<Reference Include="Moq, Version=4.13.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.13.1\lib\net45\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json.Bson, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.Bson.1.0.2\lib\net45\Newtonsoft.Json.Bson.dll</HintPath>
......@@ -614,8 +605,6 @@
<Compile Include="DefaultControllerTests.cs" />
<Compile Include="ProjectControllerTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceControllerTests.cs" />
<Compile Include="ResourceTypeControllerTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
......
using NUnit.Framework;
using Coscine.Api.Project.Controllers;
using Microsoft.AspNetCore.Mvc;
using Coscine.Api.Project.Models;
using Coscine.Database.Models;
using System.Linq;
using Coscine.Api.Project.ReturnObjects;
using Coscine.Database.ReturnObjects;
using System.IO;
using System;
using Coscine.ApiCommons.Exceptions;
using Coscine.ApiCommons.Factories;
using System.Collections.Generic;
using Coscine.Database.Util;
#region DupFinder Exclusion
namespace Coscine.Api.Project.Tests
{
[TestFixture]
......@@ -267,4 +266,3 @@ namespace Coscine.Api.Project.Tests
}
}
}
\ No newline at end of file
#endregion
\ No newline at end of file
using Coscine.Api.Project.Controllers;
using Coscine.Api.Project.Models;
using Coscine.Api.Project.ReturnObjects;
using Coscine.ApiCommons.Exceptions;
using Coscine.ApiCommons.Factories;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
namespace Coscine.Api.Project.Tests
{
[TestFixture]
public class ResourceControllerTests : DefaultControllerTests<ResourceController>
{
public ResourceControllerTests() : base(new ResourceController())
{
}
[Test]
public void TestControllerIndex()
{
var actionResult = Controller.Index();
Assert.IsTrue(actionResult.GetType() == typeof(JsonResult));
}
[Test]
public void TestControllerGet()
{
var actionResult = Controller.Get(Resources[0].Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(JsonResult));
JsonResult result = (JsonResult)actionResult;
Assert.IsTrue(result.Value.GetType() == typeof(ResourceObject));
ResourceObject resourceObject = (ResourceObject)result.Value;
Assert.IsTrue(resourceObject.Id == Resources[0].Id);
Assert.IsTrue(resourceObject.DisplayName == Resources[0].DisplayName);
Assert.IsTrue(resourceObject.Visibility.DisplayName == Resources[0].Visibility.DisplayName);
Assert.IsTrue(resourceObject.Type.Id == Resources[0].Type.Id);
Assert.IsTrue(resourceObject.Type.DisplayName == Resources[0].Type.DisplayName);
}
[Test]
public void TestControllerUpdate()
{
var actionResult = Controller.Get(Resources[0].Id.ToString());
JsonResult result = (JsonResult)actionResult;
ResourceObject resourceObject = (ResourceObject)result.Value;
resourceObject.DisplayName = "OtherName";
resourceObject.ResourceTypeOption = JObject.FromObject(new RDSResourceTypeObject(Guid.NewGuid(), "PITLABTTEST", 0));
Stream stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
FakeControllerContext(Users[0], stream);
actionResult = Controller.Update(Resources[0].Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(JsonResult));
// Cleanup
stream.Close();
stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
FakeControllerContext(Users[0], stream);
actionResult = Controller.Update(Resources[1].Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(UnauthorizedObjectResult));
// Cleanup
stream.Close();
}
[Test]
public void TestControllerStoreToProject()
{
ResourceObject resourceObject = new ResourceObject(
Guid.NewGuid(),
"Test",
"testR",
"testD",
"keys",
"usageR",
new ResourceTypeObject(Resources[0].Type.Id, Resources[0].Type.DisplayName, Resources[0].Type.Enabled),
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName),
new LicenseObject(License.Id, License.DisplayName),
JObject.FromObject(new RDSResourceTypeObject(Guid.NewGuid(), "PITLABTTEST", 0)),
"link",
JToken.Parse("{}")
);
Stream stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
FakeControllerContext(Users[0], stream);
var actionResult = Controller.StoreToProject(Projects[0].Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(JsonResult));
JsonResult result = (JsonResult)actionResult;
resourceObject = (ResourceObject)result.Value;
// Cleanup
stream.Close();
stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
FakeControllerContext(Users[0], stream);
actionResult = Controller.Delete(resourceObject.Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(JsonResult));
stream.Close();
}
}
}
using Coscine.Api.Project.Controllers;
using Microsoft.AspNetCore.Mvc;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Coscine.Api.Project.Tests
{
[TestFixture]
public class ResourceTypeControllerTests : DefaultControllerTests<ResourceTypeController>
{
public ResourceTypeControllerTests() : base(new ResourceTypeController())
{
}
[Test]
public void TestGettingFields()
{
var actionResult = Controller.Fields(Resources[0].Type.Id.ToString());
Assert.IsTrue(actionResult.GetType() == typeof(JsonResult));
JsonResult result = (JsonResult)actionResult;
List<string> fields = (List<string>) result.Value;
if(fields.Count() == 2)
{
Assert.IsTrue(fields[0] == "BucketName");
Assert.IsTrue(fields[1] == "Size");
}
else
{
Assert.Fail("Wrong field count!");
}
}
}
}
......@@ -88,7 +88,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.Database" publicKeyToken="767d77427707b70a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.15.1.0" newVersion="1.15.1.0" />
<bindingRedirect oldVersion="0.0.0.0-1.16.0.0" newVersion="1.16.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
......@@ -100,7 +100,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.SharePoint.Webparts.Vue" publicKeyToken="0fe8d3e516df6d98" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.4.0.0" newVersion="1.4.0.0" />
<bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Configuration.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
......@@ -146,6 +146,10 @@
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="LinqKit" publicKeyToken="bc217f8844052a91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.17.0" newVersion="1.1.17.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
......
......@@ -4,22 +4,19 @@
<package id="AutoMapper.Extensions.Microsoft.DependencyInjection" version="6.0.0" targetFramework="net472" />
<package id="Castle.Core" version="4.4.0" targetFramework="net472" />
<package id="Consul" version="0.7.2.6" targetFramework="net472" />
<package id="Coscine.Action" version="1.9.0" targetFramework="net472" />
<package id="Coscine.ApiCommons" version="1.5.0" targetFramework="net472" />
<package id="Coscine.Action" version="1.10.0" targetFramework="net472" />
<package id="Coscine.ApiCommons" version="1.6.0" targetFramework="net472" />
<package id="Coscine.Configuration" version="1.4.0" targetFramework="net472" />
<package id="Coscine.Database" version="1.15.1" targetFramework="net472" />
<package id="Coscine.Database" version="1.16.0" targetFramework="net472" />
<package id="Coscine.Logging" version="1.0.1" targetFramework="net472" />
<package id="Coscine.ProxyApi" version="1.2.1" targetFramework="net472" />
<package id="Coscine.SharePoint.Webparts.Vue" version="1.4.0" targetFramework="net472" />
<package id="dotNetRDF" version="2.2.1" targetFramework="net472" />
<package id="dotNetRDF.Data.Virtuoso" version="2.2.1" targetFramework="net472" />
<package id="Coscine.SharePoint.Webparts.Vue" version="1.5.0" targetFramework="net472" />
<package id="EntityFramework" version="6.2.0" targetFramework="net472" />
<package id="HtmlAgilityPack" version="1.8.2" targetFramework="net472" />
<package id="linq2db" version="2.6.4" targetFramework="net472" />
<package id="linq2db.SqlServer" version="2.6.4" targetFramework="net472" />
<package id="linq2db.t4models" version="2.6.4" targetFramework="net472" />
<package id="LinqKit" version="1.1.16" targetFramework="net472" />
<package id="Metadata" version="1.0.0" targetFramework="net472" />
<package id="LinqKit" version="1.1.17" targetFramework="net472" />
<package id="Microsoft.AspNetCore" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Antiforgery" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Authentication" version="2.2.0" targetFramework="net472" />
......@@ -122,8 +119,8 @@
<package id="Microsoft.IdentityModel.Tokens" version="5.6.0" targetFramework="net472" />
<package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net472" />
<package id="Moq" version="4.12.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
<package id="Moq" version="4.13.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="Newtonsoft.Json.Bson" version="1.0.2" targetFramework="net472" />
<package id="NLog" version="4.6.8" targetFramework="net472" />
<package id="NLog.Config" version="4.6.8" targetFramework="net472" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment