Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Coscine
backend
apis
Project
Commits
d98aaddb
Commit
d98aaddb
authored
Dec 07, 2020
by
Marcel Nellesen
Browse files
New: Included resource type definition
parent
94de2aff
Changes
18
Hide whitespace changes
Inline
Side-by-side
src/Project.Tests/DefaultControllerTests.cs
View file @
d98aaddb
using
Coscine.Api.Project.Controllers
;
using
Coscine.Database.Models
;
using
Coscine.ApiCommons.Utils
;
using
Coscine.Database.DataModel
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
...
...
@@ -20,6 +19,7 @@ using Coscine.Configuration;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging.Abstractions
;
using
Coscine.Logging
;
using
Coscine.JwtHandler
;
namespace
Coscine.Api.Project.Tests
{
...
...
@@ -230,7 +230,7 @@ namespace Coscine.Api.Project.Tests
JWTHandler
jwtHandler
=
new
JWTHandler
(
Program
.
Configuration
);
Dictionary
<
string
,
string
>
values
=
new
Dictionary
<
string
,
string
>
{
{
"
U
serId"
,
user
.
Id
.
ToString
()
}
{
"
u
serId"
,
user
.
Id
.
ToString
()
}
};
var
additionalProtocol
=
Program
.
Configuration
.
GetStringAndWait
(
"coscine/local/sharepoint/additional/protocol"
);
...
...
@@ -276,9 +276,14 @@ namespace Coscine.Api.Project.Tests
context
.
SetupGet
(
x
=>
x
.
Request
).
Returns
(
request
.
Object
);
var
claimsPrincipal
=
new
Mock
<
ClaimsPrincipal
>();
Claim
claim
=
new
Claim
(
"UserID"
,
user
.
Id
.
ToString
());
Claim
claim
=
new
Claim
(
"userId"
,
user
.
Id
.
ToString
());
var
list
=
new
List
<
Claim
>
{
claim
};
context
.
SetupGet
(
x
=>
x
.
User
).
Returns
(
claimsPrincipal
.
Object
);
context
.
Setup
(
x
=>
x
.
User
.
FindFirst
(
"UserID"
)).
Returns
(
claim
);
context
.
Setup
(
x
=>
x
.
User
.
FindFirst
(
"userId"
)).
Returns
(
claim
);
context
.
SetupGet
(
x
=>
x
.
User
.
Claims
).
Returns
(
list
);
if
(
stream
!=
null
)
{
...
...
src/Project.Tests/Project.Tests.csproj
View file @
d98aaddb
...
...
@@ -59,20 +59,23 @@
<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.1
6
.0.0, Culture=neutral, processorArchitecture=AMD64"
>
<HintPath>
..\packages\Coscine.Action.1.1
6
.0\lib\net461\Coscine.Action.dll
</HintPath>
<Reference
Include=
"Coscine.Action, Version=1.1
7
.0.0, Culture=neutral, processorArchitecture=AMD64"
>
<HintPath>
..\packages\Coscine.Action.1.1
7
.0\lib\net461\Coscine.Action.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.ApiCommons, Version=1.1
0
.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.ApiCommons.1.1
0
.0\lib\net461\Coscine.ApiCommons.dll
</HintPath>
<Reference
Include=
"Coscine.ApiCommons, Version=1.1
1
.0.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.ApiCommons.1.1
1
.0\lib\net461\Coscine.ApiCommons.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Database, Version=1.2
6
.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.2
6
.0\lib\net461\Coscine.Database.dll
</HintPath>
<Reference
Include=
"Coscine.Database, Version=1.2
7
.0.0, Culture=neutral, PublicKeyToken=767d77427707b70a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.2
7
.0\lib\net461\Coscine.Database.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Database.T4, Version=1.26.0.0, Culture=neutral, PublicKeyToken=84b4c404a0696261, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.26.0\lib\net461\Coscine.Database.T4.dll
</HintPath>
<Reference
Include=
"Coscine.Database.T4, Version=1.27.0.0, Culture=neutral, PublicKeyToken=84b4c404a0696261, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Database.1.27.0\lib\net461\Coscine.Database.T4.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.JwtHandler, Version=1.2.0.0, Culture=neutral, PublicKeyToken=aaacf41df3a6253c, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.JwtHandler.1.2.0\lib\net461\Coscine.JwtHandler.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.Logging, Version=1.2.0.0, Culture=neutral, PublicKeyToken=e1ed402bc3f6525e, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.Logging.1.2.0\lib\net461\Coscine.Logging.dll
</HintPath>
...
...
@@ -80,14 +83,23 @@
<Reference
Include=
"Coscine.ProxyApi, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.ProxyApi.1.3.0\lib\net461\Coscine.ProxyApi.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.ResourceConfiguration, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.ResourceConfiguration.1.3.0\lib\net461\Coscine.ResourceConfiguration.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.ResourceLoader, Version=1.2.0.0, Culture=neutral, processorArchitecture=AMD64"
>
<HintPath>
..\packages\Coscine.ResourceLoader.1.2.0\lib\net461\Coscine.ResourceLoader.dll
</HintPath>
</Reference>
<Reference
Include=
"Coscine.ResourceTypeBase, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Coscine.ResourceTypeBase.1.4.0\lib\net461\Coscine.ResourceTypeBase.dll
</HintPath>
</Reference>
<Reference
Include=
"EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
>
<HintPath>
..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll
</HintPath>
</Reference>
<Reference
Include=
"EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
>
<HintPath>
..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll
</HintPath>
</Reference>
<Reference
Include=
"HtmlAgilityPack, Version=1.
8.2
.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\HtmlAgilityPack.1.
8.2
\lib\Net45\HtmlAgilityPack.dll
</HintPath>
<Reference
Include=
"HtmlAgilityPack, Version=1.
11.17
.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\HtmlAgilityPack.1.
11.17
\lib\Net45\HtmlAgilityPack.dll
</HintPath>
</Reference>
<Reference
Include=
"linq2db, Version=3.1.1.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\linq2db.3.1.1\lib\net46\linq2db.dll
</HintPath>
...
...
@@ -377,11 +389,11 @@
<Reference
Include=
"microsoft.identitymodel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.7.0.0\lib\net35\microsoft.identitymodel.dll
</HintPath>
</Reference>
<Reference
Include=
"Microsoft.IdentityModel.JsonWebTokens, Version=
5.6.0
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.JsonWebTokens.
5.6.0
\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll
</HintPath>
<Reference
Include=
"Microsoft.IdentityModel.JsonWebTokens, Version=
6.7.1
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.JsonWebTokens.
6.7.1
\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll
</HintPath>
</Reference>
<Reference
Include=
"Microsoft.IdentityModel.Logging, Version=
5.6.0
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.Logging.
5.6.0
\lib\net461\Microsoft.IdentityModel.Logging.dll
</HintPath>
<Reference
Include=
"Microsoft.IdentityModel.Logging, Version=
6.7.1
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.Logging.
6.7.1
\lib\net461\Microsoft.IdentityModel.Logging.dll
</HintPath>
</Reference>
<Reference
Include=
"Microsoft.IdentityModel.Protocols, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.Protocols.5.3.0\lib\net461\Microsoft.IdentityModel.Protocols.dll
</HintPath>
...
...
@@ -389,8 +401,8 @@
<Reference
Include=
"Microsoft.IdentityModel.Protocols.OpenIdConnect, Version=5.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.5.3.0\lib\net461\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
</HintPath>
</Reference>
<Reference
Include=
"Microsoft.IdentityModel.Tokens, Version=
5.6.0
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.Tokens.
5.6.0
\lib\net461\Microsoft.IdentityModel.Tokens.dll
</HintPath>
<Reference
Include=
"Microsoft.IdentityModel.Tokens, Version=
6.7.1
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.IdentityModel.Tokens.
6.7.1
\lib\net461\Microsoft.IdentityModel.Tokens.dll
</HintPath>
</Reference>
<Reference
Include=
"Microsoft.Net.Http.Headers, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll
</HintPath>
...
...
@@ -479,8 +491,8 @@
<Private>
True
</Private>
</Reference>
<Reference
Include=
"System.Drawing"
/>
<Reference
Include=
"System.IdentityModel.Tokens.Jwt, Version=
5.6.0
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\System.IdentityModel.Tokens.Jwt.
5.6.0
\lib\net461\System.IdentityModel.Tokens.Jwt.dll
</HintPath>
<Reference
Include=
"System.IdentityModel.Tokens.Jwt, Version=
6.7.1
.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\System.IdentityModel.Tokens.Jwt.
6.7.1
\lib\net461\System.IdentityModel.Tokens.Jwt.dll
</HintPath>
</Reference>
<Reference
Include=
"System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
</HintPath>
...
...
src/Project.Tests/ProjectControllerTests.cs
View file @
d98aaddb
...
...
@@ -21,19 +21,22 @@ namespace Coscine.Api.Project.Tests
{
private
static
ILogger
<
ProjectController
>
projectLogger
=
null
;
private
static
ILogger
<
ProjectController
>
ProjectLogger
{
get
private
static
ILogger
<
ProjectController
>
ProjectLogger
{
if
(
projectLogger
==
null
)
get
{
CoscineLoggerConfiguration
.
SetConfig
();
projectLogger
=
new
NullLogger
<
ProjectController
>();
if
(
projectLogger
==
null
)
{
CoscineLoggerConfiguration
.
SetConfig
();
projectLogger
=
new
NullLogger
<
ProjectController
>();
}
return
projectLogger
;
}
return
projectLogger
;
}
}
}
public
ProjectControllerTests
()
:
base
(
new
ProjectController
(
ProjectLogger
))
{
}
[
Test
]
...
...
@@ -55,14 +58,14 @@ namespace Coscine.Api.Project.Tests
[
Test
]
public
void
TestControllerIndex
()
{
var
actionResult
=
Controller
.
Index
();
var
actionResult
=
Controller
.
Index
()
.
Result
;
Assert
.
IsTrue
(
actionResult
.
GetType
()
==
typeof
(
OkObjectResult
));
}
[
Test
]
public
void
TestControllerGet
()
{
var
actionResult
=
Controller
.
Get
(
Projects
[
0
].
Id
.
ToString
());
var
actionResult
=
Controller
.
Get
(
Projects
[
0
].
Id
.
ToString
())
.
Result
;
Assert
.
IsTrue
(
actionResult
.
GetType
()
==
typeof
(
OkObjectResult
));
OkObjectResult
okObjectResult
=
(
OkObjectResult
)
actionResult
;
...
...
@@ -83,17 +86,17 @@ namespace Coscine.Api.Project.Tests
[
Test
]
public
void
TestControllerUpdate
()
{
var
actionResult
=
Controller
.
Get
(
Projects
[
0
].
Id
.
ToString
());
var
actionResult
=
Controller
.
Get
(
Projects
[
0
].
Id
.
ToString
())
.
Result
;
ProjectObject
projectObject
=
(
ProjectObject
)((
OkObjectResult
)
actionResult
).
Value
;
projectObject
.
Description
=
"ChangedDescription"
;
Stream
stream
=
ObjectFactory
<
ProjectObject
>.
SerializeToStream
(
projectObject
);
FakeControllerContext
(
Users
[
0
],
stream
);
action
Result
=
Controller
.
Update
(
Projects
[
0
].
Id
.
ToString
());
Assert
.
IsTrue
(
action
Result
.
GetType
()
==
typeof
(
OkObjectResult
));
var
update
Result
=
Controller
.
Update
(
Projects
[
0
].
Id
.
ToString
());
Assert
.
IsTrue
(
update
Result
.
GetType
()
==
typeof
(
OkObjectResult
));
// Cleanup
stream
.
Close
();
...
...
@@ -102,8 +105,8 @@ namespace Coscine.Api.Project.Tests
FakeControllerContext
(
Users
[
0
],
stream
);
action
Result
=
Controller
.
Update
(
Projects
[
1
].
Id
.
ToString
());
Assert
.
IsTrue
(
action
Result
.
GetType
()
==
typeof
(
UnauthorizedObjectResult
));
update
Result
=
Controller
.
Update
(
Projects
[
1
].
Id
.
ToString
());
Assert
.
IsTrue
(
update
Result
.
GetType
()
==
typeof
(
UnauthorizedObjectResult
));
// Cleanup
stream
.
Close
();
...
...
@@ -112,7 +115,7 @@ namespace Coscine.Api.Project.Tests
[
Test
]
public
void
TestControllerStore
()
{
ProjectObject
newProjectObject
=
new
ProjectObject
(
Guid
.
NewGuid
(),
"NewProject"
,
"NewDisplayName"
,
DateTime
.
Now
,
DateTime
.
Now
.
AddYears
(
1
),
"test2;test3"
,
"abc"
,
"investigator"
,
"grandId"
,
ProjectObject
newProjectObject
=
new
ProjectObject
(
Guid
.
NewGuid
(),
"NewProject"
,
"NewDisplayName"
,
DateTime
.
Now
,
DateTime
.
Now
.
AddYears
(
1
),
"test2;test3"
,
"abc"
,
"investigator"
,
"grandId"
,
new
List
<
DisciplineObject
>()
{
new
DisciplineObject
(
Discipline
.
Id
,
Discipline
.
Url
,
Discipline
.
DisplayNameDe
,
Discipline
.
DisplayNameEn
)
},
new
List
<
OrganizationObject
>()
{
new
OrganizationObject
(
Organization
,
Organization
)
},
new
VisibilityObject
(
Visibility
.
Id
,
Visibility
.
DisplayName
),
Guid
.
NewGuid
().
ToString
());
...
...
@@ -181,7 +184,7 @@ namespace Coscine.Api.Project.Tests
stream
.
Close
();
Controller
.
DeleteProject
(
project
,
true
);
}
[
Test
]
public
void
TestControllerDeleteWithSubProjects
()
{
...
...
@@ -247,7 +250,7 @@ namespace Coscine.Api.Project.Tests
ProjectObject
newSubProjectObject
=
new
ProjectObject
(
Guid
.
NewGuid
(),
"NewSubProject"
,
"NewDisplayNameSub"
,
DateTime
.
Now
,
DateTime
.
Now
.
AddYears
(
1
),
"test2;test3"
,
"abc"
,
"investigator"
,
"grandId"
,
new
List
<
DisciplineObject
>()
{
new
DisciplineObject
(
Discipline
.
Id
,
Discipline
.
Url
,
Discipline
.
DisplayNameDe
,
Discipline
.
DisplayNameEn
)
},
new
List
<
OrganizationObject
>()
{
new
OrganizationObject
(
Organization
,
Organization
)
},
new
VisibilityObject
(
Visibility
.
Id
,
Visibility
.
DisplayName
),
Guid
.
NewGuid
().
ToString
(),
new
VisibilityObject
(
Visibility
.
Id
,
Visibility
.
DisplayName
),
Guid
.
NewGuid
().
ToString
(),
createdProjectObject
.
Id
);
var
subStream
=
ObjectFactory
<
ProjectObject
>.
SerializeToStream
(
newSubProjectObject
);
...
...
@@ -259,7 +262,7 @@ namespace Coscine.Api.Project.Tests
SubProjectModel
subProjectModel
=
new
SubProjectModel
();
var
subProjects
=
subProjectModel
.
GetAllWhere
((
x
)
=>
x
.
ProjectId
==
createdProjectObject
.
Id
);
foreach
(
var
subProject
in
subProjects
)
foreach
(
var
subProject
in
subProjects
)
{
Assert
.
IsTrue
(
subProject
.
SubProjectId
==
createdSubProjectObject
.
Id
);
Assert
.
IsTrue
(
subProject
.
ProjectId
==
createdProjectObject
.
Id
);
...
...
@@ -281,4 +284,4 @@ namespace Coscine.Api.Project.Tests
Assert
.
IsTrue
(
Previous
==
projectModel
.
GetAll
().
ToArray
().
Length
-
Projects
.
Count
);
}
}
}
\ No newline at end of file
}
src/Project.Tests/app.config
View file @
d98aaddb
...
...
@@ -88,15 +88,15 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database"
publicKeyToken
=
"767d77427707b70a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
6
.0.0"
newVersion
=
"1.2
6
.0.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
7
.0.0"
newVersion
=
"1.2
7
.0.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"System.IdentityModel.Tokens.Jwt"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
5.6.0
.0"
newVersion
=
"
5.6.0
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
6.7.1
.0"
newVersion
=
"
6.7.1
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Microsoft.IdentityModel.Tokens"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
5.6.0
.0"
newVersion
=
"
5.6.0
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
6.7.1
.0"
newVersion
=
"
6.7.1
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.SharePoint.Webparts.Vue"
publicKeyToken
=
"0fe8d3e516df6d98"
culture
=
"neutral"
/>
...
...
@@ -144,7 +144,7 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Microsoft.IdentityModel.Logging"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
5.6.0
.0"
newVersion
=
"
5.6.0
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
6.7.1
.0"
newVersion
=
"
6.7.1
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"LinqKit"
publicKeyToken
=
"bc217f8844052a91"
culture
=
"neutral"
/>
...
...
@@ -188,11 +188,11 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"HtmlAgilityPack"
publicKeyToken
=
"bd319b19eaf3b43a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.
8.2
.0"
newVersion
=
"1.
8.2
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.
11.17
.0"
newVersion
=
"1.
11.17
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database.T4"
publicKeyToken
=
"84b4c404a0696261"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
6
.0.0"
newVersion
=
"1.2
6
.0.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
7
.0.0"
newVersion
=
"1.2
7
.0.0"
/>
</
dependentAssembly
>
</
assemblyBinding
>
</
runtime
>
...
...
src/Project.Tests/packages.config
View file @
d98aaddb
...
...
@@ -4,14 +4,18 @@
<
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.1
6
.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ApiCommons"
version
=
"1.1
0
.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Action"
version
=
"1.1
7
.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ApiCommons"
version
=
"1.1
1
.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Configuration"
version
=
"1.5.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.26.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Database"
version
=
"1.27.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.JwtHandler"
version
=
"1.2.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.Logging"
version
=
"1.2.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ProxyApi"
version
=
"1.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ResourceConfiguration"
version
=
"1.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ResourceLoader"
version
=
"1.2.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Coscine.ResourceTypeBase"
version
=
"1.4.0"
targetFramework
=
"net472"
/>
<
package
id
=
"EntityFramework"
version
=
"6.4.4"
targetFramework
=
"net472"
/>
<
package
id
=
"HtmlAgilityPack"
version
=
"1.
8.2
"
targetFramework
=
"net472"
/>
<
package
id
=
"HtmlAgilityPack"
version
=
"1.
11.17
"
targetFramework
=
"net472"
/>
<
package
id
=
"linq2db"
version
=
"3.1.1"
targetFramework
=
"net472"
/>
<
package
id
=
"linq2db.SqlServer"
version
=
"2.6.4"
targetFramework
=
"net472"
/>
<
package
id
=
"linq2db.t4models"
version
=
"2.6.4"
targetFramework
=
"net472"
/>
...
...
@@ -116,11 +120,11 @@
<
package
id
=
"Microsoft.Extensions.Primitives"
version
=
"2.2.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.Extensions.WebEncoders"
version
=
"2.2.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel"
version
=
"7.0.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.JsonWebTokens"
version
=
"
5.6.0
"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.Logging"
version
=
"
5.6.0
"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.JsonWebTokens"
version
=
"
6.7.1
"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.Logging"
version
=
"
6.7.1
"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.Protocols"
version
=
"5.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.Protocols.OpenIdConnect"
version
=
"5.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.Tokens"
version
=
"
5.6.0
"
targetFramework
=
"net472"
/>
<
package
id
=
"Microsoft.IdentityModel.Tokens"
version
=
"
6.7.1
"
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.13.1"
targetFramework
=
"net472"
/>
...
...
@@ -152,7 +156,7 @@
<
package
id
=
"System.Diagnostics.FileVersionInfo"
version
=
"4.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"System.Diagnostics.StackTrace"
version
=
"4.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"System.Dynamic.Runtime"
version
=
"4.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"System.IdentityModel.Tokens.Jwt"
version
=
"
5.6.0
"
targetFramework
=
"net472"
/>
<
package
id
=
"System.IdentityModel.Tokens.Jwt"
version
=
"
6.7.1
"
targetFramework
=
"net472"
/>
<
package
id
=
"System.IO"
version
=
"4.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"System.IO.Compression"
version
=
"4.3.0"
targetFramework
=
"net472"
/>
<
package
id
=
"System.IO.FileSystem"
version
=
"4.3.0"
targetFramework
=
"net472"
/>
...
...
src/Project/App.config
View file @
d98aaddb
...
...
@@ -91,15 +91,15 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database"
publicKeyToken
=
"767d77427707b70a"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
6
.0.0"
newVersion
=
"1.2
6
.0.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
7
.0.0"
newVersion
=
"1.2
7
.0.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"System.IdentityModel.Tokens.Jwt"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
5.6.0
.0"
newVersion
=
"
5.6.0
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
6.7.1
.0"
newVersion
=
"
6.7.1
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Microsoft.IdentityModel.Tokens"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
5.6.0
.0"
newVersion
=
"
5.6.0
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
6.7.1
.0"
newVersion
=
"
6.7.1
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.SharePoint.Webparts.Vue"
publicKeyToken
=
"0fe8d3e516df6d98"
culture
=
"neutral"
/>
...
...
@@ -147,7 +147,7 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Microsoft.IdentityModel.Logging"
publicKeyToken
=
"31bf3856ad364e35"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
5.6.0
.0"
newVersion
=
"
5.6.0
.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-
6.7.1
.0"
newVersion
=
"
6.7.1
.0"
/>
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"LinqKit"
publicKeyToken
=
"bc217f8844052a91"
culture
=
"neutral"
/>
...
...
@@ -191,7 +191,7 @@
</
dependentAssembly
>
<
dependentAssembly
>
<
assemblyIdentity
name
=
"Coscine.Database.T4"
publicKeyToken
=
"84b4c404a0696261"
culture
=
"neutral"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
6
.0.0"
newVersion
=
"1.2
6
.0.0"
/>
<
bindingRedirect
oldVersion
=
"0.0.0.0-1.2
7
.0.0"
newVersion
=
"1.2
7
.0.0"
/>
</
dependentAssembly
>
</
assemblyBinding
>
</
runtime
>
...
...
src/Project/Controllers/DisciplineController.cs
View file @
d98aaddb
...
...
@@ -2,22 +2,34 @@
using
Coscine.Database.ReturnObjects
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
Coscine.Api.Project.Controllers
{
/// <summary>
/// This controller represents the actions which can be taken with a discipline object.
/// </summary>
[
Authorize
]
public
class
DisciplineController
:
Controller
{
private
readonly
DisciplineModel
_disciplineModel
;
/// <summary>
/// DisciplineController constructor specifying a DisciplineModel
/// </summary>
public
DisciplineController
()
{
_disciplineModel
=
new
DisciplineModel
();
}
/// <summary>
/// Returns all available disciplines
/// </summary>
/// <returns>All Disciplines</returns>
[
Route
(
"[controller]"
)]
public
I
ActionResult
Index
()
public
ActionResult
<
IEnumerable
<
DisciplineObject
>>
Index
()
{
return
Json
(
_disciplineModel
.
GetAll
()
.
OrderBy
(
discipline
=>
discipline
.
DisplayNameDe
.
Substring
(
discipline
.
DisplayNameDe
.
Length
-
3
))
...
...
src/Project/Controllers/LicenseController.cs
View file @
d98aaddb
...
...
@@ -2,22 +2,34 @@
using
Coscine.Database.ReturnObjects
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
System.Collections.Generic
;
using
System.Linq
;
namespace
Coscine.Api.Project.Controllers
{
/// <summary>
/// This controller represents the actions which can be taken with a license object.
/// </summary>
[
Authorize
]
public
class
LicenseController
:
Controller
{
private
readonly
LicenseModel
_licenseModel
;
/// <summary>
/// LicenseController constructor specifying a LicenseModel
/// </summary>
public
LicenseController
()
{
_licenseModel
=
new
LicenseModel
();
}
/// <summary>
/// Returns all available licenses
/// </summary>
/// <returns>All Licenses</returns>
[
Route
(
"[controller]"
)]
public
I
ActionResult
Index
()
public
ActionResult
<
IEnumerable
<
LicenseObject
>>
Index
()
{
return
Json
(
_licenseModel
.
GetAll
()
.
Select
((
license
)
=>
new
LicenseObject
(
license
.
Id
,
license
.
DisplayName
)));
...
...
src/Project/Controllers/ProjectController.cs
View file @
d98aaddb
using
Coscine.Action
;
using
Coscine.Action.EventArgs
;
using
Coscine.Database.Models
;
using
Coscine.Database.ReturnObjects
;
using
Coscine.ApiCommons
;
using
Coscine.ApiCommons.Factories
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Linq
;
using
Coscine.Configuration
;
using
Microsoft.AspNetCore.Authorization
;
using
Coscine.Database.DataModel
;
using
Coscine.Database.Models
;
using
Coscine.Database.ReturnObjects
;
using
Coscine.Database.Util
;
using
Coscine.Logging
;
using
Coscine.Metadata
;
using
Coscine.ResourceLoader
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.Logging
;
using
Newtonsoft.Json.Linq
;
using
Coscine.Database.DataModel
;
using
System
;
using
System.Collections.Generic
;
using
System.Text.RegularExpressions
;
using
Coscine.Metadata
;
using
System.Linq
;
namespace
Coscine.Api.Project.Controllers
{
/// <summary>
/// /// This controller represents the actions which can be taken with a project object.
/// </summary>
[
Authorize
]
public
class
ProjectController
:
Controller
{
...
...
@@ -32,6 +35,10 @@ namespace Coscine.Api.Project.Controllers
private
readonly
CoscineLogger
_coscineLogger
;
private
readonly
AnalyticsLogObject
_analyticsLogObject
;
/// <summary>
/// ProjectController constructor
/// </summary>
/// <param name="logger">Logger</param>
public
ProjectController
(
ILogger
<
ProjectController
>
logger
)
{
_authenticator
=
new
Authenticator
(
this
,
Program
.
Configuration
);
...
...
@@ -43,9 +50,13 @@ namespace Coscine.Api.Project.Controllers
_coscineLogger
=
new
CoscineLogger
(
logger
);
_analyticsLogObject
=
new
AnalyticsLogObject
();
}
/// <summary>
/// Returns all available projects (including sub projects)
/// </summary>
/// <returns>Ok</returns>
[
Route
(
"[controller]"
)]
public
I
ActionResult
Index
()
public
ActionResult
<
IEnumerable
<
ProjectObject
>>
Index
()
{
var
user
=
_authenticator
.
GetUser
();
var
result
=
_projectModel
.
GetWithAccess
(
user
,
UserRoles
.
Member
,
UserRoles
.
Owner
).
ToList
()
...
...
@@ -60,8 +71,12 @@ namespace Coscine.Api.Project.Controllers
return
Ok
(
result
);
}
/// <summary>
/// Retrieves all top level projects
/// </summary>
/// <returns>Ok</returns>
[
Route
(
"[controller]/-/topLevel"
)]
public
I
ActionResult
GetTopLevelProjects
()
public
ActionResult
<
IEnumerable
<
ProjectObject
>>
GetTopLevelProjects
()
{
var
user
=
_authenticator
.
GetUser
();
var
result
=
_projectModel
.
GetTopLevelWithAccess
(
user
,
UserRoles
.
Member
,
UserRoles
.
Owner
).
ToList
()
...
...
@@ -76,8 +91,13 @@ namespace Coscine.Api.Project.Controllers
return
Ok
(
result
);
}
/// <summary>
/// This returns the the project if the user has access to it
/// </summary>
/// <param name="id">Id of the resource</param>
/// <returns>Ok or Statuscode 401</returns>
[
HttpGet
(
"[controller]/{id}"
)]
public
I
ActionResult
Get
(
string
id
)
public
ActionResult
<
ProjectObject
>
Get
(
string
id
)
{
var
user
=
_authenticator
.
GetUser
();
var
project
=
_projectModel
.
GetById
(
Guid
.
Parse
(
id
));
...
...
@@ -99,8 +119,13 @@ namespace Coscine.Api.Project.Controllers
}
}
/// <summary>
/// Gets the resources
/// </summary>
/// <param name="id">Id of the resource</param>
/// <returns>Json object or Statuscode 401</returns>
[
HttpGet
(
"[controller]/{id}/resources"
)]
public
I
ActionResult
GetResources
(
string
id
)
public
ActionResult
<
IEnumerable
<
ResourceObject
>>
GetResources
(
string
id
)
{
var
project
=
_projectModel
.
GetById
(
Guid
.
Parse
(
id
));
var
user
=
_authenticator
.
GetUser
();
...
...
@@ -129,8 +154,13 @@ namespace Coscine.Api.Project.Controllers
}
}
/// <summary>
/// Retrieves the quota for the selected project
/// </summary>
/// <param name="id">Id of the resource</param>
/// <returns>Json object or Statuscode 401</returns>
[
HttpGet
(
"[controller]/{id}/quotas"
)]
public
I
ActionResult
Quotas
(
string
id
)
public
ActionResult
<
IEnumerable
<
ProjectQuota
>>
Quotas
(
string
id
)
{
var
user
=
_authenticator
.
GetUser
();
var
projectObject
=
ObjectFactory
<
ProjectObject
>.
DeserializeFromStream
(
Request
.
Body
);
...
...
@@ -177,6 +207,11 @@ namespace Coscine.Api.Project.Controllers
}
}
/// <summary>
/// Updates the selected project
/// </summary>
/// <param name="id">Id of the resource</param>
/// <returns>Ok or Statuscode 401</returns>
[
HttpPost
(
"[controller]/{id}"
)]
public
IActionResult
Update
(
string
id
)
{
...
...
@@ -194,6 +229,11 @@ namespace Coscine.Api.Project.Controllers
}
}
/// <summary>
/// Deletes the selected project
/// </summary>
/// <param name="id">Id of the resource</param>
/// <returns>Json object or Statuscode 401</returns>
[
HttpDelete
(
"[controller]/{id}"
)]
public
IActionResult
Delete
(
string
id
)
{
...
...
@@ -211,6 +251,12 @@ namespace Coscine.Api.Project.Controllers
}
}
/// <summary>
/// Deletes the project