public void Cannot_execute_BackendIpRegulationService_without_permissions() { /* Arrange */ LogWithNewAdmin(Modules.PlayerManager, Permissions.View); /* Act */ Assert.Throws <InsufficientPermissionsException>(() => _brandService.GetIpRegulations()); Assert.Throws <InsufficientPermissionsException>(() => _brandService.CreateIpRegulation(new AddBrandIpRegulationData())); Assert.Throws <InsufficientPermissionsException>(() => _brandService.UpdateIpRegulation(new EditBrandIpRegulationData())); Assert.Throws <InsufficientPermissionsException>(() => _brandService.DeleteIpRegulation(new Guid())); }
public void Can_update_brand_ip_regulation() { /*** Arrange ***/ var ipAddress = TestDataGenerator.GetRandomIpAddress(); const string redirectionUrl = "google.com"; var brandIpRegulation = new AddBrandIpRegulationData { IpAddress = ipAddress, BrandId = Brand.Id, LicenseeId = Brand.LicenseeId, // Ip address is blocked with redirection to specified Url BlockingType = IpRegulationConstants.BlockingTypes.Redirection, RedirectionUrl = redirectionUrl }; _brandService.CreateIpRegulation(brandIpRegulation); var regulation = _brandService.GetIpRegulations().SingleOrDefault(ip => ip.IpAddress == ipAddress); var editIpAddress = TestDataGenerator.GetRandomIpAddress(); var editDescription = TestDataGenerator.GetRandomString(20); var editData = new EditBrandIpRegulationData { Id = regulation.Id, LicenseeId = Brand.LicenseeId, BrandId = Brand.Id, IpAddress = editIpAddress, Description = editDescription, BlockingType = IpRegulationConstants.BlockingTypes.LoginRegistration }; /*** Act ***/ _brandService.UpdateIpRegulation(editData); /*** Assert ***/ var updatedRegulation = _brandService.GetIpRegulations().SingleOrDefault(ip => ip.IpAddress == editIpAddress); Assert.IsNotNull(updatedRegulation); Assert.AreEqual(updatedRegulation.IpAddress, editIpAddress); Assert.AreEqual(updatedRegulation.Description, editDescription); Assert.AreEqual(updatedRegulation.BlockingType, IpRegulationConstants.BlockingTypes.LoginRegistration); }