Beispiel #1
0
        public async Task CreateRoleTest()
        {
            var droneRoleValidator = new DroneRoleValidator(_roleManager);

            _roleManager.CreateAsync(Arg.Any <IdentityRole>()).Returns(new IdentityResult());
            await droneRoleValidator.CreateRoleAsync("teste");
        }
Beispiel #2
0
        public async Task ExistRoleTest()
        {
            var droneRoleValidator = new DroneRoleValidator(_roleManager);

            _roleManager.RoleExistsAsync(Arg.Any <string>()).Returns(true);
            var exists = await droneRoleValidator.ExistRoleAsync("teste");

            Assert.True(exists);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
                              ApplicationDbContext context,
                              UserManager <ApplicationUser> userManager,
                              RoleManager <IdentityRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();
            app.UseCors("CorsPolicy");

            // Criação de estruturas, usuários e permissões
            // na base do ASP.NET Identity Core (caso ainda não
            // existam)
            var validateDatabase   = new ValidateDatabse();
            var droneRoleValidator = new DroneRoleValidator(roleManager);

            new IdentityInitializer(validateDatabase, userManager, droneRoleValidator).Initialize();

            // Swagger
            app.UseSwagger()
            .UseSwaggerUI(c =>
            {
                c.RoutePrefix = string.Empty;
                c.SwaggerEndpoint(SWAGGERFILE_PATH, ProjectConsts.PROJECT_NAME + ProjectConsts.API_VERSION);
            });

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }