Browse Source

Refactorings

pull/1/head
Sebastian 9 years ago
parent
commit
040fed0d1f
  1. 6
      src/Squidex.Infrastructure/CQRS/Commands/IUserCommand.cs
  2. 5
      src/Squidex.Infrastructure/Security/Extensions.cs
  3. 5
      src/Squidex.Infrastructure/Security/OpenIdClaims.cs
  4. 11
      src/Squidex.Infrastructure/UserToken.cs
  5. 4
      src/Squidex.Write/Apps/AppDomainObject.cs
  6. 4
      src/Squidex.Write/Apps/Commands/CreateApp.cs
  7. 2
      src/Squidex/Config/Domain/WriteModule.cs
  8. 48
      src/Squidex/Pipeline/AppFilterAttribute.cs
  9. 18
      src/Squidex/Pipeline/CommandHandlers/EnrichWithUserHandler.cs
  10. 18
      src/Squidex/app/components/internal/app/settings/clients-page.component.html
  11. 5
      src/Squidex/app/components/internal/app/settings/clients-page.component.scss
  12. 15
      src/Squidex/app/components/internal/app/settings/clients-page.component.ts
  13. 14
      src/Squidex/app/shared/services/app-clients.service.ts
  14. 4
      src/Squidex/project.json
  15. 3
      tests/Squidex.Core.Tests/Schemas/FieldRegistryTests.cs
  16. 4
      tests/Squidex.Core.Tests/Schemas/Json/JsonSerializerTests.cs
  17. 7
      tests/Squidex.Core.Tests/Schemas/NumberFieldPropertiesTests.cs
  18. 5
      tests/Squidex.Core.Tests/Schemas/NumberFieldTests.cs
  19. 5
      tests/Squidex.Core.Tests/Schemas/SchemaTests.cs
  20. 3
      tests/Squidex.Core.Tests/Schemas/StringFieldPropertiesTests.cs
  21. 5
      tests/Squidex.Core.Tests/Schemas/StringFieldTests.cs
  22. 5
      tests/Squidex.Core.Tests/Schemas/Validators/AllowedValuesValidatorTests.cs
  23. 3
      tests/Squidex.Core.Tests/Schemas/Validators/PatternValidatorTests.cs
  24. 3
      tests/Squidex.Core.Tests/Schemas/Validators/RangeValidatorTests.cs
  25. 5
      tests/Squidex.Core.Tests/Schemas/Validators/RequiredStringValidatorTests.cs
  26. 5
      tests/Squidex.Core.Tests/Schemas/Validators/RequiredValidatorTests.cs
  27. 3
      tests/Squidex.Core.Tests/Schemas/Validators/StringLengthValidatorTests.cs
  28. 2
      tests/Squidex.Core.Tests/Squidex.Core.Tests.xproj
  29. 2
      tests/Squidex.Core.Tests/project.json
  30. 17
      tests/Squidex.Infrastructure.Tests/UserTokenTests.cs
  31. 14
      tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs
  32. 8
      tests/Squidex.Write.Tests/Apps/AppDomainObjectTests.cs
  33. 3
      tests/Squidex.Write.Tests/Apps/ClientKeyGeneratorTests.cs
  34. 6
      tests/Squidex.Write.Tests/Schemas/SchemaCommandHandlerTests.cs
  35. 4
      tests/Squidex.Write.Tests/Schemas/SchemaDomainObjectTests.cs
  36. 2
      tests/Squidex.Write.Tests/Squidex.Write.Tests.xproj
  37. 2
      tests/Squidex.Write.Tests/Utils/HandlerTestBase.cs
  38. 2
      tests/Squidex.Write.Tests/Utils/SchemaFixture.cs
  39. 2
      tests/Squidex.Write.Tests/project.json

6
src/Squidex.Infrastructure/CQRS/Commands/ISubjectCommand.cs → src/Squidex.Infrastructure/CQRS/Commands/IUserCommand.cs

@ -1,5 +1,5 @@
// ==========================================================================
// ISubjectCommand.cs
// IUserCommand.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
@ -8,8 +8,8 @@
namespace Squidex.Infrastructure.CQRS.Commands
{
public interface ISubjectCommand : ICommand
public interface IUserCommand : ICommand
{
string SubjectId { get; set; }
string UserId { get; set; }
}
}

5
src/Squidex.Infrastructure/Security/Extensions.cs

@ -18,6 +18,11 @@ namespace Squidex.Infrastructure.Security
return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.Subject)?.Value;
}
public static string OpenIdClientId(this ClaimsPrincipal principal)
{
return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.ClientId)?.Value;
}
public static string OpenIdPreferredUserName(this ClaimsPrincipal principal)
{
return principal.Claims.FirstOrDefault(x => x.Type == OpenIdClaims.PreferredUserName)?.Value;

5
src/Squidex.Infrastructure/Security/OpenIdClaims.cs

@ -15,6 +15,11 @@ namespace Squidex.Infrastructure.Security
/// </summary>
public const string Subject = "sub";
/// <summary>
/// The client id claim.
/// </summary>
public const string ClientId = "client_id";
/// <summary>
/// End-User's full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User's locale and preferences.
/// </summary>

11
src/Squidex.Infrastructure/UserToken.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Squidex.Infrastructure
{
public sealed class UserToken
{
}
}

4
src/Squidex.Write/Apps/AppDomainObject.cs

@ -173,9 +173,9 @@ namespace Squidex.Write.Apps
return new AppLanguagesConfigured { Languages = DefaultLanguages };
}
private static AppContributorAssigned CreateInitialOwner(ISubjectCommand command)
private static AppContributorAssigned CreateInitialOwner(IUserCommand command)
{
return new AppContributorAssigned { ContributorId = command.SubjectId, Permission = PermissionLevel.Owner };
return new AppContributorAssigned { ContributorId = command.UserId, Permission = PermissionLevel.Owner };
}
private void ThrowIfNotCreated()

4
src/Squidex.Write/Apps/Commands/CreateApp.cs

@ -13,11 +13,11 @@ using Squidex.Infrastructure.CQRS.Commands;
namespace Squidex.Write.Apps.Commands
{
public sealed class CreateApp : AggregateCommand, ISubjectCommand, IValidatable
public sealed class CreateApp : AggregateCommand, IUserCommand, IValidatable
{
public string Name { get; set; }
public string SubjectId { get; set; }
public string UserId { get; set; }
public CreateApp()
{

2
src/Squidex/Config/Domain/WriteModule.cs

@ -22,7 +22,7 @@ namespace Squidex.Config.Domain
.As<ICommandHandler>()
.SingleInstance();
builder.RegisterType<EnrichWithSubjectHandler>()
builder.RegisterType<EnrichWithUserHandler>()
.As<ICommandHandler>()
.SingleInstance();

48
src/Squidex/Pipeline/AppFilterAttribute.cs

@ -12,7 +12,9 @@ using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Squidex.Core.Apps;
using Squidex.Infrastructure.Security;
using Squidex.Read.Apps;
using Squidex.Read.Apps.Services;
namespace Squidex.Pipeline
@ -40,23 +42,19 @@ namespace Squidex.Pipeline
return;
}
var subject = context.HttpContext.User.FindFirst(OpenIdClaims.Subject)?.Value;
var user = context.HttpContext.User;
if (subject == null)
{
context.Result = new NotFoundResult();
return;
}
var contributor = app.Contributors.FirstOrDefault(x => string.Equals(x.ContributorId, subject, StringComparison.OrdinalIgnoreCase));
var permission =
FindByOpenIdSubject(app, user) ??
FindByOpenIdClient(app, user);
if (contributor == null)
if (permission == null)
{
context.Result = new NotFoundResult();
return;
}
var roleName = $"app-{contributor.Permission.ToString().ToLowerInvariant()}";
var roleName = $"app-{permission.ToString().ToLowerInvariant()}";
var defaultIdentity = context.HttpContext.User.Identities.First();
@ -67,5 +65,35 @@ namespace Squidex.Pipeline
context.HttpContext.Features.Set<IAppFeature>(new AppFeature(app));
}
}
private static PermissionLevel? FindByOpenIdClient(IAppEntity app, ClaimsPrincipal user)
{
var clientId = user.FindFirst(OpenIdClaims.ClientId)?.Value;
if (clientId == null)
{
return null;
}
clientId = clientId.Split(':')[0];
var contributor = app.Clients.FirstOrDefault(x => string.Equals(x.ClientName, clientId, StringComparison.OrdinalIgnoreCase));
return contributor != null ? PermissionLevel.Owner : PermissionLevel.Editor;
}
private static PermissionLevel? FindByOpenIdSubject(IAppEntity app, ClaimsPrincipal user)
{
var subject = user.FindFirst(OpenIdClaims.Subject)?.Value;
if (subject == null)
{
return null;
}
var contributor = app.Contributors.FirstOrDefault(x => string.Equals(x.ContributorId, subject, StringComparison.OrdinalIgnoreCase));
return contributor?.Permission;
}
}
}

18
src/Squidex/Pipeline/CommandHandlers/EnrichWithSubjectHandler.cs → src/Squidex/Pipeline/CommandHandlers/EnrichWithUserHandler.cs

@ -15,29 +15,39 @@ using Squidex.Infrastructure.Security;
namespace Squidex.Pipeline.CommandHandlers
{
public class EnrichWithSubjectHandler : ICommandHandler
public class EnrichWithUserHandler : ICommandHandler
{
private readonly IHttpContextAccessor httpContextAccessor;
public EnrichWithSubjectHandler(IHttpContextAccessor httpContextAccessor)
public EnrichWithUserHandler(IHttpContextAccessor httpContextAccessor)
{
this.httpContextAccessor = httpContextAccessor;
}
public Task<bool> HandleAsync(CommandContext context)
{
var subjectCommand = context.Command as ISubjectCommand;
var subjectCommand = context.Command as IUserCommand;
if (subjectCommand != null)
{
var subjectId = httpContextAccessor.HttpContext.User.OpenIdSubject();
if (subjectId == null)
{
var clientId = httpContextAccessor.HttpContext.User.OpenIdClientId();
if (clientId != null)
{
subjectId = $"Client:"
}
}
if (subjectId == null)
{
throw new SecurityException("No user with subject id available");
}
subjectCommand.SubjectId = subjectId;
subjectCommand.UserId = subjectId;
}
return Task.FromResult(false);

18
src/Squidex/app/components/internal/app/settings/clients-page.component.html

@ -88,4 +88,22 @@
</div>
</div>
</div>
</div>
<div class="modal ng-animate" *sqxModalView="modalDialog" [@fade]>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="modalDialog.hide()">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Access Token</h4>
</div>
<div class="modal-body">
<textarea class="form-control access-token">{{appClientToken.tokenType}} {{appClientToken.accessToken}}</textarea>
</div>
</div>
</div>
</div>

5
src/Squidex/app/components/internal/app/settings/clients-page.component.scss

@ -41,4 +41,9 @@
&-expires {
padding: .3rem .8rem;
}
}
.access-token {
resize: none;
height: 300px;
}

15
src/Squidex/app/components/internal/app/settings/clients-page.component.ts

@ -8,12 +8,14 @@
import * as Ng2 from '@angular/core';
import * as Ng2Forms from '@angular/forms';
import {
import {
AccessTokenDto,
AppsStoreService,
AppClientDto,
AppClientCreateDto,
AppClientsService,
fadeAnimation,
ModalView,
Notification,
NotificationService,
TitleService
@ -31,7 +33,10 @@ export class ClientsPageComponent implements Ng2.OnInit {
private appSubscription: any | null = null;
private appName: string | null = null;
public modalDialog = new ModalView();
public appClients: AppClientDto[];
public appClientToken: AccessTokenDto;
public creationError = '';
public createForm =
@ -90,7 +95,13 @@ export class ClientsPageComponent implements Ng2.OnInit {
}
public createToken(client: AppClientDto) {
this.appClientsService.createToken(this.appName, client).subscribe();
this.appClientsService.createToken(this.appName, client)
.subscribe(token => {
this.appClientToken = token;
this.modalDialog.show();
}, error => {
this.notifications.notify(Notification.error('Failed to retrieve access token. Please retry.'));
});
}
public attachClient() {

14
src/Squidex/app/shared/services/app-clients.service.ts

@ -29,6 +29,14 @@ export class AppClientCreateDto {
}
}
export class AccessTokenDto {
constructor(
public readonly accessToken: string,
public readonly tokenType: string
) {
}
}
@Ng2.Injectable()
export class AppClientsService {
constructor(
@ -67,7 +75,7 @@ export class AppClientsService {
return this.authService.authDelete(this.apiUrl.buildUrl(`api/apps/${appName}/clients/${name}`));
}
public createToken(appName: string, client: AppClientDto): Observable<any> {
public createToken(appName: string, client: AppClientDto): Observable<AccessTokenDto> {
const options = new Ng2Http.RequestOptions({
headers: new Ng2Http.Headers({
'Content-Type': 'application/x-www-form-urlencoded'
@ -76,6 +84,8 @@ export class AppClientsService {
const body = `grant_type=client_credentials&scope=squidex-api&client_id=${appName}:${client.clientName}&client_secret=${client.clientSecret}`;
return this.http.post(this.apiUrl.buildUrl('identity-server/connect/token'), body, options);
return this.http.post(this.apiUrl.buildUrl('identity-server/connect/token'), body, options)
.map(response => response.json())
.map(response => new AccessTokenDto(response.access_token, response.token_type));
}
}

4
src/Squidex/project.json

@ -55,11 +55,13 @@
}
},
"nowarn": [ "1591" ],
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"xmlDoc": true,
"nowarn": [ "1591", "1573", "1572" ],
"nowarn": [ "CS1591", "1591", "1573", "1572" ],
"embed": {
"include": [
"Config/Identity/Cert/*.*"

3
tests/Squidex.Core.Tests/Schemas/FieldRegistryTests.cs

@ -8,11 +8,10 @@
using System;
using System.Collections.Generic;
using Squidex.Core.Schemas;
using Squidex.Infrastructure;
using Xunit;
namespace Squidex.Core.Tests.Schemas
namespace Squidex.Core.Schemas
{
public class FieldRegistryTests
{

4
tests/Squidex.Core.Tests/Schemas/Json/JsonSerializerTests.cs

@ -9,13 +9,11 @@
using System.Reflection;
using FluentAssertions;
using Newtonsoft.Json;
using Squidex.Core.Schemas;
using Squidex.Core.Schemas.Json;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Json;
using Xunit;
namespace Squidex.Core.Tests.Schemas.Json
namespace Squidex.Core.Schemas.Json
{
public class JsonSerializerTests
{

7
tests/Squidex.Core.Tests/Schemas/NumberFieldPropertiesTests.cs

@ -9,14 +9,13 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using Squidex.Core.Schemas;
using FluentAssertions;
using Squidex.Infrastructure;
using Xunit;
using FluentAssertions;
using System.Linq;
namespace Squidex.Core.Tests.Schemas
namespace Squidex.Core.Schemas
{
public class NumberFieldPropertiesTests
{

5
tests/Squidex.Core.Tests/Schemas/NumberFieldTests.cs

@ -9,12 +9,11 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Squidex.Core.Schemas;
using FluentAssertions;
using Squidex.Infrastructure;
using Xunit;
using FluentAssertions;
namespace Squidex.Core.Tests.Schemas
namespace Squidex.Core.Schemas
{
public class NumberFieldTests
{

5
tests/Squidex.Core.Tests/Schemas/SchemaTests.cs

@ -9,12 +9,11 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Squidex.Core.Schemas;
using FluentAssertions;
using Squidex.Infrastructure;
using Xunit;
using FluentAssertions;
namespace Squidex.Core.Tests.Schemas
namespace Squidex.Core.Schemas
{
public class SchemaTests
{

3
tests/Squidex.Core.Tests/Schemas/StringFieldPropertiesTests.cs

@ -11,11 +11,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FluentAssertions;
using Squidex.Core.Schemas;
using Squidex.Infrastructure;
using Xunit;
namespace Squidex.Core.Tests.Schemas
namespace Squidex.Core.Schemas
{
public class StringFieldPropertiesTests
{

5
tests/Squidex.Core.Tests/Schemas/StringFieldTests.cs

@ -9,12 +9,11 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Squidex.Core.Schemas;
using FluentAssertions;
using Squidex.Infrastructure;
using Xunit;
using FluentAssertions;
namespace Squidex.Core.Tests.Schemas
namespace Squidex.Core.Schemas
{
public class StringFieldTests
{

5
tests/Squidex.Core.Tests/Schemas/Validators/AllowedValuesValidatorTests.cs

@ -8,11 +8,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Squidex.Core.Schemas.Validators;
using Xunit;
using FluentAssertions;
using Xunit;
namespace Squidex.Core.Tests.Schemas.Validators
namespace Squidex.Core.Schemas.Validators
{
public class AllowedValuesValidatorTests
{

3
tests/Squidex.Core.Tests/Schemas/Validators/PatternValidatorTests.cs

@ -9,10 +9,9 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentAssertions;
using Squidex.Core.Schemas.Validators;
using Xunit;
namespace Squidex.Core.Tests.Schemas.Validators
namespace Squidex.Core.Schemas.Validators
{
public class PatternValidatorTests
{

3
tests/Squidex.Core.Tests/Schemas/Validators/RangeValidatorTests.cs

@ -10,10 +10,9 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentAssertions;
using Squidex.Core.Schemas.Validators;
using Xunit;
namespace Squidex.Core.Tests.Schemas.Validators
namespace Squidex.Core.Schemas.Validators
{
public class RangeValidatorTests
{

5
tests/Squidex.Core.Tests/Schemas/Validators/RequiredStringValidatorTests.cs

@ -8,11 +8,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Squidex.Core.Schemas.Validators;
using Xunit;
using FluentAssertions;
using Xunit;
namespace Squidex.Core.Tests.Schemas.Validators
namespace Squidex.Core.Schemas.Validators
{
public sealed class RequiredStringValidatorTests
{

5
tests/Squidex.Core.Tests/Schemas/Validators/RequiredValidatorTests.cs

@ -8,11 +8,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Squidex.Core.Schemas.Validators;
using Xunit;
using FluentAssertions;
using Xunit;
namespace Squidex.Core.Tests.Schemas.Validators
namespace Squidex.Core.Schemas.Validators
{
public sealed class RequiredValidatorTests
{

3
tests/Squidex.Core.Tests/Schemas/Validators/StringLengthValidatorTests.cs

@ -11,10 +11,9 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using FluentAssertions;
using Squidex.Core.Schemas.Validators;
using Xunit;
namespace Squidex.Core.Tests.Schemas.Validators
namespace Squidex.Core.Schemas.Validators
{
public class StringLengthValidatorTests
{

2
tests/Squidex.Core.Tests/Squidex.Core.Tests.xproj

@ -7,7 +7,7 @@
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>fd0afd44-7a93-4f9e-b5ed-72582392e435</ProjectGuid>
<RootNamespace>Squidex.Core.Tests</RootNamespace>
<RootNamespace>Squidex.Core</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

2
tests/Squidex.Core.Tests/project.json

@ -26,7 +26,7 @@
},
"testRunner": "xunit",
"tooling": {
"defaultNamespace": "Squidex.Core.Tests"
"defaultNamespace": "Squidex.Core"
},
"tools": {
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"

17
tests/Squidex.Infrastructure.Tests/UserTokenTests.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace Squidex.Infrastructure
{
public class UserTokenTests
{
[Fact]
public void Should_parse_user_token_from_string()
{
var token = UserToken.Parse("")
}
}
}

14
tests/Squidex.Write.Tests/Apps/AppCommandHandlerTests.cs

@ -9,6 +9,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FluentAssertions;
using Moq;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS.Commands;
@ -16,15 +17,14 @@ using Squidex.Read.Apps;
using Squidex.Read.Apps.Repositories;
using Squidex.Read.Users;
using Squidex.Read.Users.Repositories;
using Squidex.Write.Apps;
using Squidex.Write.Apps.Commands;
using Squidex.Write.Tests.Utils;
using Squidex.Write.Utils;
using Xunit;
using FluentAssertions;
// ReSharper disable ImplicitlyCapturedClosure
// ReSharper disable ConvertToConstant.Local
namespace Squidex.Write.Tests.Apps
namespace Squidex.Write.Apps
{
public class AppCommandHandlerTests : HandlerTestBase<AppDomainObject>
{
@ -54,7 +54,7 @@ namespace Squidex.Write.Tests.Apps
[Fact]
public async Task Create_should_throw_if_a_name_with_same_name_already_exists()
{
var command = new CreateApp { Name = appName, AggregateId = Id, SubjectId = subjectId };
var command = new CreateApp { Name = appName, AggregateId = Id, UserId = subjectId };
var context = new CommandContext(command);
appRepository.Setup(x => x.FindAppByNameAsync(appName)).Returns(Task.FromResult(new Mock<IAppEntity>().Object)).Verifiable();
@ -70,7 +70,7 @@ namespace Squidex.Write.Tests.Apps
[Fact]
public async Task Create_should_create_app_if_name_is_free()
{
var command = new CreateApp { Name = appName, AggregateId = Id, SubjectId = subjectId };
var command = new CreateApp { Name = appName, AggregateId = Id, UserId = subjectId };
var context = new CommandContext(command);
appRepository.Setup(x => x.FindAppByNameAsync(appName)).Returns(Task.FromResult<IAppEntity>(null)).Verifiable();
@ -200,7 +200,7 @@ namespace Squidex.Write.Tests.Apps
private AppDomainObject CreateApp()
{
app.Create(new CreateApp { Name = appName, SubjectId = subjectId });
app.Create(new CreateApp { Name = appName, UserId = subjectId });
return app;
}

8
tests/Squidex.Write.Tests/Apps/AppDomainObjectTests.cs

@ -15,12 +15,12 @@ using Squidex.Events.Apps;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.CQRS.Events;
using Squidex.Write.Apps;
using Squidex.Write.Apps.Commands;
using Xunit;
// ReSharper disable ConvertToConstant.Local
namespace Squidex.Write.Tests.Apps
namespace Squidex.Write.Apps
{
public class AppDomainObjectTests
{
@ -54,7 +54,7 @@ namespace Squidex.Write.Tests.Apps
[Fact]
public void Create_should_specify_name_and_owner()
{
sut.Create(new CreateApp { Name = TestName, SubjectId = subjectId });
sut.Create(new CreateApp { Name = TestName, UserId = subjectId });
Assert.Equal(TestName, sut.Name);
Assert.Equal(PermissionLevel.Owner, sut.Contributors[subjectId]);
@ -271,7 +271,7 @@ namespace Squidex.Write.Tests.Apps
private void CreateApp()
{
sut.Create(new CreateApp { Name = TestName, SubjectId = subjectId });
sut.Create(new CreateApp { Name = TestName, UserId = subjectId });
((IAggregate)sut).ClearUncommittedEvents();
}

3
tests/Squidex.Write.Tests/Apps/ClientKeyGeneratorTests.cs

@ -6,10 +6,9 @@
// All rights reserved.
// ==========================================================================
using Squidex.Write.Apps;
using Xunit;
namespace Squidex.Write.Tests.Apps
namespace Squidex.Write.Apps
{
public class ClientKeyGeneratorTests
{

6
tests/Squidex.Write.Tests/Schemas/SchemaCommandHandlerTests.cs

@ -14,13 +14,13 @@ using Squidex.Core.Schemas;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS.Commands;
using Squidex.Read.Schemas.Services;
using Squidex.Write.Schemas;
using Squidex.Write.Schemas.Commands;
using Squidex.Write.Tests.Utils;
using Squidex.Write.Utils;
using Xunit;
// ReSharper disable ConvertToConstant.Local
namespace Squidex.Write.Tests.Schemas
namespace Squidex.Write.Schemas
{
public class SchemaCommandHandlerTests : HandlerTestBase<SchemaDomainObject>
{

4
tests/Squidex.Write.Tests/Schemas/SchemaDomainObjectTests.cs

@ -14,12 +14,12 @@ using Squidex.Events.Schemas;
using Squidex.Infrastructure;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.CQRS.Events;
using Squidex.Write.Schemas;
using Squidex.Write.Schemas.Commands;
using Xunit;
// ReSharper disable ConvertToConstant.Local
namespace Squidex.Write.Tests.Schemas
namespace Squidex.Write.Schemas
{
[Collection("Schema")]
public class SchemaDomainObjectTests

2
tests/Squidex.Write.Tests/Squidex.Write.Tests.xproj

@ -7,7 +7,7 @@
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>9a3dea7e-1681-4d48-ac5c-1f0de421a203</ProjectGuid>
<RootNamespace>Squidex.Write.Tests</RootNamespace>
<RootNamespace>Squidex.Write</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

2
tests/Squidex.Write.Tests/Utils/HandlerTestBase.cs

@ -12,7 +12,7 @@ using Moq;
using Squidex.Infrastructure.CQRS;
using Squidex.Infrastructure.CQRS.Commands;
namespace Squidex.Write.Tests.Utils
namespace Squidex.Write.Utils
{
public abstract class HandlerTestBase<T> where T : DomainObject
{

2
tests/Squidex.Write.Tests/Utils/SchemaFixture.cs

@ -11,7 +11,7 @@ using Squidex.Core.Schemas;
using Squidex.Infrastructure;
using Xunit;
namespace Squidex.Write.Tests.Utils
namespace Squidex.Write.Utils
{
public class SchemaFixture
{

2
tests/Squidex.Write.Tests/project.json

@ -27,7 +27,7 @@
},
"testRunner": "xunit",
"tooling": {
"defaultNamespace": "Squidex.Write.Tests"
"defaultNamespace": "Squidex.Write"
},
"tools": {
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"

Loading…
Cancel
Save