Skip to content

Commit

Permalink
Merge pull request #204 from SaintAngeLs/identity_service_tests
Browse files Browse the repository at this point in the history
(#188) Identity service tests
  • Loading branch information
olegkiprik committed May 27, 2024
2 parents bf37e4d + bc84052 commit 2990c24
Show file tree
Hide file tree
Showing 32 changed files with 705 additions and 0 deletions.
15 changes: 15 additions & 0 deletions MiniSpace.Services.Identity/MiniSpace.Services.Identity.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniSpace.Services.Identity
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniSpace.Services.Identity.Infrastructure.UnitTests", "tests\MiniSpace.Services.Identity.Infrastructure.UnitTests\MiniSpace.Services.Identity.Infrastructure.UnitTests.csproj", "{F8D738D3-3485-4A9C-892A-54522694B270}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MiniSpace.Services.Identity.Core.UnitTests", "tests\MiniSpace.Services.Identity.Core.UnitTests\MiniSpace.Services.Identity.Core.UnitTests.csproj", "{56cf9ea6-644c-4fe3-86b0-b3b92185de47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -104,6 +106,18 @@ Global
{F8D738D3-3485-4A9C-892A-54522694B270}.Release|x64.Build.0 = Release|Any CPU
{F8D738D3-3485-4A9C-892A-54522694B270}.Release|x86.ActiveCfg = Release|Any CPU
{F8D738D3-3485-4A9C-892A-54522694B270}.Release|x86.Build.0 = Release|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Debug|x64.ActiveCfg = Debug|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Debug|x64.Build.0 = Debug|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Debug|x86.ActiveCfg = Debug|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Debug|x86.Build.0 = Debug|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Release|Any CPU.Build.0 = Release|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Release|x64.ActiveCfg = Release|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Release|x64.Build.0 = Release|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Release|x86.ActiveCfg = Release|Any CPU
{56cf9ea6-644c-4fe3-86b0-b3b92185de47}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AFCB936C-D59B-47AA-9152-E97D33798A68} = {3B3DEC12-51E9-47DC-BA78-6B61C15FFA37}
Expand All @@ -112,5 +126,6 @@ Global
{F16801D7-FC50-4DAC-806B-46D0FEF1C962} = {3B3DEC12-51E9-47DC-BA78-6B61C15FFA37}
{C040B759-5FCA-4E6F-A8A2-AF3A968DAC27} = {B2FC737B-10D2-4E96-BADD-6A39826E3BCB}
{F8D738D3-3485-4A9C-892A-54522694B270} = {B2FC737B-10D2-4E96-BADD-6A39826E3BCB}
{56cf9ea6-644c-4fe3-86b0-b3b92185de47} = {B2FC737B-10D2-4E96-BADD-6A39826E3BCB}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Diagnostics.CodeAnalysis;

namespace MiniSpace.Services.Identity.Application.DTO
{
[ExcludeFromCodeCoverage]
public class AuthDto
{
public string AccessToken { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using MiniSpace.Services.Identity.Core.Entities;

namespace MiniSpace.Services.Identity.Application.DTO
{
[ExcludeFromCodeCoverage]
public class UserDto
{
public Guid Id { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using Convey;
using Convey.CQRS.Commands;
using Convey.CQRS.Events;

namespace MiniSpace.Services.Identity.Application
{
[ExcludeFromCodeCoverage]
public static class Extensions
{
public static IConveyBuilder AddApplication(this IConveyBuilder builder)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Convey.CQRS.Queries;
using MiniSpace.Services.Identity.Application.DTO;

namespace MiniSpace.Services.Identity.Application.Queries
{
[ExcludeFromCodeCoverage]
public class GetUser : IQuery<UserDto>
{
public Guid UserId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Convey.Auth;
using MiniSpace.Services.Identity.Application.DTO;
using MiniSpace.Services.Identity.Application.Services;

namespace MiniSpace.Services.Identity.Infrastructure.Auth
{
[ExcludeFromCodeCoverage]
public class JwtProvider : IJwtProvider
{
private readonly IJwtHandler _jwtHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Identity;
using MiniSpace.Services.Identity.Application.Services;

namespace MiniSpace.Services.Identity.Infrastructure.Auth
{
[ExcludeFromCodeCoverage]
public class PasswordService : IPasswordService
{
private readonly IPasswordHasher<IPasswordService> _passwordHasher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography;
using MiniSpace.Services.Identity.Application.Services;

namespace MiniSpace.Services.Identity.Infrastructure.Auth
{
[ExcludeFromCodeCoverage]
internal sealed class Rng : IRng
{
private static readonly string[] SpecialChars = new[] {"/", "\\", "=", "+", "?", ":", "&"};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Diagnostics.CodeAnalysis;
using MiniSpace.Services.Identity.Application;

namespace MiniSpace.Services.Identity.Infrastructure.Contexts
{
[ExcludeFromCodeCoverage]
internal class AppContext : IAppContext
{
public string RequestId { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using MiniSpace.Services.Identity.Application;
using System.Diagnostics.CodeAnalysis;

namespace MiniSpace.Services.Identity.Infrastructure.Contexts
{
[ExcludeFromCodeCoverage]
internal sealed class AppContextFactory : IAppContextFactory
{
private readonly ICorrelationContextAccessor _contextAccessor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace MiniSpace.Services.Identity.Infrastructure.Contexts
{
[ExcludeFromCodeCoverage]
internal class CorrelationContext
{
public string CorrelationId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using MiniSpace.Services.Identity.Application;

namespace MiniSpace.Services.Identity.Infrastructure.Contexts
{
[ExcludeFromCodeCoverage]
internal class IdentityContext : IIdentityContext
{
public Guid Id { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Convey.CQRS.Commands;
using Convey.MessageBrokers;
Expand All @@ -7,6 +8,7 @@

namespace MiniSpace.Services.Identity.Infrastructure.Decorators
{
[ExcludeFromCodeCoverage]
[Decorator]
internal sealed class OutboxCommandHandlerDecorator<TCommand> : ICommandHandler<TCommand>
where TCommand : class, ICommand
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Convey.CQRS.Events;
using Convey.MessageBrokers;
Expand All @@ -7,6 +8,7 @@

namespace MiniSpace.Services.Identity.Infrastructure.Decorators
{
[ExcludeFromCodeCoverage]
[Decorator]
internal sealed class OutboxEventHandlerDecorator<TEvent> : IEventHandler<TEvent>
where TEvent : class, IEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Convey.MessageBrokers.RabbitMQ;
using MiniSpace.Services.Identity.Application.Commands;
using MiniSpace.Services.Identity.Application.Events.Rejected;
using MiniSpace.Services.Identity.Core.Exceptions;

namespace MiniSpace.Services.Identity.Infrastructure.Exceptions
{
[ExcludeFromCodeCoverage]
internal sealed class ExceptionToMessageMapper : IExceptionToMessageMapper
{
public object Map(Exception exception, object message)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using Convey;
using Convey.WebApi.Exceptions;
Expand All @@ -8,6 +9,7 @@

namespace MiniSpace.Services.Identity.Infrastructure.Exceptions
{
[ExcludeFromCodeCoverage]
internal sealed class ExceptionToResponseMapper : IExceptionToResponseMapper
{
private static readonly ConcurrentDictionary<Type, string> Codes = new ConcurrentDictionary<Type, string>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
using MiniSpace.Services.Identity.Infrastructure.Mongo.Documents;
using MiniSpace.Services.Identity.Infrastructure.Mongo.Repositories;
using MiniSpace.Services.Identity.Infrastructure.Services;
using System.Diagnostics.CodeAnalysis;

namespace MiniSpace.Services.Identity.Infrastructure
{
[ExcludeFromCodeCoverage]
public static class Extensions
{
public static IConveyBuilder AddInfrastructure(this IConveyBuilder builder)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using MiniSpace.Services.Identity.Application;

namespace MiniSpace.Services.Identity.Infrastructure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using MiniSpace.Services.Identity.Application.DTO;
using MiniSpace.Services.Identity.Core.Entities;

namespace MiniSpace.Services.Identity.Infrastructure.Mongo.Documents
{
[ExcludeFromCodeCoverage]
internal static class Extensions
{
public static User AsEntity(this UserDocument document)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Convey.Types;

namespace MiniSpace.Services.Identity.Infrastructure.Mongo.Documents
{
[ExcludeFromCodeCoverage]
internal sealed class RefreshTokenDocument : IIdentifiable<Guid>
{
public Guid Id { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Convey.Types;

namespace MiniSpace.Services.Identity.Infrastructure.Mongo.Documents
{
[ExcludeFromCodeCoverage]
internal sealed class UserDocument : IIdentifiable<Guid>
{
public Guid Id { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
using Microsoft.Extensions.DependencyInjection;
using MongoDB.Driver;
using MiniSpace.Services.Identity.Infrastructure.Mongo.Documents;
using System.Diagnostics.CodeAnalysis;

namespace MiniSpace.Services.Identity.Infrastructure.Mongo
{
[ExcludeFromCodeCoverage]
public static class Extensions
{
public static IApplicationBuilder UseMongo(this IApplicationBuilder builder)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Convey.CQRS.Queries;
using Convey.Persistence.MongoDB;
Expand All @@ -8,6 +9,7 @@

namespace MiniSpace.Services.Identity.Infrastructure.Mongo.Queries.Handlers
{
[ExcludeFromCodeCoverage]
internal sealed class GetUserHandler : IQueryHandler<GetUser, UserDto>
{
private readonly IMongoRepository<UserDocument, Guid> _userRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Convey.Persistence.MongoDB;
using MiniSpace.Services.Identity.Core.Entities;
Expand All @@ -7,6 +8,7 @@

namespace MiniSpace.Services.Identity.Infrastructure.Mongo.Repositories
{
[ExcludeFromCodeCoverage]
internal sealed class RefreshTokenRepository : IRefreshTokenRepository
{
private readonly IMongoRepository<RefreshTokenDocument, Guid> _repository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Convey.Persistence.MongoDB;
using MiniSpace.Services.Identity.Core.Entities;
Expand All @@ -7,6 +8,7 @@

namespace MiniSpace.Services.Identity.Infrastructure.Mongo.Repositories
{
[ExcludeFromCodeCoverage]
internal sealed class UserRepository : IUserRepository
{
private readonly IMongoRepository<UserDocument, Guid> _repository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Microsoft.Extensions.Logging;
using OpenTracing;
using MiniSpace.Services.Identity.Application.Services;
using System.Diagnostics.CodeAnalysis;

[assembly: InternalsVisibleTo("MiniSpace.Services.Identity.Infrastructure.UnitTests")]
namespace MiniSpace.Services.Identity.Infrastructure.Services
Expand Down
Loading

0 comments on commit 2990c24

Please sign in to comment.