private async Task InitOnce() { if (_app != null) { return; } LogHelper.ConfigureConsoleLogger(); _gryffindorHouseGuid = Guid.NewGuid(); _otherTenantGuid = Guid.NewGuid(); _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(options); _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>()); await _apiClient.AsSiteAdminAsync(_httpClient); _allSiteRoles = (await _apiClient.GetRolesAsync()).ToList(); var gryff = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse); _gryffindorRoles = (await _apiClient.GetRolesAsync()).ToList(); _gryffindorHouseAdminRoleId = gryff.TenantAdminRoleId; _newRoleInTenantId = _gryffindorRoles.First(r => r.Id != _gryffindorHouseAdminRoleId.ToString()).Id; }
private async Task InitOnce() { if (_app != null) return; _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions() { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(options); _apiClient = new ApiClient(_httpClient, _app.GetLogger<ApiClient>()); // create tenants here await _apiClient.AsSiteAdminAsync(_httpClient); _gryffindorHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse); await TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _gryffindorHouse); await TestDepartment.SeedDefaultDepartments(_apiClient, _gryffindorHouse); await TestPosition.SeedDefaultPosition(_apiClient, _gryffindorHouse); await TestEmployees.SeedDefaultEmployees(_apiClient, _gryffindorHouse); _gryffindorEmployees = (await _apiClient.GetEmployeesAsync()).ToList(); await _apiClient.AsSiteAdminAsync(_httpClient); _slytherinHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.SlytherinHouse); await TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _slytherinHouse); await TestDepartment.SeedDefaultDepartments(_apiClient, _slytherinHouse); await TestPosition.SeedDefaultPosition(_apiClient, _slytherinHouse); await TestEmployees.SeedDefaultEmployees(_apiClient, _slytherinHouse); }
private async Task InitOnce() { if (_app != null) { return; } LogHelper.ConfigureConsoleLogger(); _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions() { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(options); _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>()); _apiClient.SignInWithUserPassword_WithSlug_Async( TestUsers.DefaultSiteAdminName, TestUsers.DefaultSiteAdminPass, _httpClient, "").Wait(); _siteAdminUser = await _apiClient.GetCurrentUserAsync(); _gryffindorHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse); await _apiClient.SignInWithUserPassword_WithSlug_Async( TestUsers.DefaultSiteAdminName, TestUsers.DefaultSiteAdminPass, _httpClient, ""); _slytherinHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.SlytherinHouse); }
private async Task InitOnce() { if (_app != null) { return; } LogHelper.ConfigureConsoleLogger(); _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions() { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(/* not using options */); _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>()); await _apiClient.AsSiteAdminAsync(_httpClient); var tenant = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse); _gryffindorTenantId = tenant.Tenant.Id; await _apiClient.AsSiteAdminAsync(_httpClient); var tenant2 = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.SlytherinHouse); _slytherinTenantId = tenant2.Tenant.Id; }
private async Task InitOnce() { if (_app != null) { return; } LogHelper.ConfigureConsoleLogger(); _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions() { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(options); _unauthorizedHttpClient = _app.CreateClient(options); _unauthorizedHttpClient.DefaultRequestHeaders.Add("accept", "application/json"); _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>()); await _apiClient.AsSiteAdminAsync(_httpClient); _siteAdminUser = await _apiClient.GetCurrentUserAsync(); _siteRoles = (await _apiClient.GetRolesAsync()).ToList(); { var gryffindorTenant = await TestTenants.CreateTenantWithRolesAndUsers( _apiClient, _httpClient, TestTenants.GryffindorHouse); _gryffindorAdminUser = gryffindorTenant.AdminUser; await _apiClient.AsGryffindorAdminAsync(_httpClient); _gryffindorRoles = (await _apiClient.GetRolesAsync()).ToList(); _gryffindorAdminRoleId = gryffindorTenant.TenantAdminRoleId.ToString(); } await _apiClient.AsSiteAdminAsync(_httpClient); { var slytherinTenant = await TestTenants.CreateTenantWithRolesAndUsers( _apiClient, _httpClient, TestTenants.SlytherinHouse); _slytherinAdminUser = slytherinTenant.AdminUser; await _apiClient.AsSlytherinAdminAsync(_httpClient); _slytherinRoles = (await _apiClient.GetRolesAsync()).ToList(); _slytherinAdminRoleId = slytherinTenant.TenantAdminRoleId.ToString(); } }
private async Task InitOnce() { if (_app != null) { return; } LogHelper.ConfigureConsoleLogger(); _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(options); var apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>()); apiClient.TraceResponseOnException = true; _apiClient = apiClient; // site admin creates 2 tenants await _apiClient.AsSiteAdminAsync(_httpClient); _gryffindorHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse); await _apiClient.AsSiteAdminAsync(_httpClient); _slytherinHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.SlytherinHouse); // Slytherin House admin creates branch office and departments await _apiClient.AsSlytherinAdminAsync(_httpClient); TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _slytherinHouse).Wait(); TestDepartment.SeedDefaultDepartments(_apiClient, _slytherinHouse).Wait(); TestPosition.SeedDefaultPosition(_apiClient, _slytherinHouse).Wait(); TestEmployees.SeedDefaultEmployees(_apiClient, _slytherinHouse).Wait(); // Gryffindor House admin creates branch office and departments await _apiClient.AsGryffindorAdminAsync(_httpClient); TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _gryffindorHouse).Wait(); TestDepartment.SeedDefaultDepartments(_apiClient, _gryffindorHouse).Wait(); TestPosition.SeedDefaultPosition(_apiClient, _gryffindorHouse).Wait(); TestEmployees.SeedDefaultEmployees(_apiClient, _gryffindorHouse).Wait(); _workDepartmentId = _gryffindorHouse.Department_1_2.Department.Id; }
private async Task InitOnce() { if (_app != null) { return; } LogHelper.ConfigureConsoleLogger(); _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(options); _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>()); // admin creates Gryffindor tenant and initializes default branch office await _apiClient.AsSiteAdminAsync(_httpClient); var tenant = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse); _gryffindorHouseAdminRoleId = tenant.TenantAdminRoleId; _tenantRoles = await _apiClient.GetRolesAsync(); // Create a site role await _apiClient.AsSiteAdminAsync(_httpClient); var siteRole = new RoleDto() { Name = "Qwertyasdfzcv 123", Description = "Hello, world" }; await _apiClient.PostRoleAsync(siteRole); _siteRoles = await _apiClient.GetRolesAsync(); _siteRoles = _siteRoles.Where(sr => !_tenantRoles.Any(tr => tr.Id == sr.Id)); }
private async Task InitOnce() { if (_app != null) { return; } LogHelper.ConfigureConsoleLogger(); _app = new DefaultWebApplicationFactory(); var options = new WebApplicationFactoryClientOptions() { AllowAutoRedirect = false }; _httpClient = _app.CreateClient(options); _apiClient = new ApiClient(_httpClient, _app.GetLogger <ApiClient>()); // admin creates Gryffindor tenant and initializes default branch office await _apiClient.AsSiteAdminAsync(_httpClient); _siteAdminUser = await _apiClient.GetCurrentUserAsync(); _gryffindorHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.GryffindorHouse); await _apiClient.AsGryffindorAdminAsync(_httpClient); await TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _gryffindorHouse); // admin creates Slytherin tenant and initializes default branch office await _apiClient.AsSiteAdminAsync(_httpClient); _slytherinHouse = await TestTenants.CreateTenantWithRolesAndUsers(_apiClient, _httpClient, TestTenants.SlytherinHouse); await _apiClient.AsSlytherinAdminAsync(_httpClient); await TestBranchOffice.SeedDefaultBranchOffice(_apiClient, _httpClient, _slytherinHouse); }