protected WebApplicationBase(WebApplicationFactory <Auth.Startup> factory, ITestOutputHelper testOutputHelper)
        {
            TestOutputHelper = testOutputHelper;
            TestOutputHelper.WriteLine("Construct");

            Client = factory.CreateClient();
            Client.DefaultRequestHeaders.Accept.Clear();
            Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json));

            var scope = factory.Services.GetService <IServiceScopeFactory>().CreateScope();

            MainDbContext   = scope.ServiceProvider.GetService <MainDbContext>();
            RadiusDbContext = scope.ServiceProvider.GetService <RadiusDbContext>();

            UserRepository           = scope.ServiceProvider.GetService <UserRepository>();
            AuthenticationRepository = scope.ServiceProvider.GetService <AuthenticationRepository>();
            RadiusRepository         = scope.ServiceProvider.GetService <RadiusRepository>();

            TestOutputHelper.WriteLine("Database Init");
            MainDbContext.Database.EnsureDeleted();
            //MainDbContext.Database.EnsureCreated();
            MainDbContext.Database.Migrate();

            RadiusDbContext.Database.EnsureDeleted();
            RadiusDbContext.Database.EnsureCreated();
            RadiusDbContext.Database.Migrate();
        }
Exemple #2
0
 public RadiusSync(ILogger <RadiusSync> logger, IConfiguration configuration, AuthenticationRepository authenticationRepository, RadiusRepository radiusRepository)
 {
     this._logger                   = logger;
     this._configuration            = configuration;
     this._authenticationRepository = authenticationRepository;
     this._radiusRepository         = radiusRepository;
 }
 public MultiFactorAuthenticationController(ILogger <MultiFactorAuthenticationController> logger,
                                            AuthenticationRepository authenticationRepository, RadiusRepository radiusRepository,
                                            IConfiguration configuration)
 {
     _logger = logger;
     _authenticationRepository = authenticationRepository;
     _radiusRepository         = radiusRepository;
     _configuration            = configuration;
 }
 public SimDeviceAuthenticationController(ILogger <SimDeviceAuthenticationController> logger,
                                          AuthenticationRepository authenticationRepository,
                                          RadiusRepository radiusRepository,
                                          IConfiguration configuration)
 {
     _logger = logger;
     _authenticationRepository = authenticationRepository;
     _radiusDbRepository       = radiusRepository;
     _configuration            = configuration;
 }
Exemple #5
0
        public BatchTestBase(ITestOutputHelper testOutputHelper)
        {
            TestOutputHelper = testOutputHelper;

            Configuration = new ConfigurationBuilder()
                            .SetBasePath(System.IO.Directory.GetCurrentDirectory())
                            .AddJsonFile("appsettings.json")
                            .Build();
            var config = new ConfigurationBuilder()
                         .SetBasePath(System.IO.Directory.GetCurrentDirectory())
                         .Build();

            HostBuilder = Host.CreateDefaultBuilder()
                          .ConfigureLogging(logging =>
            {
                //logging.ReplaceToSimpleConsole();
                logging.ClearProviders();
                logging.SetMinimumLevel(LogLevel.Trace);
                logging.AddNLog(config);
            })
                          .ConfigureServices((hostContext, services) =>
            {
                services.Configure <IConfiguration>(hostContext.Configuration);

                services.AddDbContext <MainDbContext>(options =>
                {
                    options.UseMySql(hostContext.Configuration.GetConnectionString("MainDbConnection"));
                });
                services.AddDbContext <RadiusDbContext>(options =>
                {
                    options.UseMySql(hostContext.Configuration.GetConnectionString("RadiusDbConnection"));
                });

                services.AddTransient <UserRepository>();
                services.AddTransient <AuthenticationRepository>();
                services.AddTransient <RadiusRepository>();
            });


            var mainDbContextOptions = new DbContextOptionsBuilder <MainDbContext>()
                                       .UseMySql(Configuration.GetConnectionString("MainDbConnection"))
                                       .Options;
            var radiusDdbContextOptions = new DbContextOptionsBuilder <RadiusDbContext>()
                                          .UseMySql(Configuration.GetConnectionString("RadiusDbConnection"))
                                          .Options;

            MainDbContext   = new MainDbContext(mainDbContextOptions);
            RadiusDbContext = new RadiusDbContext(radiusDdbContextOptions);

            UserRepository           = new UserRepository(MainDbContext);
            AuthenticationRepository = new AuthenticationRepository(MainDbContext);
            RadiusRepository         = new RadiusRepository(RadiusDbContext);

            TestOutputHelper.WriteLine("Database Init");
            //MainDbContext.Database.EnsureDeleted();
            //MainDbContext.Database.EnsureCreated();
            //MainDbContext.Database.Migrate();

            //RadiusDbContext.Database.EnsureDeleted();
            //RadiusDbContext.Database.EnsureCreated();
            //RadiusDbContext.Database.Migrate();

            RemoveAllEntities(MainDbContext, RadiusDbContext);
        }
 public HealthCheckController(ILogger <HealthCheckController> logger, UserRepository userRepository, RadiusRepository radiusRepository)
 {
     _logger           = logger;
     _userRepository   = userRepository;
     _radiusRepository = radiusRepository;
 }