public void CreateDataCase17() { CreateBaseData(); var simAndDeviceAuthenticated = new SimAndDeviceAuthenticated() { SimAndDevice = SimAndDevice1, Expiration = CurrentDateTimeForLessThanStart.Item2 }; MainDbContext.AddRange(simAndDeviceAuthenticated); SimAndDevice1.SimAndDeviceAuthenticated = simAndDeviceAuthenticated; var multiFactorAuthenticated = new MultiFactorAuthenticated() { MultiFactor = MultiFactor1, Expiration = CurrentDateTimeForLessThanStart.Item2 }; MainDbContext.AddRange(multiFactorAuthenticated); MultiFactor1.MultiFactorAuthenticated = multiFactorAuthenticated; MainDbContext.SaveChanges(); RadiusDbContext.SaveChanges(); }
public void Case12() { SetUpData(); for (int j = 1; j <= 2; j++) { for (int i = 1; i <= 25; i++) { var simDeviceAuthenticationStateDone = new SimAndDeviceAuthenticated() { Expiration = DateTime.Now.AddHours(6.00) }; var simDevice = new SimAndDevice() // 正常データ { Sim = _sim1, Device = _device1, IsolatedNw2Ip = $"127.0.0.{i:00}", AuthenticationDuration = i, StartDate = DateTime.Parse($"2020-{j:00}-{i:00}"), EndDate = DateTime.Parse($"2021-{j:00}-{i:00}"), SimAndDeviceAuthenticated = simDeviceAuthenticationStateDone }; _context.AddRange(simDevice, simDeviceAuthenticationStateDone); } } _context.SaveChanges(); var(response, _, json) = Utils.Get(_client, $"{Url}/?page=1&pageSize=2&Msisdn=msisdn&DeviceName=device&startDateFrom=2019-12-29&startDateTo=2020-02-27&endDateFrom=2020-12-29&endDateTo=2021-02-27&IsAuthenticationDone=True&sortBy=endDate&orderBy=asc", "user1", "user1", 1, "domain01"); // ユーザー管理者 var list = (JArray)json["results"]; Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(2, list.Count); Assert.Equal(50, (int)json["count"]); Assert.Equal("2021-01-01", list[0]["endDate"]); Assert.Equal("2021-01-02", list[1]["endDate"]);// 利用終了日ソート:'昇順 }
public void Case05() { var simDeviceAuthenticationStateDone = new SimAndDeviceAuthenticated() { Expiration = DateTime.Now.AddHours(1.00) }; var simDevice1 = new SimAndDevice() // 組織 : '自組織 { Sim = _sim1, Device = _device1, IsolatedNw2Ip = "127.0.0.1", AuthenticationDuration = 1, StartDate = DateTime.Parse("2020-02-07"), SimAndDeviceAuthenticated = simDeviceAuthenticationStateDone }; _context.Add(simDeviceAuthenticationStateDone); _context.Add(simDevice1); _context.SaveChanges(); var(response, _, json) = Utils.Get(_client, $"{Url}/{simDevice1.Id}", "user1", "user1", 1, "domain01"); // ユーザー管理者 Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(simDevice1.Id.ToString(), json["id"]); Assert.Equal(simDevice1.Sim.Msisdn, json["sim"]["msisdn"]); Assert.Equal(simDevice1.Device.Name, json["device"]["name"]); Assert.Equal(simDevice1.IsolatedNw2Ip, json["isolatedNw2Ip"]); Assert.Equal(simDevice1.AuthenticationDuration, json["authenticationDuration"]); Assert.Equal(simDevice1.StartDate.ToString("yyyy-MM-dd"), json["startDate"]); Assert.Null(json["endDate"].FirstOrDefault()); Assert.Equal(simDeviceAuthenticationStateDone.Id, json["simAndDeviceAuthenticated"]["id"]); }
public void SetUpInsertDataForDeauthenticationCase20() { var simDevice = SetUpInsertDataForDeauthenticationCase13(); var simDeviceAuthenticationStateDone = new SimAndDeviceAuthenticated { Expiration = DateTime.Now.AddHours(1.00) }; simDevice.SimAndDeviceAuthenticated = simDeviceAuthenticationStateDone; MainDbContext.SimAndDeviceAuthenticated.Add(simDeviceAuthenticationStateDone); MainDbContext.SaveChanges(); CreateUser6(simDevice); }
public void CreateDataCase10() { CreateBaseData(); var simAndDeviceAuthenticated = new SimAndDeviceAuthenticated() { SimAndDevice = SimAndDevice1, Expiration = CurrentDateTimeForEnd.Item2 }; MainDbContext.AddRange(simAndDeviceAuthenticated); SimAndDevice1.SimAndDeviceAuthenticated = simAndDeviceAuthenticated; MainDbContext.SaveChanges(); RadiusDbContext.SaveChanges(); }
public void SetUpInsertDataForDeauthenticationCase21() { var simDevice = SetUpInsertDataForDeauthenticationCase13(); var simDeviceAuthenticationStateDone = new SimAndDeviceAuthenticated { Expiration = DateTime.Now.AddHours(1.00) }; simDevice.SimAndDeviceAuthenticated = simDeviceAuthenticationStateDone; MainDbContext.SimAndDeviceAuthenticated.Add(simDeviceAuthenticationStateDone); var factorCombination = CreateUser6(simDevice); var multiFactorAuthenticationStateDone = new MultiFactorAuthenticated { Expiration = DateTime.Now.AddHours(1.00) }; factorCombination.MultiFactorAuthenticated = multiFactorAuthenticationStateDone; MainDbContext.MultiFactorAuthenticated.Add(multiFactorAuthenticationStateDone); MainDbContext.SaveChanges(); }
public void Case10() { for (int j = 1; j <= 2; j++) { for (int i = 1; i <= 25; i++) { var simDeviceAuthenticationStateDone = new SimAndDeviceAuthenticated() { Expiration = DateTime.Now.AddHours(6.00) }; var simDevice = new SimAndDevice() // 組織 : '自組織 認証済み:'フィルターに合致 { Sim = _sim1, Device = _device1, IsolatedNw2Ip = $"127.0.0.{i:00}", AuthenticationDuration = i, StartDate = DateTime.Parse($"2020-{j:00}-{i:00}"), SimAndDeviceAuthenticated = simDeviceAuthenticationStateDone }; _context.AddRange(simDevice, simDeviceAuthenticationStateDone); } } _context.Add(new SimAndDevice() // 組織 : '自組織 認証済み:'フィルターに合致せず { Sim = _sim1, Device = _device1, IsolatedNw2Ip = "127.0.0.1", AuthenticationDuration = 1, StartDate = DateTime.Parse("2020-02-01") }); _context.SaveChanges(); var(response, _, json) = Utils.Get(_client, $"{Url}/?page=3&IsAuthenticationDone=True&sortBy=startDate&orderBy=asc", "user1", "user1", 1, "domain01"); // ユーザー管理者 var list = (JArray)json["results"]; Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.InRange(list.Count, 1, 20); Assert.Equal(50, (int)json["count"]); Assert.Equal("2020-02-16", list[0]["startDate"]); Assert.Equal("2020-02-17", list[1]["startDate"]); // 利用開始日ソート:'昇順 }
private SimAndDeviceAuthenticated CreateSimAndDeviceAuthenticated(SimAndDevice simAndDevice) { string startTime = _configuration.GetSection("Auth:ExpireHour").Value; var simAndDeviceAuthenticated = simAndDevice.SimAndDeviceAuthenticated; if (simAndDeviceAuthenticated == null) { simAndDeviceAuthenticated = new SimAndDeviceAuthenticated { Expiration = DateTime.Now.AddHours(double.Parse(startTime)) }; simAndDevice.SimAndDeviceAuthenticated = simAndDeviceAuthenticated; _authenticationRepository.Create(simAndDeviceAuthenticated); } else { simAndDeviceAuthenticated.Expiration = DateTime.Now.AddHours(double.Parse(startTime)); _authenticationRepository.Update(simAndDeviceAuthenticated); } return(simAndDeviceAuthenticated); }
public void Case03() { var simDeviceAuthenticationStateDone = new SimAndDeviceAuthenticated() { Expiration = DateTime.Now.AddHours(1.00) }; var simDevice1 = new SimAndDevice() // 組織 : '他組織 { Sim = _sim2, Device = _device1, IsolatedNw2Ip = "127.0.0.1", AuthenticationDuration = 1, StartDate = DateTime.Parse("2020-02-07"), EndDate = DateTime.Now.AddHours(6.00), SimAndDeviceAuthenticated = simDeviceAuthenticationStateDone }; _context.Add(simDeviceAuthenticationStateDone); _context.Add(simDevice1); _context.SaveChanges(); var(response, _, json) = Utils.Get(_client, $"{Url}/{simDevice1.Id}", "user1", "user1", 1, "domain01"); // ユーザー管理者 Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); Assert.NotNull(json["errors"]["Role"]); }
private SimDeviceAuthenticationResponse CreateSimDeviceAuthenticationResponse(SimAndDeviceAuthenticated simAndDeviceAuthenticated, SimAndDevice simAndDevice, HashSet <string> canLogonUsers) { var simDeviceAuthenticationResponse = new SimDeviceAuthenticationResponse { AuthId = simAndDeviceAuthenticated.Id, CanLogonUsers = canLogonUsers, AssignDeviceIpAddress = simAndDevice.IsolatedNw2Ip, WindowsSignInListCacheDays = simAndDevice.Device.WindowsSignInListCacheDays, IsSoftwareRadioState = simAndDevice.Device.LteModule?.UseSoftwareRadioState, AuthenticationDuration = simAndDevice.AuthenticationDuration }; if (simAndDevice.Device.OrganizationClientApp != null) { var clientInformation = new SimDeviceAuthenticationResponse.ClientInformation(); clientInformation.Os = simAndDevice.Device.OrganizationClientApp?.ClientApp.ClientOs.Name; try { clientInformation.Version = new Version(simAndDevice.Device.OrganizationClientApp?.ClientApp.Version); } catch (ArgumentException) { _logger.LogWarning($"Invalid Version {simAndDevice.Device.OrganizationClientApp?.ClientApp.Version}"); } simDeviceAuthenticationResponse.Client = clientInformation; } return(simDeviceAuthenticationResponse); }